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-9
SimplePublisher.cpp
Example 6-3. SimplePublisher.cpp Sample Client Application (page 1 of 3)
/**
 *
 * Copyright (c) Hewlett-Packard Company, 2002-2003
 * Protected as an unpublished work.
 * All rights reserved.
 *
 * The computer program listings, specifications, and documentation herein
 * are the property of Hewlett-Packard Company or a third party supplier and
 * shall not be reproduced, copied, disclosed, or used in whole or in part
 * for any reason without the prior express written permission of
 * Hewlett-Packard Company.
 */
#include <unistd.h>
#include <libgen.h>
#include <strstream.h> 
#include <cextdecs.h(JULIANTIMESTAMP,BEGINTRANSACTION,ENDTRANSACTION)>
#include "nsjmsc.h"
const static int PRIORITY = 1;
bool tGiven = FALSE;
bool persistent = false;
int deliveryMode = DELIVERYMODE_NONPERSISTENT;
unsigned long msgCount = 10;
char *destName;
Session * pSes;
Producer* pProducer;
TextMessage* pMsg;
/**
* Print out information on running this sevice
*/
void usage(char * appName)
{
 cerr<<" Usage: "<<basename(appName)<<" [options]"<<endl;
 cerr<<" -topic <string> Topic destination name"<<endl;
 cerr<<" -count <number> Number of messages to send (10)"<<endl;
 cerr<<" -persistent Specifies persistent delivery mode"<<endl;
 cerr<<" -help This Message"<<endl;
 return;
}
/**
* Sends a message to the destination.
*/
int send_message()
{
 try {
 // Use an environment variable to dynamically assign a directory
 char *propFile = getenv(“NSJMS_HOME”);
 strcat(propFile, “/nsjms.properties”);
 pSes = new Session(propFile);
 /* Create a new session using a properties file in the current
 working directory*/
 /***********************************************
 pSes = new Session("nsjms.properties");
 ***********************************************/










