• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

putting back into the queue the JMS messages

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I was wondering if I read a message from a message Queue, and want to put it back can I do it?
I am using a JMS Queue inside JBoss 3.0. Inside a session bean, I am sending messages to this queue. In my frontend I am reading the messages and using them. But if at a previous action the usecase terminated earlier than expected, not all the messages inside the queue were processed so there were some left inside the queue. The next time the usecase is runned, the frontend will process these leftout messages too but I don't want that. Now, I've written a message consumer which is called at the beginning of the usecase, and this consumer pops out all the messages inside the queue. But this messages are different for different users/machines/browsers. Inside each message I have a sessionID. Now, the consumer pops out all the messages, but I want it to pop out only the messages for a certain user. Here is my question:
1)Can I read the contents of a message without poping out the message?
or
2)If I pop out the message to read it's contents and I see that it's a message for another user and not the one currently running the usecase, I have to put the message back into the queue. Can I do that and how?
Thanks guys
Wish you well
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


1)Can I read the contents of a message without poping out the message?


I have done this when I was using Oracle's AQ that reads straight from the queue tables but that was part of administration, if the real app can read directly from db table or other place where the message is stored then the use Messaging server for queing becomes irrelevent. I don't know any other way of reading the message in the queue with out poping it out.


2)If I pop out the message to read it's contents and I see that it's a message for another user and not the one currently running the usecase, I have to put the message back into the queue. Can I do that and how?


I have read some were if you are a durable subscriber and your message listeners (MDB) are part of a (container managed)transaction then if an exception is thrown when processing the message then the message is put back into the queue automatically (I don't have any clear proof of the above). Or your listener application can have a message producer which can reformat the poped out message and put it back to the queue.
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I know that if an exception occures, the message will be put back into the queue. I'm not sure if in my case this is true but it's not a solution and I will tell you why: if I have 10 messages inside the queue, and at the 5th message I realize it's not for the current user, I throw an exception and maybe the message gets back into the queue, but for sure the last 5 messages are not proccessed. Do you get my point?
Reformatting the message and putting it back into the queue is a solution but it's not the most elegant.
Do you know of any other solution guys?
Thanks, Sergiu.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about using the browsing capability of JMS or
rollback the user transaction will undo all read from the queue...
Melody
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Melody Sadler:
What about using the browsing capability of JMS or
rollback the user transaction will undo all read from the queue...
Melody



I think you can use for QueueBroswer facilities..
- Raman
 
Let's get him boys! We'll make him read this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic