#include "os.h"
#include "common.h"
#ifndef LLONG_MAX
#ifndef INT64_MAX
#define INT64_MAX (9223372036854775807LL)
#endif
#define LLONG_MAX INT64_MAX
#endif
solClient_int64_t minTransitTime_s = LLONG_MAX, maxTransitTime_s = 0, totalTransitTime_s = 0;
{
printf ( "Received message:\n" );
common_handleError ( rc, "solClient_msg_dump()" );
}
common_handleError ( rc, "solClient_msg_getSenderTimestamp()" );
}
common_handleError ( rc, "solClient_msg_getRcvTimestamp()" );
}
transitTime = rcvTimestamp - sendTimestamp;
if ( transitTime < minTransitTime_s ) minTransitTime_s = transitTime;
if ( transitTime > maxTransitTime_s ) maxTransitTime_s = transitTime;
totalTransitTime_s += transitTime;
printf ( "\n" );
}
int
main ( int argc, char *argv[] )
{
struct commonOptions commandOpts;
const char *sessionProps[50];
int propIndex = 0;
int msgsSent = 0;
printf ( "\ndirectPubSub.c (Copyright 2009-2024 Solace Corporation. All rights reserved.)\n" );
common_initCommandOptions(&commandOpts,
( USER_PARAM_MASK ),
( HOST_PARAM_MASK |
DEST_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);
}
if ( commandOpts.destinationName[0] == ( char ) 0 ) {
strncpy (commandOpts.destinationName, COMMON_MY_SAMPLE_TOPIC, sizeof(commandOpts.destinationName));
}
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.username;
sessionProps[propIndex++] = commandOpts.password;
if ( commandOpts.vpn[0] ) {
sessionProps[propIndex++] = commandOpts.vpn;
}
sessionProps[propIndex++] = "3";
sessionProps[propIndex++] = ( commandOpts.enableCompression ) ? "9" : "0";
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;
}
for ( msgsSent = 0; msgsSent < commandOpts.numMsgsToSend; ++msgsSent ) {
common_handleError ( rc, "solClient_msg_alloc()" );
goto sessionConnected;
}
common_handleError ( rc, "solClient_msg_setDeliveryMode()" );
goto freeMessage;
}
destination.
dest = commandOpts.destinationName;
common_handleError ( rc, "solClient_msg_setDestination()" );
goto freeMessage;
}
COMMON_ATTACHMENT_TEXT,
( solClient_uint32_t ) strlen ( COMMON_ATTACHMENT_TEXT ) ) ) !=
common_handleError ( rc, "solClient_msg_setBinaryAttachment()" );
goto freeMessage;
}
common_handleError ( rc, "solClient_session_sendMsg()" );
goto freeMessage;
}
freeMessage:
common_handleError ( rc, "solClient_msg_free()" );
goto sessionConnected;
}
sleepInSec ( 1 );
}
common_handleError ( rc, "solClient_session_topicSubscribe()" );
goto sessionConnected;
}
printf ("Summary:\n");
printf (" Maximum Transit Time = %lld\n", maxTransitTime_s);
printf (" Minimum Transit Time = %lld\n", minTransitTime_s);
printf (" Average Transit Time = %lld\n", totalTransitTime_s / commandOpts.numMsgsToSend);
sessionConnected:
common_handleError ( rc, "solClient_session_disconnect()" );
}
cleanup:
common_handleError ( rc, "solClient_cleanup()" );
}
notInitialized:
return 0;
}