NonStop JMS C++ API Programmer's Guide

Using the NSJMS C++ APIs
NonStop Server for Java Message Service C++ API Programmer’s Guide526459-002
5-7
Sending a Message
A client can send a message using the default delivery mode, priority, and time-to-live
for messages sent by a message producer or, a client can specify a delivery mode,
priority, and time-to-live per message. The default values are:
deliveryMode = DELIVERYMODE_PERSISTENT,
priority = DEFAULT_JMSPRIORITY,
timeToLive = DEFAULT_JMSEXPIRATION
Message Delivery Mode
NSJMS C++ APIs allows a message’s delivery mode to be set using the
deliveryMode argument of the Producer::send() method, and retrieved using
the Message::getJMSDeliveryMode() method of the Message class. Neither
NSJMS nor the NSJMS C++ APIs optimize for NON_PERSISTENT messages (deliver
at most once). All messages are treated as having PERSISTENT delivery mode
(deliver once and only once).
Message Priority
NSJMS C++ APIs allows a message’s priority to be set using the priority argument
of the Producer::send() method, and retrieved using the
Message::getJMSPriority() method of the Message class. Although the NSJMS
C++ APIs allow a message’s priority to be set and retrieved, this priority does not affect
message-delivery order.
Message Expiration Value (timeToLive)
NSJMS C++ APIs allow a message’s expiration value to be set using the timeToLive
argument of the Producer::send() method, and retrieved using the
Message::getJMSExpiration() method of the Message class.
A client specifies a time-to-live value in milliseconds for each message it sends. For
example, if a message is to expire one day after it was sent, you would assign the
following value to the timeToLive argument of the Producer::send() method:
long long oneDay = 1000*60*60*24;
where 1000 is the number of milliseconds in one second, 60 is the number of seconds
in one minute, 60 is the number of minutes in one hour, and 24 is the number of hours
in one day.
When a message is sent, the expiration time is left unassigned. After completion of the
send() method, the message's JMSExpiration header field contains the expiration
time of the message.
The message's expiration time is calculated, in milliseconds, to be the sum of the time-
to-live value and the Greenwich mean time (GMT) when the message is sent (this is
the time the client sends the message and not the time the send transaction is
committed). This unit of time is consistent with the Java
System.currentTimeMillis() method which returns the difference, measured in
milliseconds, between the current time and midnight, January 1, 1970 UTC. Internally,