質問

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