Announcement Announcement Module
Collapse
No announcement yet.
How use whith IBM MQ the MQQueueManager.backout() metod whith spring framework? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How use whith IBM MQ the MQQueueManager.backout() metod whith spring framework?

    How use whith IBM MQ the MQQueueManager.backout() metod whith spring framework?

    I made it with code with ibm code.

    Code:
    MQGetMessageOptions gmo = new MQGetMessageOptions(); // Set
    			// get
    			// message
    			// options
    			gmo.options = MQC.MQGMO_WAIT
    					+ MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_CONVERT + MQC.MQGMO_SYNCPOINT;
    			gmo.waitInterval = MQC.MQWI_UNLIMITED;			
    			
    			while (true) {
    				MQMessage myMessage = new MQMessage();
    				myMessage.clearMessage();
    				myMessage.correlationId = MQC.MQCI_NONE;
    				myMessage.messageId = MQC.MQMI_NONE;
    				
    				System.out.println("waiting for message ... ");
    				myQueue.get(myMessage, gmo);
    				System.out.println("Get message sucessfull... ");
    				
    				System.out.println("Message lenght = "+myMessage.getMessageLength());
    				
    				/** ********************************* */
    				/* Have we gotten to the threshold? */
    				/** ********************************* */
    				if (myMessage.backoutCount <= boThresh) {
    					System.out.println("BackoutCount: "
    							+ myMessage.backoutCount + " of " + boThresh);
    					qMgr.backout(); /* increase backout count by one */
    				}
    I necessary make the backout on IBM MQ queue when there are exception in code.
    Someone know how do it?

  • #2
    If you can't do it with JMS, you probably can't do it with Spring.

    Comment


    • #3
      Cant you do this with JTA transactions? I believe when you trigger a rollback on a JMS transaction, it causes the underlying MQ manager to perform a backout on the message.

      Comment


      • #4
        I resolve using JMS Session and Rollback:

        Code:
        queueConnectionFactory = (QueueConnectionFactory) getJmsReceiver()
        					.getJmsTemplate().getConnectionFactory();
        
        			// create a Queue Connection
        			queueConnection = queueConnectionFactory.createQueueConnection();
        
        			// create a Queue Session
        			queueSession = queueConnection.createQueueSession(true,
        					Session.AUTO_ACKNOWLEDGE);
        
        			// create Queue with DefaultDestination()
        			Queue queue = (Queue) getJmsReceiver().getJmsTemplate()
        					.getDefaultDestination();
        
        			// create Queue Receiver
        			queueReceiver = queueSession.createReceiver(queue);
                                              // start the connection
        			queueConnection.start();
        
        queueSession.commit();
        
        ....
        
        or queueSession.rollback();
        by

        Comment

        Working...
        X