NonStop JMS C++ API Programmer's Guide
NSJMS C++ API Sample Client Applications
NonStop Server for Java Message Service C++ API Programmer’s Guide—526459-002
6-11
SimpleConsumer.cpp
SimpleConsumer.cpp
This SimpleConsumer.cpp sample client application creates a Session and then
creates a Consumer or Durable Subscriber. The application expects a Topic Name,
Message Count, and optionally a Durable Subscriber name and Client ID. If a Topic
Name is not specified, an exception is raised.
if (strcmp(argv[optind],"-help") == 0)
{
usage(basename(argv[0]));
return 1;
}
else if (strcmp(argv[optind],"-topic") == 0)
{
destName=strdup(argv[++optind]);
tGiven=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 (tGiven == FALSE) {
usage(basename(argv[0]));
return 1;
}
if (persistent) {
deliveryMode = DELIVERYMODE_PERSISTENT;
}
if (!send_message()) {
cout<<"Message Sending successful" << endl;
return 0;
}
else {
cout<<"Message Send Failed" << endl;
return 1;
}
return 0;
}
Example 6-3. SimplePublisher.cpp Sample Client Application (page 3 of 3)