#include "os.h"
#include "common.h"
#include "RRcommon.h"
{
solClient_int32_t operand1;
solClient_int32_t operand2;
double result;
common_handleError ( rc, "solClient_msg_getReplyTo()");
}
common_handleError ( rc, "solClient_msg_getBinaryAttachmentStream()" );
goto createReply;
}
common_handleError ( rc, "solClient_container_getInt8() for operation" );
goto createReply;
}
common_handleError ( rc, "solClient_container_getInt32() for operand1" );
goto createReply;
}
common_handleError ( rc, "solClient_container_getInt32() for operand2" );
goto createReply;
}
switch ( operation ) {
case plusOperation:
result = (double)operand1 + (double)operand2;
resultOk = TRUE;
break;
case minusOperation:
result = (double)operand1 - (double)operand2;
resultOk = TRUE;
break;
case timesOperation:
result = (double)operand1 * (double)operand2;
resultOk = TRUE;
break;
case divideOperation:
if (operand2 != 0) {
result = (double)operand1 / (double)operand2;
resultOk = TRUE;
}
break;
default:
break;
}
createReply:
if ( resultOk ) {
printf( " Received request for %d %s %d, sending reply with result %f. \n",
operand1, RR_operationToString ( operation ), operand2, result );
} else {
printf( " Received request for %d %s %d, sending reply with a failure status. \n",
operand1, RR_operationToString ( operation ), operand2 );
}
common_handleError ( rc, "solClient_msg_alloc()" );
}
common_handleError ( rc, "solClient_msg_createBinaryAttachmentStream()" );
goto freeMsg;
}
common_handleError ( rc, "solClient_container_addBoolean()" );
goto freeMsg;
}
if ( resultOk ) {
common_handleError ( rc, "solClient_container_addDouble()" );
goto freeMsg;
}
}
common_handleError ( rc, "solClient_msg_setDeliveryMode()" );
goto freeMsg;
}
common_handleError ( rc, "solClient_msg_setDestination()" );
goto freeMsg;
}
common_handleError ( rc, "solClient_session_send" );
goto freeMsg;
}
freeMsg:
common_handleError ( rc, "solClient_msg_free()" );
}
}
int
main ( int argc, char *argv[] )
{
struct commonOptions commandOpts;
const char *sessionProps[50];
const char *flowProps[20];
const char *provProps[20];
char requestQueue_a[256];
int propIndex;
char *positionalParms = "\tQUEUE Guaranteed Message Queue.\n";
printf ( "\nRRGuaranteedReplier.c (Copyright 2013-2024 Solace Corporation. All rights reserved.)\n" );
initSigHandler ( );
common_initCommandOptions(&commandOpts,
( USER_PARAM_MASK |
DEST_PARAM_MASK ),
( HOST_PARAM_MASK |
PASS_PARAM_MASK |
LOG_LEVEL_MASK |
USE_GSS_MASK |
ZIP_LEVEL_MASK));
if ( common_parseCommandOptions ( argc, argv, &commandOpts, positionalParms ) == 0 ) {
exit (1);
}
if (optind < argc) {
if (commandOpts.destinationName[0] != '\0') {
printf("%s does not support topic ('-t, --topic) and queue name (%s) at the same time\n",
argv[0], argv[optind]);
exit(1);
}
strncpy(requestQueue_a, argv[optind], sizeof(requestQueue_a));
}
else {
if (commandOpts.destinationName[0] == '\0') {
printf("%s must specify either a topic ('-t, --topic) or a queue name argument\n",
argv[0]);
exit(1);
}
}
common_handleError ( rc, "solClient_initialize()" );
goto notInitialized;
}
common_printCCSMPversion ( );
&context_p, &contextFuncInfo,
sizeof ( contextFuncInfo ) ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "solClient_context_create()" );
goto cleanup;
}
propIndex = 0;
if ( commandOpts.targetHost[0] != (char) 0 ) {
sessionProps[propIndex++] = commandOpts.targetHost;
}
sessionProps[propIndex++] = ( commandOpts.enableCompression ) ? "9" : "0";
sessionProps[propIndex++] = "3";
sessionProps[propIndex++] = "3";
if ( commandOpts.vpn[0] ) {
sessionProps[propIndex++] = commandOpts.vpn;
}
sessionProps[propIndex++] = commandOpts.username;
sessionProps[propIndex++] = commandOpts.password;
if ( commandOpts.useGSS ) {
}
sessionProps[propIndex] = NULL;
context_p,
&session_p, &sessionFuncInfo,
sizeof ( sessionFuncInfo ) ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "solClient_session_create()" );
goto cleanup;
}
common_handleError ( rc, "solClient_session_connect()" );
goto cleanup;
}
goto sessionConnected;
}
propIndex = 0;
if (commandOpts.destinationName[0] == '\0' ) {
provProps[propIndex++] = requestQueue_a;
}
else {
provProps[propIndex++] = MY_SAMPLE_REQUEST_TE;
}
provProps[propIndex++] = "100";
provProps[propIndex++] = NULL;
session_p,
if ( errorInfo_p != NULL ) {
"solClient_session_endpointProvision() failed subCode (%d:'%s')",
}
goto sessionConnected;
}
endpointProvisioned = TRUE;
propIndex = 0;
if (commandOpts.destinationName[0] == '\0') {
flowProps[propIndex++] = requestQueue_a;
}
else {
flowProps[propIndex++] = MY_SAMPLE_REQUEST_TE;
flowProps[propIndex++] = commandOpts.destinationName;
}
flowProps[propIndex] = NULL;
session_p, &flow_p, &flowFuncInfo,
sizeof ( flowFuncInfo ) ) ) !=
SOLCLIENT_OK ) {
"solClient_session_createFlow() did not return SOLCLIENT_OK " "after session create. rc = %d ", rc );
goto sessionConnected;
}
if (commandOpts.destinationName[0] == '\0') {
printf ( "Serving requests on queue '%s', Ctrl-C to stop.....\n", requestQueue_a );
}
else {
printf ( "Serving requests on topic '%s', Ctrl-C to stop.....\n", commandOpts.destinationName );
}
while ( !gotCtlC ) {
sleepInSec ( 1 );
}
printf ( "Got Ctrl-C, cleaning up\n" );
common_handleError ( rc, "solClient_flow_destroy()" );
}
sessionConnected:
if (endpointProvisioned) {
session_p,
if ( errorInfo_p != NULL ) {
"solClient_session_endpointDeprovision() failed subCode (%d:'%s')",
}
}
}
common_handleError ( rc, "solClient_session_disconnect()" );
}
cleanup:
common_handleError ( rc, "solClient_cleanup()" );
}
goto notInitialized;
notInitialized:
return 0;
}