• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!


 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Each messge is processed/consumed only once.
 
Jay Lim
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Rancher
Posts: 989
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic