MessageConsumer not consuming messages from Temporary queue

I have a client application that is deployed on JBoss 4.03-sp1.

The client application looks up the connection factory and queue from SJSAS8.1

I create a temporary queue, create a message, set the temporary queue in the jmsreplyto of the message and send it to the queue. However the message consumer doesnt retrieve the response from the temporary queue. If i use a queuebrowser i can find the message there. Any clue on what might be happening?

Code snippets:

TemporaryQueue temporaryQueue =null;

MessageProducer producer =null;

QueueReceiver consumer =null;

temporaryQueue = session.createTemporaryQueue();

TextMessage message = session.createTextMessage(object.toString());

message.setJMSReplyTo(temporaryQueue);

producer = session.createProducer(getJmsTemplate().getDefaultDestination());

producer.send(destination, message);

consumer = ((QueueSession)session).createReceiver(temporaryQueue);

response = consumer.receive(connectionTimeout);

response is null

but if i do the following i can retrieve the message:

if(response==null){

QueueBrowser queueBrowser = session.createBrowser(temporaryQueue);

boolean exists = queueBrowser.getEnumeration().hasMoreElements();

if (exists){

response = (Message) queueBrowser.getEnumeration().nextElement();

response.acknowledge();

}

queueBrowser.close();

}

First thing i thought was it was an expiration issue, but the JMSExpiration of the message is 0.

any hints on what might be the problem?

[1936 byte] By [jmota_csw] at [2007-11-26 9:19:46]
# 1

Hi,

The following code should work for you. The producer must produce the message to the same destination (temporaryQueue) so that the consumer can receive the message.

chiaming

temporaryQueue = session.createTemporaryQueue();

TextMessage message = session.createTextMessage(object.toString());

message.setJMSReplyTo(temporaryQueue);

//producer = session.createProducer(getJmsTemplate().getDefaultDestination());

//replace the above statement with the following statement.

producer = session.createProducer(temporaryQueue );

producer.send(message);

consumer = ((QueueSession)session).createReceiver(temporaryQueue);

response = consumer.receive(connectionTimeout);

-

chiamingyang at 2007-7-6 23:50:11 > top of Java-index,Application & Integration Servers,Sun Java System Message Queue...