#include "os.h"
#include "common.h"
void
{
printf ( "cache_EventCallback() called: \n"
"\tevent: %s\n"
"\ttopic: %s\n"
"\tresponseCode: (%d) %s\n"
"\tsubCode: (%d) %s\n"
"\tcacheRequestId: %llu\n\n",
switch ( eventInfo_p->
rc ) {
break;
"received event=SOLCACHE_EVENT_REQUEST_COMPLETED_NOTICE,"
"rc=SOLCLIENT_INCOMPLETE, subCode=%s",
break;
"received event=SOLCACHE_EVENT_REQUEST_COMPLETED_NOTICE,"
"rc=SOLCLIENT_INCOMPLETE, subCode=%s",
break;
"received event=SOLCACHE_EVENT_REQUEST_COMPLETED_NOTICE,"
"rc=SOLCLIENT_INCOMPLETE, subCode=%s",
break;
default:
"received event=SOLCACHE_EVENT_REQUEST_COMPLETED_NOTICE,"
"rc=SOLCLIENT_INCOMPLETE, with unusual subcode subCode=%d", eventInfo_p->
subCode );
break;
}
break;
"received event=SOLCACHE_EVENT_REQUEST_COMPLETED_NOTICE,rc=SOLCLIENT_FAIL" )
break;
default:
"received event=SOLCACHE_EVENT_REQUEST_COMPLETED_NOTICE, "
"with unusual rc=%d", eventInfo_p->
rc );
break;
}
break;
default:
break;
}
}
int
main ( int argc, char *argv[] )
{
struct commonOptions commandOpts;
const char *cacheProps[20];
int propIndex = 0;
printf ( "\nasyncCacheRequest.c (Copyright 2009-2024 Solace Corporation. All rights reserved.)\n" );
initSigHandler ( );
common_initCommandOptions(&commandOpts,
( USER_PARAM_MASK |
CACHE_PARAM_MASK ),
( HOST_PARAM_MASK |
DEST_PARAM_MASK |
PASS_PARAM_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;
}
if ( ( rc = common_createAndConnectSession ( context_p,
&session_p,
common_messageReceivePrintMsgCallback,
common_eventCallback, NULL, &commandOpts ) ) !=
SOLCLIENT_OK ) {
common_handleError ( rc, "common_createAndConnectSession()" );
goto cleanup;
}
common_handleError ( rc, "common_publishMessage()" );
goto sessionConnected;
}
propIndex = 0;
cacheProps[propIndex++] = commandOpts.cacheName;
cacheProps[propIndex] = NULL;
common_handleError ( rc, "solClient_session_createCacheSession" );
goto sessionConnected;
}
printf ( "Sending cache request.\n\n" );
commandOpts.destinationName,
cacheRequestId,
cache_eventCallback,
common_handleError ( rc, "solClient_cacheSession_sendCacheRequest()" );
goto cleanupCache;
}
printf ( "Cache request sent.\n\n" );
printf ( "Waiting for cache response. Sleeping for 11 seconds.\n\n" );
sleepInSec ( 11 );
printf ( "Exiting.\n" );
cleanupCache:
common_handleError ( rc, "solClient_cacheSession_destroy()" );
}
sessionConnected:
common_handleError ( rc, "solClient_session_disconnect()" );
}
cleanup:
common_handleError ( rc, "solClient_cleanup()" );
}
notInitialized:
return 0;
}