Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top