java websphere MQ

前端 未结 3 895
逝去的感伤
逝去的感伤 2021-02-06 13:15

My aim is to put n number of messages in a for loop to a WebSphere MQ queue using WebSphere MQ java programming.

My java program will run as a standalone program.

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 13:32

    If you have access to a transaction manager and more importantly an XATransaction wired up to your MQ access, you can start a transaction at the beginning of your message processing put all the messages on the queue then commit the transaction. Using the XATransactions it will not put any messages until the transaction commits. If you don't have access to that, you can do a little more plumbing by placing your messages in a local data object, wrap your code in a try/catch if no exceptions iterate through the local data object sending the messages. The issue with the later approach is that it will commit all your other processing but if a problem occurs in the sending of messages your other processing will not be rolled back.

提交回复
热议问题