Need Help in orderbook-distribution-ext-users using Solace C API

SnapShot_Recovery(int Queue)
{

int argc=9;
char *argv[9];

argv[0]="./SnapShot_Rec";
argv[1]="-c";
argv[2]="tcp:172.28.124.40:10986";
argv[3]="-u";
argv[4]="member_fo_prod@od_fo_prod";
argv[5]="-q";

if(Queue == 10){
argv[6]="lvq.nse.fo.od.10.orderbook";
}
if(Queue == 11){
argv[6]="lvq.nse.fo.od.11.orderbook";
}
if(Queue == 12){
argv[6]="lvq.nse.fo.od.12.orderbook";
}
if(Queue == 13){
argv[6]="lvq.nse.fo.od.13.orderbook";
}
if(Queue == 14){
argv[6]="lvq.nse.fo.od.14.orderbook";
}
if(Queue == 15){
argv[6]="lvq.nse.fo.od.15.orderbook";
}
if(Queue == 16){
argv[6]="lvq.nse.fo.od.16.orderbook";
}

argv[7]="-p";
argv[8]="YoEvx#9675";


struct commonOptions commandOpts;
solClient_returnCode_t rc = SOLCLIENT_OK;

/* Context */
solClient_opaqueContext_pt context_p;
solClient_context_createFuncInfo_t contextFuncInfo = SOLCLIENT_CONTEXT_CREATEFUNC_INITIALIZER;

/* Session */
solClient_opaqueSession_pt session_p;
solClient_session_createFuncInfo_t sessionFuncInfo = SOLCLIENT_SESSION_CREATEFUNC_INITIALIZER;

/* Flow */
solClient_opaqueFlow_pt flow_p;
solClient_flow_createFuncInfo_t flowFuncInfo = SOLCLIENT_FLOW_CREATEFUNC_INITIALIZER;

/*
Flow Properties
We only want the browser to receive
a single message
*/
solClient_uint32_t browseWindow = 1;

printf("\nQueueBrowser.c (Copyright 2007-2020 Solace Corporation. All rights reserved.)\n\n");

/*************************************************************************
* Parse command options
*************************************************************************/
common_initCommandOptions(&commandOpts,
( USER_PARAM_MASK |
HOST_PARAM_MASK |
PASS_PARAM_MASK |
QUEUE_PARAM_MASK ), /* required parameters */
(
LOG_LEVEL_MASK )); /* optional parameters */
if (common_parseCommandOptions(argc, argv, &commandOpts, NULL) == 0) {
exit(1);
}

/*************************************************************************
* Optional - uncomment the below lines to redirect all API logs to a file
* 'solace.log'
*************************************************************************/

/*
const char solaceLogFileStr[] = "solace.log";

if ((rc = solClient_log_setFile(solaceLogFileStr)) != SOLCLIENT_OK) {
common_handleError(rc, "solClient_log_setFile");
goto notInitialized;
}
*/

/*************************************************************************
* Initialize the API and setup logging level
*************************************************************************/

/* solClient needs to be initialized before any other API calls. */
if ((rc = solClient_initialize(SOLCLIENT_LOG_DEFAULT_FILTER,
NULL)) != SOLCLIENT_OK) {
common_handleError(rc, "solClient_initialize()");
goto notInitialized;
}

common_printCCSMPversion();

/*
* Standard logging levels can be set independently for the API and the
* application. In this case, the ALL category is used to set the log level for
* both at the same time.
*/
solClient_log_setFilterLevel(SOLCLIENT_LOG_CATEGORY_ALL,
commandOpts.logLevel);

/*************************************************************************
* Create a Context
*
* Contexts are used for organizing communication between an application and
* a Solace PubSub+ event broker.
*
* A Context encapsulates threads that drive network I/O and
* message delivery notification for the Sessions and Session components
* associated with that Context.
*************************************************************************/

/*
* Create a Context, and specify that the Context thread be created
* automatically instead of having the application create its own
* Context thread.
*/
solClient_log(SOLCLIENT_LOG_INFO, "Creating solClient context");

if ((rc = solClient_context_create(SOLCLIENT_CONTEXT_PROPS_DEFAULT_WITH_CREATE_THREAD,
&context_p,
&contextFuncInfo,
sizeof(contextFuncInfo))) != SOLCLIENT_OK) {
common_handleError(rc, "solClient_context_create()");
goto cleanup;
}

/*************************************************************************
* Create and connect a Session
*
* A Session creates a single TCP client connection to a Solace event broker
* for sending and receiving messages.
*************************************************************************/

solClient_log(SOLCLIENT_LOG_INFO, "Creating solClient session");

if ((rc = common_createAndConnectSession(context_p,
&session_p,
common_messageReceivePrintMsgCallback,
common_eventCallback,
NULL,
&commandOpts)) != SOLCLIENT_OK) {
common_handleError(rc, "common_createAndConnectSession()");
goto cleanup;
}

if (!solClient_session_isCapable(session_p, SOLCLIENT_SESSION_CAPABILITY_BROWSER)) {
solClient_log(SOLCLIENT_LOG_ERROR, "Stopping as Solace appliance doesn't have guaranteed delivery enabled");
goto sessionConnected;
}

/*************************************************************************
* Create a flow to browse messages on the queue
*
* A subscriber Flow allows applications to receive Guaranteed messages
* from an endpoint, such as a Queue.
***************************************************/

browserFlow (session_p, commandOpts.queueName, browseWindow);

printf ( "Endpoint Browsing completed. Exiting.\n" );

/*************************************************************************
* Cleanup
*************************************************************************/

sessionConnected:
/* Disconnect the Session. */
solClient_log(SOLCLIENT_LOG_INFO, "Disconnecting solClient session");
if ( ( rc = solClient_session_disconnect ( session_p ) ) != SOLCLIENT_OK ) {
common_handleError ( rc, "solClient_session_disconnect()" );
}

cleanup:
/* Cleanup solClient. */
if ((rc = solClient_cleanup()) != SOLCLIENT_OK) {
common_handleError(rc, "solClient_cleanup()");
}

notInitialized:
return 0;

}


/* while calling SnapShot_Recovery(int Queue) function its working fine for first time , but when i call again its gives error . my Question is how to connect multiple queue */
Tagged:

Comments

  • maheshkumar
    maheshkumar Member Posts: 3
    how to connect multiple queue ?
  • maheshkumar
    maheshkumar Member Posts: 3

    done multiple queue . all working fine :)

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 535 admin

    Great you were able to fix the issue @maheshkumar ! Do you mind sharing your solution here incase someone come across the same issue? Thanks!

  • Naruto
    Naruto Member Posts: 13 ✭✭
    edited May 8 #5

    I am having the same issue as it's not working for Multiple Queues. Can you please post the solution here how you made that work @maheshkumar @Abhishek Sharma that would be really helpful.

  • Naruto
    Naruto Member Posts: 13 ✭✭

    I think I got the solution as we need to update the optind = 1 everytime we sent new argv array for traversing

This Month's Leaders