• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Can JMS handle multiple requests?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

We have a MQ component which uses the JMS for MQ communication.

Can JMS handle multiple requests to the same queue?

regards,
Neha
 
Sheriff
Posts: 3064
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Neha,

Welcome to the Ranch. I'm sure some bartenders will be along soon to modify your post. You made a couple mistakes. Always use code tags when posting code and never, never, never post copyrighted code. Generally speaking, you can't expect people here to read through hundreds of line of code, so it's a good idea to just post the important parts of the code ... maybe 20 to 30 lines. That helps with copyright issues too.

Meanwhile, what do you mean by multiple requests? Do you mean several readers reading from the same queue? That's always possible. In a normal point-to-point mode, each reader gets a different message, so having multiple readers just can speed up how fast messages are consumed. In a publish/subscribe mode, all active readers (now called subscribers) that have registered their interest in that queue (now called a topic) will get every message written (published) to it.

Greg
 
Neha Prasad
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Greg,

Thank you for the advice. I really appreciate it.

Yes, we are trying for several readers reading from the same queue.

I read in below link that JMS cannot handle multiple requests and the code has to handle multiple reading on the same queue. Is it correct?

http://www.ibm.com/developerworks/java/library/j-pj2ee5/

Do i need to handle multiple queues handling in the code we are writing for communication with MQ using JMS?

Thanks and regards,
neha
 
Greg Charles
Sheriff
Posts: 3064
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Neha,

I looked at the link you gave, but I'm not sure exactly what section you are referring to. Yes, you can have multiple queues and you can have several readers for the same queue.

JMS has several constructs. You use a ConnectionFactory to get a Connection, and the Connection to get the Session. When I was just starting out with JMS (and only wanted a single reader), it seemed like a huge burden to just get to the point where I could read a message. However, the advantage is you can create one Connection, which is guaranteed thread-safe, and use it to create multiple Sessions, which are not guaranteed thread-safe. You can create many readers, each in a separate thread, to read from the same queue. Each will get a different message. They just share the work of processing.

In the J2EE world, the easiest thing to do is just create a Message Driven Bean. This bean will handle reading messages from a specific queue, without forcing you to even deal with Connections and Sessions. You can then configure the number of readers just by configuring the number of beans through your app server administration.

Greg
 
reply
    Bookmark Topic Watch Topic
  • New Topic