MessageDrivenBean实例标识符 [英] MessageDrivenBean instance identifier

查看:126
本文介绍了MessageDrivenBean实例标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获取正在执行的MDB实例的标识符?
我有一个MDB池(例如10),我在我的消息中设置属性JMSXGroupID,以便具有相同的MDB实例处理所有具有相同JMSXGroupID的消息。
要检查我想要记录当前MDB实例的标识符:如何获取该信息?

解决方案

根据EJB规范,没有这样的标识符,尽管可能使用您的MDB供应商API来实现。



您可以随时在@PostConstruct方法中创建唯一的MDB标识符,但在我看来,它不是一个好的解决方案,因为池中的所有bean都应该以同样的方式对待!



也许您可以将JMSXGroupID设置为消息头,并在MDB中使用消息选择器来处理它,并使用给定的MDB实现,以便不止一个bean侦听在给定队列(示例)?



或者你可以创建通用的MDB bean,它将提取前面提到的头并使用你愿意按照JMSXGroupID实现的状态来调用EJB单例bean。 p>

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?

解决方案

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.

这篇关于MessageDrivenBean实例标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆