Using MQSeries with NonStop Tuxedo 6.5.3
mqsgetcl, tmqsgetcl, and mqsgetserv
mqsgetcl and tmqsgetcl use the same source file, however, when the executable is invoked as
tmqsgetcl, it starts a transaction before calling the service. Otherwise, the client is basically
simpcl.c except it calls the service MQSGETTOLOWER. It can also be forced to abort the
transaction it started. If the string returned from the service MQSGETTOLOWER is
"tpabort-mqsgetcl", and the tmqsgetcl client was invoked, then the transaction is aborted and the
message is returned to the MQSeries queue.
mqsgetserv implements the MQSGETTOLOWER service and basically merges amqsget with
simpserv. That is, when the server is first booted it opens the queue listed in its CLOPT. Then
for each service request it uses MQGET to get a message from the queue (if a message is
available), downshifts the string, and returns it to the client. The server uses the NonStop
TUXEDO tpgetlev() to determine if the service request is in a transaction. If it is, then the
service includes the MQGET request in that transaction. If that’s the case, and the string
retrieved is "tpabort-mqsgetserv", then the service calls tpabort() and fails the service.
To test the various paths do the following:
amqsput SYSTEM.DEFAULT.LOCAL.QUEUE QMNAME
>mSg #1
>tpabort-mqsgetserv
>TPABORT-mqsgetcl
>Ctrl-Y
Run mqsgetcl four times. The first three times will retrieve the messages and return
them as all lowercase. The fourth time the client will take more time as the server
waits for a message to be added to the queue and then eventually indicates that the
service has failed.
Do the amqsput again, using the same input, but this time use tmqsgetcl so that a
transaction is started for each request. The first time tmqsgetcl is executed the
same result is obtained. The next time tmqsgetcl is executed the message indicates
the service failed, because the string caused the service to call tpabort(). To remove
the "tpabort-mqsgetserv" message run mqsgetcl (i.e., without the "t"). Then run
tmqsgetcl again. This time the string is returned and displayed but the client calls
tpabort() so the message returns to the queue. Run mqsgetcl to see the message was
still on the queue and to have it successfully removed.