#include "os.h"
#include "common.h"
{
solClient_uint32_t *counter_p = user_p;
( *counter_p )++;
}
{
solClient_uint32_t *counter_p = user_p;
( *counter_p )++;
printf ( "Acknowledging message Id: %lld.\n", msgId );
}
}
int
main ( int argc, char *argv[] )
{
struct commonOptions commandOpts;
solClient_uint32_t msgCounterA = 0;
solClient_uint32_t msgCounterB = 0;
const char *props[20];
int propIndex = 0;
printf ( "\nnoLocalPubSub.c (Copyright 2010-2024 Solace Corporation. All rights reserved.)\n" );
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);
}
common_handleError ( rc, "solClient_initialize()" );
goto notInitialized;
}
common_printCCSMPversion ( );
&context_p, &contextFuncInfo,
sizeof ( contextFuncInfo ) ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "solClient_context_create()" );
goto cleanup;
}
if ( ( rc = common_createAndConnectSession ( context_p,
&sessionA_p,
messageReceiveCallback,
common_eventCallback, (
void *)(&msgCounterA), &commandOpts ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "common_createAndConnectSession()" );
goto cleanup;
}
goto cleanup;
}
propIndex = 0;
if ( commandOpts.targetHost[0] != (char) 0 ) {
props[propIndex++] = commandOpts.targetHost;
}
props[propIndex++] = commandOpts.username;
props[propIndex++] = commandOpts.password;
if ( commandOpts.vpn[0] ) {
props[propIndex++] = commandOpts.vpn;
}
props[propIndex++] = "3";
props[propIndex] = NULL;
context_p,
&sessionB_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;
}
if ( ( rc = common_createQueue ( sessionA_p, COMMON_TESTQ ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "common_createQueue()" );
goto sessionConnected;
}
propIndex = 0;
props[propIndex++] = COMMON_TESTQ;
props[propIndex] = NULL;
sessionA_p, &flow_p, &flowFuncInfo,
sizeof ( flowFuncInfo ) ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "solClient_session_createFlow() did not return SOLCLIENT_OK" );
goto sessionConnected;
}
common_handleError ( rc, "solClient_msg_alloc()" );
goto sessionConnected;
}
common_handleError ( rc, "solClient_msg_setDeliveryMode()" );
goto freeMessage;
}
destination.
dest = COMMON_MY_SAMPLE_TOPIC;
common_handleError ( rc, "solClient_msg_setDestination()" );
goto freeMessage;
}
COMMON_ATTACHMENT_TEXT,
(solClient_uint32_t)(strlen ( COMMON_ATTACHMENT_TEXT ) ) ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "solClient_msg_setBinaryAttachment()" );
goto freeMessage;
}
common_handleError ( rc, "solClient_session_sendMsg()" );
goto freeMessage;
}
sleepInSec ( 1 );
if ( msgCounterA != 0 || msgCounterB != 1 ) {
common_handleError ( rc, "Published direct message seen on session A or not seen on session B" );
goto freeMessage;
}
msgCounterB = 0;
common_handleError ( rc, "solClient_session_sendMsg()" );
goto freeMessage;
}
sleepInSec ( 1 );
if ( msgCounterA != 0 || msgCounterB != 0 ) {
common_handleError ( rc, "Published direct message seen on session A or on session B" );
goto freeMessage;
}
printf ( "\nnoLocalPubSub: Publishing a message that will be rejected by appliance due to No Local Discard\n\nWaiting for Event ... \n\n" );
common_handleError ( rc, "solClient_msg_setDeliveryMode()" );
goto freeMessage;
}
destination.
dest = COMMON_TESTQ;
common_handleError ( rc, "solClient_msg_setDestination()" );
goto freeMessage;
}
common_handleError ( rc, "solClient_session_sendMsg()" );
goto freeMessage;
}
sleepInSec ( 1 );
if ( msgCounterA != 0 || msgCounterB != 0 ) {
common_handleError ( rc, "Published persistent message seen on session A or on session B" );
goto freeMessage;
}
common_handleError ( rc, "solClient_session_sendMsg()" );
goto freeMessage;
}
sleepInSec ( 1 );
if ( msgCounterA != 1 || msgCounterB != 0 ) {
common_handleError ( rc, "Published persistent message not seen on session A or seen on session B" );
goto freeMessage;
}
printf ( "\nTest Passed\n" );
freeMessage:
common_handleError ( rc, "solClient_msg_free()" );
goto sessionConnected;
}
common_handleError ( rc, "solClient_session_topicSubscribe()" );
goto sessionConnected;
}
sessionConnected:
if ( flow_p != NULL ) {
common_handleError ( rc, "solClient_flow_destroy()" );
}
}
if ( ( rc = common_deleteQueue ( sessionA_p, COMMON_TESTQ ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "common_deleteQueue()" );
}
common_handleError ( rc, "solClient_session_disconnect()" );
}
common_handleError ( rc, "solClient_session_disconnect()" );
}
cleanup:
common_handleError ( rc, "solClient_cleanup()" );
}
notInitialized:
return 0;
}