#include "os.h"
#include "common.h"
static int msgCount_s = 0;
static long long firstMsgRecvTime_s = 0;
{
if ( msgCount_s == 0 ) {
firstMsgRecvTime_s = getTimeInUs ( );
}
msgCount_s++;
}
static void
{
}
{
if ( msgCount_s == 0 ) {
firstMsgRecvTime_s = getTimeInUs ( );
}
}
msgCount_s++;
}
int
main ( int argc, char *argv[] )
{
struct commonOptions commandOpts;
const char *sessionProps[50];
int propIndex;
const char *flowProps[20];
const char *provProps[20];
int provIndex;
long long lastMsgRecvTime;
long long elapsedTime;
int endpointCreated = 0;
enum flowMode subscribeMode;
char positionalParms[] = "\tmode Subscribe Mode (te, queue, sub - default queue).\n";
msgCount_s = 0;
printf ( "\nperfADSub.c (Copyright 2007-2024 Solace Corporation. All rights reserved.)\n" );
common_initCommandOptions(&commandOpts,
( USER_PARAM_MASK |
DEST_PARAM_MASK ),
( HOST_PARAM_MASK |
PASS_PARAM_MASK |
DURABLE_MASK |
NUM_MSGS_MASK |
WINDOW_SIZE_MASK |
LOG_LEVEL_MASK |
USE_GSS_MASK |
ZIP_LEVEL_MASK));
if ( common_parseCommandOptions ( argc, argv, &commandOpts, positionalParms ) == 0 ) {
exit(1);
}
if (optind < argc ) {
if ( strcmp ( "te", argv[optind] ) == 0 ) {
subscribeMode = TE;
} else if ( strcmp ( "queue", argv[optind] ) == 0 ) {
subscribeMode = QUEUE;
} else if ( strcmp ( "sub", argv[optind] ) == 0 ) {
subscribeMode = SUBSCRIBER;
} else {
printf ( "Invalid mode parameter '%s': must be one of 'te', 'queue', 'sub'\n", argv[optind] );
exit(1);
}
} else {
subscribeMode = QUEUE;
}
initSigHandler ( );
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;
sessionProps[propIndex++] = commandOpts.username;
sessionProps[propIndex++] = commandOpts.password;
if ( commandOpts.targetHost[0] != (char) 0 ) {
sessionProps[propIndex++] = commandOpts.targetHost;
}
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 ) ) )
common_handleError ( rc, "solClient_session_create()" );
goto cleanup;
}
common_handleError ( rc, "solClient_session_connect()" );
goto cleanup;
}
propIndex = 0;
provIndex = 0;
if ( commandOpts.gdWindow != 0 ) {
char gdWindowStr[32];
snprintf ( gdWindowStr, sizeof ( gdWindowStr ), "%d", commandOpts.gdWindow );
flowProps[propIndex++] = gdWindowStr;
}
if ( subscribeMode == TE ) {
if ( commandOpts.usingDurable ) {
flowProps[propIndex++] = COMMON_TESTDTE;
provProps[provIndex++] = COMMON_TESTDTE;
} else {
}
flowProps[propIndex++] = commandOpts.destinationName;
} else if ( subscribeMode == QUEUE ) {
flowProps[propIndex++] = commandOpts.destinationName;
provProps[provIndex++] = commandOpts.destinationName;
} else if ( subscribeMode == SUBSCRIBER ) {
}
flowProps[propIndex++] = NULL;
if ( provIndex > 0 ) {
provProps[provIndex++] = "100";
provProps[provIndex++] = NULL;
session_p,
if ( errorInfo_p != NULL ) {
"solClient_session_endpointProvision() failed subCode (%d:'%s')",
} else {
"solClient_session_endpointProvision() failed subCode (%d:'%s')",
}
}
} else {
endpointCreated = 1;
}
}
session_p,
common_handleError ( rc, "solClient_session_createFlow() did not return SOLCLIENT_IN_PROGRESS after session create." );
goto sessionConnected;
}
if ( subscribeMode == SUBSCRIBER ) {
common_handleError ( rc, "solClient_session_topicSubscribe()" );
goto sessionConnected;
}
}
printf ( "Waiting for messages....." );
fflush ( stdout );
while ( ( msgCount_s < commandOpts.numMsgsToSend ) && !gotCtlC ) {
sleepInUs ( 100 );
}
lastMsgRecvTime = getTimeInUs ( );
elapsedTime = lastMsgRecvTime - firstMsgRecvTime_s;
printf ( "Recv %d msgs in %lld usec, rate of %Lf msgs/sec\n",
msgCount_s, elapsedTime, ( long double ) msgCount_s / ( ( long double ) elapsedTime / ( long double ) 1000000.0 ) );
sessionConnected:
if ( flow_p != NULL ) {
common_handleError ( rc, "solClient_flow_destroy()" );
}
}
if ( endpointCreated ) {
session_p,
if ( errorInfo_p != NULL ) {
"solClient_session_endpointDeprovision() failed subCode (%d:'%s')",
}
}
}
common_handleError ( rc, "solClient_session_disconnect()" );
}
cleanup:
common_handleError ( rc, "solClient_cleanup()" );
}
goto notInitialized;
notInitialized:
return 0;
}