#include "os.h"
#include "common.h"
int
main ( int argc, char *argv[] )
{
struct commonOptions commandOpts;
const char *flowProps[20];
int propIndex;
char binMsg[] = COMMON_ATTACHMENT_TEXT;
char *topic_p;
int publishCount = 0;
printf ( "\nsimpleFlowToTopic.c (Copyright 2007-2024 Solace Corporation. All rights reserved.)\n" );
initSigHandler ( );
common_initCommandOptions(&commandOpts,
( USER_PARAM_MASK ),
( HOST_PARAM_MASK |
PASS_PARAM_MASK |
DURABLE_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,
&session_p,
common_messageReceivePrintMsgCallback,
common_eventCallback, NULL, &commandOpts ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "common_createAndConnectSession()" );
goto cleanup;
}
propIndex = 0;
if ( commandOpts.usingDurable ) {
flowProps[propIndex++] = COMMON_TESTDTE;
topic_p = COMMON_MY_SAMPLE_TOPIC;
} else {
common_handleError ( rc, "solClient_session_createTemporaryTopicName()" );
goto sessionConnected;
}
topic_p = tempTopic;
}
flowProps[propIndex++] = topic_p;
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.usingDurable ) {
printf ( "Publishing 10 messages to durable Topic Endpoint %s, Ctrl-C to stop.....\n", COMMON_TESTDTE );
} else {
printf ( "Publishing 10 messages to a non-durable Topic Endpoint, Ctrl-C to stop.....\n" );
}
publishCount = 0;
while ( !gotCtlC && publishCount < 10 ) {
common_handleError ( rc, "solClient_msg_alloc()" );
goto cleanupFlow;
}
common_handleError ( rc, "solClient_msg_setDeliveryMode()" );
goto cleanupFlow;
}
common_handleError ( rc, "solClient_msg_setBinaryAttachmentPtr()" );
goto cleanupFlow;
}
destination.
dest = topic_p;
common_handleError ( rc, "solClient_msg_setDestination()" );
goto cleanupFlow;
}
common_handleError ( rc, "solClient_session_send" );
goto cleanupFlow;
}
common_handleError ( rc, "solClient_msg_free()" );
goto cleanupFlow;
}
publishCount++;
sleepInSec ( 1 );
}
if ( gotCtlC ) {
printf ( "Got Ctrl-C, cleaning up\n" );
}
cleanupFlow:
common_handleError ( rc, "solClient_flow_destroy()" );
}
if ( commandOpts.usingDurable ) {
printf ( "About to unsubscribe from durable Topic Endpoint %s\n", COMMON_TESTDTE );
common_handleError ( rc, "solClient_session_dteUnsubscribe()" );
}
sleepInSec ( 1 );
}
sessionConnected:
common_handleError ( rc, "solClient_session_disconnect()" );
}
cleanup:
common_handleError ( rc, "solClient_cleanup()" );
}
notInitialized:
return 0;
}