Creating simple put and get messages within a TransactionScope
Product sample C# applications are available within IBM MQ . These simple applications demonstrate putting and getting messages within a TransactionScope. At the end of the task, you will be able to put and get messages from a queue or topic.
Before you begin
MSDTC service must be running and enabled for XA Transactions.
The example is a simple application, SimpleXAPut and SimpleXAGet. The programs SimpleXAPut and SimpleXAGet are C# applications available within IBM MQ. SimpleXAPut demonstrates using MQPUT, under Distributed Transactions using SystemTransactions namespace. SimpleXAGet demonstrates using MQGET, under Distributed Transactions using SystemTransactions namespace.
SimpleXAPut is located in WebSphere MQ\tools\dotnet\samples\cs\base
Procedure
The applications can be run with the command-line parameters from tools\dotnet\samples\cs\base\binSimpleXAPut.exe -d destinationURI [-h host -p port -l channel -tx transaction -tm mode -n numberOfMsgs]
SimpleXAGet.exe -d destinationURI [-h host -p port -l channel -tx transaction -tm mode -n numberOfMsgs]
where the parameters are:
-destinationURIThis can be queue or topic. For a queue, specify as queue://queueName and for a topic specify as topic://topicName.
-hostThis can be a host name such as localhost or an IP address.
-portThe port on which the queue manager is running.
-channelThe connection channel being used. The default is SYSTEM.DEF.SVRCONN
-transactionThe transaction result, for example commit or rollback.
-modeThe transport mode, for example managed or unmanaged.
-numberOfMsgsThe number of messages. The default is 1.
Example
SimpleXAPut -d topic://T01 -h localhost -p 2345 -tx rollback -tm unmanaged
SimpleXAGet -d queue://Q01 -h localhost -p 2345 -tx rollback -tm unmanaged