Writing a JMS Publisher without "public static void main"
Posted
by The Elite Gentleman
on Stack Overflow
See other posts from Stack Overflow
or by The Elite Gentleman
Published on 2010-03-15T21:09:09Z
Indexed on
2010/03/16
11:26 UTC
Read the original article
Hit count: 415
Hi guys,
Every example I've seen on the web, e.g. http://www.codeproject.com/KB/docview/jms_to_jms_bridge_activem.aspx, creates a publisher and subscriber with a public static void main
method. I don't think that'll work for my web application.
I'm learning JMS and I've setup Apache ActiveMQ to run on JBoss 5 and Tomcat 6 (with no glitches).
I'm writing a messaging JMS service that needs to send email asynchronously.
I've already written a JMS subscriber that receives the message (the class inherits MessageListener
).
My question is simple:
- How do I write a publisher that will so that my web applications can call it? Does it have to be published somewhere? My thought is to create a publisher with a no-attribute constructor (in there) and get the MessageQueue Factory, etc. from the JNDI pool (in the constructor). Is my idea correct?
- How do I subscribe my subscriber to the Queue Receiver? (So far, the subscriber has no constructor, and if I write a constructor, do I always subscribe myself to the Queue receiver?)
Thanks for your help, sorry if my terminology is not up to scratch, there are too many java terminologies that I get lost sometimes (maybe a java GPS will do! :-) )
PS Is there a tutorial out there that explains how to write a "better" (better can mean anything, but in my case it's all about performance in high demand requests) JMS Publisher and Subscriber that I can run on Application Server such as JBoss or Glassfish? Don't forget that the JMS application will needs a "guarantee" uptime as many applications will use this.
© Stack Overflow or respective owner