Howdy, I don't have much time before a meeting, but let's see if I can help.
I have one class that reads the configuration (initial context factory class, JNDI URL, queue name, etc.) from a file, creates the initial context, connects to the server, and has a QueueReceiver. This class doesn't implement any interfaces, but it does expose a setMessageListener(MessageListener ml) method. This class is also a singleton. The setMessageListener(ml) method calls the setMessageListener(ml) on the QueueReceiver. Then I have a class that implements MessageListener. It does a getInstance() on the above singleton class, and then setMessageListener(this). This class gets notified when messages are sent to the queue, and it consumes the messages. I have it then create an Event object (POJO, not JMS) with some specific things I extract from the message, and do stuff with this event in a new Thread. The latter part is not strictly necessary but I've found it useful in separating the handling of multiple possibly concurrent messages. Yoav Shapira Millennium ChemInformatics >-----Original Message----- >From: Gavin, Rick [mailto:[EMAIL PROTECTED] >Sent: Wednesday, November 19, 2003 1:36 PM >To: Tomcat Users List >Subject: RE: Tomcat & OpenJMS Design Pattern? > >Hi Yoav, > I was looking for a basic design model, that worked well, such as a high >level class diagram( classes,interfaces, etc ) that shows a good way to >implement openJMS within tomcat. Some code snipets would be nice if >possible. As I said, my main consern in Point-to-Point Queue processing, I >don't have any need for Subscription / Topic. Basically I was looking to >have some manager class that on tomcat startup, would read in a config >file, >then create listeners for all specified queues. > >It my current tests, I have been having trouble getting the listeners to >work properly. I have no trouble putting messages in the queue, but my >listener some how is removing the item from the queue but not calling the >onMessage() method, so I never get a chance to handle the message, it just >vanishes. > >My listeners have this structure.. > >class FtpQueueListener implements javax.jms.MessageListener >{ > private QueueSession session; > private QueueReceiver receiver; > > FtpQueueListener() > > close() > // closes jms session > // clears the reciever's message listener.. >receiver.setMessageListener(null); > > startListener() > // gets a jms connection,session, receiver and bind them to local >variabls > // sets the reciever's message listener to self.. >receiver.setMessageListener(this); > > onMessage() > // handles messages, but seems to never get called, broken >} > >I was reading some info that talked about using the MessageListner.run() >method in a threaded sense. >You need to make the class implement runnable. Is this required for doing >async message handling? > >Thanks for your help, > >Rick > > >-----Original Message----- >From: Shapira, Yoav [mailto:[EMAIL PROTECTED] >Sent: Wednesday, November 19, 2003 5:26 AM >To: Tomcat Users List >Subject: RE: Tomcat & OpenJMS Design Pattern? > > >Howdy, >I've used and use OpenJMS with tomcat all the time, including in several >production systems. > >What are you looking for specifically? A document? Code that sends >messages to an OpenJMS queue/topic, received from an OpenJMS queue/topic, >all of the above? > >I've actually gone from using tomcat's JNDI support to specifying the JMS >connection parameters in an app-specific configuration file and creating >the >JMS objects myself. But I had it working via tomcat's JNDI before as well. > >Yoav Shapira >Millennium ChemInformatics > > >>-----Original Message----- >>From: Gavin, Rick [mailto:[EMAIL PROTECTED] >>Sent: Tuesday, November 18, 2003 6:25 PM >>To: Tomcat Users List >>Subject: Tomcat & OpenJMS Design Pattern? >> >>Hi All, >> Just wondering if any could post a working design pattern for using >>openJMS or another open JMS engine with tomcat, preferably a model >>using asynchronous queue >message >>handling. I >>figured someone around here has done it and I would rather use a tried >and >>true model. >> >>Looking for some basics about best intregration method, and or for >dealing >>with async message >>Handling. >> >>I currently have openJMS setup using persistent Database storage, using >>JNDI content lookup to Get the JMS connection factory, is this better >>looked up once and bound >to >>servlet context as an >>Application scope variable, etc, etc? >> >>Thanks for you any help, >> >>Rick > > > >This e-mail, including any attachments, is a confidential business >communication, and may contain information that is confidential, >proprietary >and/or privileged. This e-mail is intended only for the individual(s) to >whom it is addressed, and may not be saved, copied, printed, disclosed or >used by anyone else. If you are not the(an) intended recipient, please >immediately delete this e-mail from your computer system and notify the >sender. Thank you. > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
