MessageDrivenBean instance identifier

半世苍凉 提交于 2019-12-08 13:42:46

问题


Is it possible to get the identifier of the MDB instance that is executing? I have a pool of MDB (e.g. 10) and I set in my messages the property JMSXGroupID in order to have the same MDB instance processing all the messages with same JMSXGroupID. To check that I'd like to log an identifier of the current MDB instance: how can I get that information?


回答1:


There is no such identifier according to EJB specification, although probably it may be achieved using your MDB vendor API.

You can always create unique MDB identifier in @PostConstruct method, but in my opinion it is not a good solution, as all beans in the pool should be treated the same way!

Maybe you could set JMSXGroupID as a message header, and use message selector in MDB to process it with given MDB implementation, so that there would be more than one bean listening on given queue (example)?

Or you could create generic MDB bean which will extract mentioned previously header and invoke EJB singleton bean with state you are willing to achieve per JMSXGroupID.



来源:https://stackoverflow.com/questions/42907214/messagedrivenbean-instance-identifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!