#include "os.h"
#include "common.h"
struct commonOptions commandOpts;
static int solMsgRxCount[4];
{
solMsgRxCount[0]++;
}
{
solMsgRxCount[1]++;
}
{
solMsgRxCount[2]++;
}
{
solMsgRxCount[3]++;
}
int
main ( int argc, char *argv[] )
{
int propIndex;
const char *sessionProps[40];
printf ( "\ntopicDispatch.c (Copyright 2007-2024 Solace Corporation. All rights reserved.)\n" );
common_handleError ( rc, "solClient_initialize()" );
goto notInitialized;
}
common_printCCSMPversion ( );
common_initCommandOptions(&commandOpts,
( USER_PARAM_MASK ),
( HOST_PARAM_MASK |
PASS_PARAM_MASK |
LOG_LEVEL_MASK |
USE_GSS_MASK |
ZIP_LEVEL_MASK));
if ( common_parseCommandOptions ( argc, argv, &commandOpts, NULL ) == 0 ) {
exit(1);
}
initSigHandler ( );
&context_p, &contextFuncInfo,
sizeof ( contextFuncInfo ) ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "solClient_context_create()" );
goto cleanup;
}
propIndex = 0;
sessionProps[propIndex++] = commandOpts.username;
sessionProps[propIndex++] = commandOpts.password;
if ( commandOpts.targetHost[0] != (char) 0 ) {
sessionProps[propIndex++] = commandOpts.targetHost;
}
sessionProps[propIndex++] = "3";
sessionProps[propIndex++] = "3";
sessionProps[propIndex++] = ( commandOpts.enableCompression ) ? "9" : "0";
if ( commandOpts.vpn[0] ) {
sessionProps[propIndex++] = commandOpts.vpn;
}
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;
}
common_handleError ( rc, "solClient_session_topicSubscribe()" );
goto sessionConnected;
}
dispatchInfo.
callback_p = solDispatchMsgReceiveCallback1;
common_handleError ( rc, "solClient_session_topicSubscribeWithDispatch()" );
goto sessionConnected;
}
dispatchInfo.
callback_p = solDispatchMsgReceiveCallback2;
common_handleError ( rc, "solClient_session_topicSubscribeWithDispatch()" );
goto sessionConnected;
}
dispatchInfo.
callback_p = solDispatchMsgReceiveCallback3;
common_handleError ( rc, "solClient_session_topicSubscribeWithDispatch()" );
goto sessionConnected;
}
printf ( "Publishing messages\n\n" );
sleepInSec ( 1 );
if ( solMsgRxCount[0] == 1 ) {
printf ( "Received exactly one message on session callback as expected\n" );
} else {
}
if ( solMsgRxCount[1] == 1 ) {
printf ( "Received exactly one message on dispatch callback for topic 'a/b' as expected\n" );
} else {
solMsgRxCount[1] );
}
if ( solMsgRxCount[2] == 2 ) {
printf ( "Received exactly two messages on dispatch callback for topic 'c/>' as expected\n" );
} else {
solMsgRxCount[2] );
}
if ( solMsgRxCount[3] == 1 ) {
printf ( "Received exactly one message on dispatch callback for topic 'c/d' as expected\n" );
} else {
solMsgRxCount[3] );
}
sessionConnected:
common_handleError ( rc, "solClient_session_disconnect()" );
}
cleanup:
common_handleError ( rc, "solClient_cleanup()" );
}
notInitialized:
return 0;
}