How can I notify the cometd server instance when I get JMS message on Message driven bean?

StackOverflow https://stackoverflow.com/questions/22209712

سؤال

I have read somewhere that the Cometd is container specific and we cannot inject into an EJB container. I have an application in which there are MDBs defined and the messages received are somehow should be sent to the web clients. Is it possible?

I appreciate any inputs. thanks.

هل كانت مفيدة؟

المحلول

CometD is not container specific, it will work in any Servlet 3 container using Asynchronous Servlets.

CometD relies on Jetty classes for its implementation, and scales best when deployed in Jetty, but there are users that deploy CometD in Tomcat, GlassFish, etc.

Having said that, if you deploy CometD into a JEE server and have MDBs, you can easily convert the MDB message into a CometD message and have CometD send it to clients.

The actual details of how to wire the MDB to CometD depend on the frameworks you use (e.g. Spring, CDI, custom, etc.), but typically the MDB needs to lookup/notify a CometD service, and have the CometD service broadcast the CometD message.

You can find the CometD server-side tutorial very similar (although it's not using MDBs) to what you need. In that tutorial, the role of the MDB is played by the StockPriceEmitter class.

Look also at the CometD reference manual for further information.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top