File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Unable to consume message from jms queue more than once using jsf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Unable to consume message from jms queue more than once using jsf" Watch "Unable to consume message from jms queue more than once using jsf" New topic
Author

Unable to consume message from jms queue more than once using jsf

Jay Lim
Greenhorn

Joined: Jul 04, 2012
Posts: 5
I am trying to create a jsf page which will connect to this managed bean when it wants to receive a message from the jms queue. In the JSF page, when the method #{review.getMessage()} was called, a message could successfully be retrieved from the queue. However, when i close the webpage and reopen again, to try to make a connection to the jms queue, i realized i was not able to receive the JMS message from the queue. I have to redeploy the Glassfish server, in order for the consumption of message to work again. While debugging, i realized the onMessage method was called during the first run only.

Thanks in advance for the help guys!


Rajit vreddi
Greenhorn

Joined: Jul 05, 2012
Posts: 17
Each messge is processed/consumed only once.
Jay Lim
Greenhorn

Joined: Jul 04, 2012
Posts: 5
Yes, but it should work such that, everytime i click the button in the JSF page, i should create a new connection and consume a message if there is one in the queue. However, now it is not working that way. Every subsequent connection i made, the onMessage was not activated even when there is a message waiting in the queue.
I have to redeploy the application in order for the message to be consumed. How do i make the onMessage to work every time i hit the button in the JSF page?
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
You are manually triggering the receipt so why have a MessageListener if you're not receiving the messages asynchronously?
I'd expect that you would call the receive or receiveNoWait method here.

Jay Lim
Greenhorn

Joined: Jul 04, 2012
Posts: 5
Hey! That was awesome! I managed to receive the messages successfully whenever i click the button after using the receive() than onMessage().
I understand why receive will work, but i am also curious why the onMessage() method doesn't work? While implementing in application client, it works successfully whenever i run it.
Is it because the web takes a shorter time to load, thus the message does not call the onMessage method?
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
Jay Lim wrote:..
I understand why receive will work, but i am also curious why the onMessage() method doesn't work?..


Probably because you're inducing undefined behavior. The specs for setMessageListener says

The effect of calling MessageConsumer.setMessageListener while messages are being consumed by an existing listener or the consumer is being used to consume messages synchronously is undefined.
Rajit vreddi
Greenhorn

Joined: Jul 05, 2012
Posts: 17
your messagelistener behaving not properly or stop running after message is consumed.did you clean resources like session,queue and etc.. after finishing message process.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to consume message from jms queue more than once using jsf