拥有一个消息驱动的 bean“fire”;作为两个事件的结果?
我希望 MDB 仅在到达两个独立国家后才启动。例如:
事件A发生 一段时间过去了 事件B发生 A 事件和 B 事件同时发生时调用 MDB onMessage A 和 B 事件被清除
因此,例如,如果事件 B 发生但事件 A 尚未发生,那么我不希望触发 onMessage。同样,如果事件 A 发生但事件 B 未发生,我不希望 onMessage 触发。我还希望事件 A 和 B 相关联,以便在触发 onMessage 时事件 A 和 B 被清除。
实现此目的的一种方法是让事件 A 生成一条消息,该消息处理程序将检查事件 B 是否已发生,但它必须阻塞并循环,直到事件 B 触发为止。轮询方案似乎效率低下。
从功能上讲,这类似于 CyclicBarrier,但通过消息传递实现。
对于 MDB 是否可以实现这样的事情,有什么想法吗?
I would like to have an MDB that fires only after two independent states have been reached. For example:
Event A occurs
some time passes
Event B occurs
MDB onMessage is called as a result of both A and B event occurring
A and B events are cleared
So for example if Event B occurs but Event A has not occurred then I do not want the onMessage triggered. Similarly if Event A occurs but Event B has not occurred I do not want the onMessage to fire. I also want Event A and B to be correlated such that when onMessage is fired Events A and B are cleared.
One way to do this would be to have Event A produce a message and the message handler for that would check to see if Event B has occurred but it would have to block and loop until an Event B had fired. The polling scheme seems inefficient.
Functionally this would act like a CyclicBarrier but implemented with messaging.
Any thoughts as to whether or not something like this is possible with MDBs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对此没有内置机制。我建议将增量状态存储在数据库表中(收到第一个事件时插入,收到第二个事件时更新/删除)。
我绝对不建议投票;有太多的事情可能会出错(服务器线程挂起、CPU 浪费、事务超时等)。
There is no builtin mechanism for this. I would recommend storing incremental state in a DB table (insert when the first event is received, update/delete when the second event is received).
I would definitely not recommend polling; there are far too many things that can go wrong (hung server threads, wasted CPU, transaction timeouts, etc.).