dcsimg
Synchronous message consumption together with CLIENT_ACKNOWLEDGE configured session fails.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jonas_Carlsson
Posted On:   Wednesday, March 5, 2003 09:32 AM

Hi everybody, I am writing a prototype for a "Queue Flusher" that is intended to run as a batch job and pick messages of a queue until queue is empty (or a max message count is reached). It is then supposed to process all messages. It is imperative that no messages are ever lost in this process, and therefore all messages must be pushed back on the queue if any problems are encountered during the processing. I went about this by writing the following "flushing test piece": InitialContext context = new InitialContext(); QueueConnectionFactory qConnectionFactory = ( QueueConnectionFactory)context.lookup("jms/MQConnectionFactory");    More>>

Hi everybody,



I am writing a prototype for a "Queue Flusher" that is intended to run as a batch job and pick messages of a queue until queue is empty (or a max message count is reached). It is then supposed to process all messages. It is imperative that no messages are ever lost in this process, and therefore all messages must be pushed back on the queue if any problems are encountered during the processing.



I went about this by writing the following "flushing test piece":




			
InitialContext context = new InitialContext();
QueueConnectionFactory qConnectionFactory = (
QueueConnectionFactory)context.lookup("jms/MQConnectionFactory");
Queue queue = (Queue)context.lookup("jms/MQOutputQueue");
QueueConnection qConnection = qConnectionFactory.createQueueConnection();
QueueSession qSession = qConnection.createQueueSession(false,
Session.CLIENT_ACKNOWLEDGE);
QueueReceiver qReceiver = qSession.createReceiver(queue);
qConnection.start();

TextMessage msg = null;
TextMessage msgPrevious = null;
while ((msg = (TextMessage)qReceiver.receive(1)) != null) {
resp.getWriter().println(msg.getText());
msgPrevious = msg;
}

// expect this to acknowledge all received messages
if (msgPrevious != null)
msgPrevious.acknowledge();

qReceiver.close();
qSession.close();
qConnection.close();



The problem I have is that when I do message.acknowledge() on the last message, I receive the exception: "javax.jms.IllegalStateException: MQJMS1057: Message has no session associated with it". Interesting enough: when I comment out the message acknowledgement code everything works and messages are never redelivered. This is not the expected behavour since the session has been configured to use CLIENT_ACKNOWLEDGE, which should result in redelivery of messages picked of but not acknowledged within the session.



As hinted by bode, I'm doing this in an IBM shop. The code is triggered by a servlet, so EJB transactions etc should not apply. I have tried the piece with WSAD 5.0 GA internal queue provider and a full MQSeries queue, both resulting in the same exception.



I am absolutely stuck here and would highly appreciate any feedback.    <<Less
About | Sitemap | Contact