#include "os.h"
#include "common.h"
typedef struct publisherInfoStruct
{
int acknowledgementRx_m;
int rejectedMsgRx_m;
} publisherInfoStruct_t, *publisherInfoStruct_pt;
void
{
publisherInfoStruct_pt pubInfo_p = ( publisherInfoStruct_pt ) user_p;
"replication_eventCallback() called - %s\n",
pubInfo_p->acknowledgementRx_m ++;
break;
printf ( "replication_eventCallback() called - %s; subCode %s, responseCode %d, reason %s\n",
pubInfo_p->rejectedMsgRx_m ++;
break;
"replication_eventCallback() called - %s\n",
break;
printf ( "replication_eventCallback() called - %s; info_p %s\n",
break;
printf ( "replication_eventCallback() called - %s; subCode %s, responseCode %d, reason %s\n",
break;
default:
printf ( "replication_eventCallback() called - %s. Unrecognized or deprecated event.\n",
break;
}
}
int
main ( int argc, char *argv[] )
{
struct commonOptions commandOpts;
int loop;
char binMsg[1024];
publisherInfoStruct_t pubInfo;
printf ( "\nreplication.c (Copyright 2010-2024 Solace Corporation. All rights reserved.)\n" );
memset (&pubInfo, 0, sizeof(pubInfo));
common_initCommandOptions(&commandOpts,
( USER_PARAM_MASK ),
( HOST_PARAM_MASK |
PASS_PARAM_MASK |
NUM_MSGS_MASK |
LOG_LEVEL_MASK |
USE_GSS_MASK |
ZIP_LEVEL_MASK));
if ( common_parseCommandOptions ( argc, argv, &commandOpts, NULL ) == 0 ) {
exit(1);
}
common_handleError ( rc, "solClient_initialize()" );
goto notInitialized;
}
common_printCCSMPversion ( );
initSigHandler ( );
&context_p, &contextFuncInfo,
sizeof ( contextFuncInfo ) ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "solClient_context_create()" );
goto cleanup;
}
if ( ( rc = common_createAndConnectSession ( context_p,
&session_p,
common_messageReceivePrintMsgCallback,
replication_eventCallback, &pubInfo, &commandOpts ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "common_createAndConnectSession()" );
goto cleanup;
}
for ( loop = 0; ( loop < commandOpts.numMsgsToSend ) && !gotCtlC; loop++ ) {
common_handleError ( rc, "solClient_msg_alloc()" );
goto sessionConnected;
}
common_handleError ( rc, "solClient_msg_setDeliveryMode()" );
goto sessionConnected;
}
memset ( ( void * ) binMsg, 0xab, sizeof ( binMsg ) );
common_handleError ( rc, "solClient_msg_setBinaryAttachmentPtr()" );
goto sessionConnected;
}
destination.
dest = COMMON_MY_SAMPLE_TOPIC;
common_handleError ( rc, "solClient_msg_setDestination()" );
goto sessionConnected;
}
common_handleError ( rc, "solClient_session_send" );
break;
}
common_handleError ( rc, "solClient_msg_free" );
break;
}
printf ("Sent %d\n", loop+1);
sleepInSec ( 1 );
}
if ( gotCtlC ) {
printf ( "Got Ctrl-C, cleaning up\n" );
}
sleepInSec ( 1 );
sessionConnected:
common_handleError ( rc, "solClient_session_disconnect()" );
}
if ( pubInfo.rejectedMsgRx_m != 0 ) {
printf ( "Test saw '%d' SOLCLIENT_SESSION_EVENT_REJECTED_MSG_ERROR. None expected\n",
pubInfo.rejectedMsgRx_m );
}
if (( pubInfo.rejectedMsgRx_m + pubInfo.acknowledgementRx_m ) != loop ) {
printf ( "Test saw '%d' responses (acknowlegement+rejected). Expected '%d'\n",
pubInfo.rejectedMsgRx_m+pubInfo.acknowledgementRx_m, loop );
}
cleanup:
common_handleError ( rc, "solClient_cleanup()" );
}
goto notInitialized;
notInitialized:
return 0;
}