[jboss-user] [Messaging, JMS & JBossMQ] - Queue - I can send but cannot receive

vitor_b do-not-reply at jboss.com
Fri Mar 23 08:20:43 EDT 2007


JBoss: 4.0.5 GA

I'm still facing some problems working with JMS.
The last problem is that i cannot receive message from queue. I  can send it, but cannot receive it later. All from mothod inside simle stateless session bean. This method works in a transaction (Container, Required).

First getting stuff

	InitialContext ictx = new InitialContext();
  | 	ConnectionFactory cf = (ConnectionFactory) ictx.lookup("java:JmsXA");
  | 	Connection con = cf.createConnection();
  | 	Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
  | 	Queue queue = (Queue ) ictx.lookup("queue/testQueue");
  | 	logger.info(queue.getQueueName());

Now we can perform some operations on queue:
First we can send message:

	MessageProducer sender = session.createProducer(queue);
  | 	Order order = new Order();
  | 	order.setOrderId("orderId");
  | 	Message message = session.createObjectMessage(order);
  | 	sender.send(message);
  | 	logger.info("Message has been sent");

Sending messages works fine.
Now i would like to receive one message:

	MessageConsumer consumer = session.createConsumer(queue);
  | 	Message m = consumer.receiveNoWait();
  | 	if (m == null){
  | 		logger.error("m is null");
  | 	}else{
  | 		logger.info("got message, yupi");
  | 	}

But I cannot get message from queue "testQueue". Everytime single time i get null. Queue depth is huge now after so many tries :(

I deployed MDB, and that MDB was able to consume messages from this queue. I have no idea what i'm doing wrong. Any sugestions?

Thank you for all your replies in advance.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031032#4031032

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031032

More information about the jboss-user mailing list