NonStop JMS C++ API Programmer's Guide

NSJMS C++ API Sample Client Applications
NonStop Server for Java Message Service C++ API Programmer’s Guide526459-002
6-4
SimpleReceiver.cpp
SimpleReceiver.cpp
This SimpleReceiver.cpp sample client application waits for a specified number of
messages from a specific queue and then exits.
if (strcmp(argv[optind],"-help") == 0)
{
usage(basename(argv[0]));
return 1;
}
else if (strcmp(argv[optind],"-queue") == 0)
{
destName=strdup(argv[++optind]);
qGiven=TRUE;
}
else if (strcmp(argv[optind],"-persistent") == 0)
{
persistent = true;
}
else if (strcmp(argv[optind],"-count") == 0)
{
msgCount = atol(argv[++optind]);
}
else if (strcmp(argv[optind],"-") == 0)
{
usage(basename(argv[0]));
return 1;
}
}
if (qGiven == FALSE) {
usage(basename(argv[0]));
return 1;
}
if (persistent) {
deliveryMode = DELIVERYMODE_PERSISTENT;
}
if (!send_message()) {
cout<< "Message Send successful"<< endl;
return 0;
}
else {
cout<<"Message Send Failed" << endl;
return 1;
}
return 0;
}
Example 6-1. SimpleSender.cpp Sample Client Application (page 3 of 3)