Can't get JMS Session.CLIENT_ACKNOWLEDGE to work - Websphere

This is a discussion on Can't get JMS Session.CLIENT_ACKNOWLEDGE to work - Websphere ; We have Websphere MQ 6.0.2.2 and WAS 6.1.0.13. I am trying to get Session.CLIENT_ACKNOWLEDGE to work when using JMS 1.1, but what ever I seem to do the message gets pulled off the queue (as seen via MQ explorer). The ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Can't get JMS Session.CLIENT_ACKNOWLEDGE to work

  1. Can't get JMS Session.CLIENT_ACKNOWLEDGE to work

    We have Websphere MQ 6.0.2.2 and WAS 6.1.0.13.



    I am trying to get Session.CLIENT_ACKNOWLEDGE to work when using JMS 1.1, but what ever I seem to do the message gets pulled off the queue (as seen via MQ explorer).

    The the QueueConnectionFactory and Queue are setup in the WAS admin and connected to via JNDI in my Java code.



    As you know the JMS code is really simple, so I think it may well be some issue/configuration on MQ that I am missing:



    con = qcf.createQueueConnection();

    QueueSession queueSession = con.createQueueSession(false,Session.CLIENT_ACKNOW LEDGE);



    Queue jmsQueue =jmsQueues.get("MyQueue");

    QueueReceiver queueReceiver = queueSession.createReceiver(jmsQueue);



    Queue q = queueReceiver.getQueue();

    con.start();

    Message message = queueReceiver.receive();



    TextMessage textMsg = (TextMessage) message;



    // wait here in debug mode and note that message has already left the queue



    message.acknowledge();


    Any ideas on what in MQ would stop CLIENT_ACKNOWLEDGE from working?



    Thanks

  2. Re: Can't get JMS Session.CLIENT_ACKNOWLEDGE to work

    tom.forrester@belmin.com wrote:
    > We have Websphere MQ 6.0.2.2 and WAS 6.1.0.13.
    >
    >
    >
    > I am trying to get Session.CLIENT_ACKNOWLEDGE to work when using JMS 1.1, but what ever I seem to do the message gets pulled off the queue (as seen via MQ explorer).


    As it should do - each message may only be delivered to one consumer, so
    until we know that your application will not acknowledge that message we
    must hide it from everyone else.

    If you want to verify that CLIENT_ACKNOWLEDGE is working correctly, you
    can call the recover() method of your Session object and verify that
    your unacknowledged messages are once more visible on the queue.
    Closing the Session or Connection killing your application will have the
    same effect.

    A CLIENT_ACKNOWLEDGE session is essentially a transacted for Receivers
    and non-transacted for Producers, where Session.commit() is renamed
    Message.acknowledge() and Session.rollback() is renamed Session.recover().

    Regards,

    Phil Willoughby
    --
    Staff Software Engineer - IBM WebSphere MQ for z/OS
    Senior Inventor

    IBM Certified System Administrator - WebSphere MQ V6.0
    IBM Certified Solution Designer - WebSphere MQ V6.0
    IBM Certified SOA Solution Designer

  3. Re: Can't get JMS Session.CLIENT_ACKNOWLEDGE to work

    Thanks Phil,



    That makes sense, but I don't see that behaviour, when using either queueSession.recover() or queueSession.commit() or queueSession.close();



    the message dos not appear back on the queue.

  4. Re: Can't get JMS Session.CLIENT_ACKNOWLEDGE to work

    Interestingly I can only get the message to remain on the queue if I set the transacted flag on the QueueSession to true and invoke the .recover(), regardless of whether I use Session.AUTO_ACKNOWLEDGE or Session.CLIENT_ACKNOWLEDGE. That is with transacted flag set to false nothing I do will cause the message to stay on the queue.

    Also I set the Backed Out Threshold to 1 on the queue (via WAS admin.) and provided a "Backout requeue name" but even when triggering the re-queue by the above method I could not get the message to be placed on the Backed-out queue either.



    So it seems the CLIENT_ACKNOWLEDGE is NOT "essentially a transacted for Receivers" as Phil suggested, at any rate when the transacted flag is set to false and when it is set to true .recover() invokes the same behaviour whether you use CLIENT_ACKNOWLEDGE or AUTO_ACKNOWLEDGE.



    Sure, I could set the transacted flag to true and use the .recover() method rather than using CLIENT_ACKNOWLEDGE, but it does seem that there is a bug here, has anyone else found this issue?

  5. Re: Can't get JMS Session.CLIENT_ACKNOWLEDGE to work

    tom.forrester@belmin.com wrote:
    > That makes sense, but I don't see that behaviour, when using either queueSession.recover() or queueSession.commit() or queueSession.close();


    queueSession.commit() should throw an exception in the scenario you
    described as it is only valid for use with a transacted Session.

    Regards,

    Phil Willoughby
    --
    Staff Software Engineer - IBM WebSphere MQ for z/OS
    Senior Inventor

    IBM Certified System Administrator - WebSphere MQ V6.0
    IBM Certified Solution Designer - WebSphere MQ V6.0
    IBM Certified SOA Solution Designer

  6. Re: Can't get JMS Session.CLIENT_ACKNOWLEDGE to work

    tom.forrester@belmin.com wrote:
    > Interestingly I can only get the message to remain on the queue if I
    > set the transacted flag on the QueueSession to true and invoke the
    > .recover(), regardless of whether I use Session.AUTO_ACKNOWLEDGE or
    > Session.CLIENT_ACKNOWLEDGE. That is with transacted flag set to false
    > nothing I do will cause the message to stay on the queue.


    AcknowledgeMode is ignored for transacted sessions.

    > So it seems the CLIENT_ACKNOWLEDGE is NOT "essentially a transacted
    > for Receivers" as Phil suggested, at any rate when the transacted
    > flag is set to false and when it is set to true .recover() invokes
    > the same behaviour whether you use CLIENT_ACKNOWLEDGE or
    > AUTO_ACKNOWLEDGE.


    The behaviour I described is the designed behaviour - if you are not
    seeing that behaviour you need to call IBM service and report a problem.

    Regards,

    Phil Willoughby
    --
    Staff Software Engineer - IBM WebSphere MQ for z/OS
    Senior Inventor

    IBM Certified System Administrator - WebSphere MQ V6.0
    IBM Certified Solution Designer - WebSphere MQ V6.0
    IBM Certified SOA Solution Designer

+ Reply to Thread