[英]Invocation Listener for EJB 3 / web service?
We have a system using EJB 3
Stateless bean which is also exposed as web service. 我们有一个使用
EJB 3
无状态bean的系统,它也作为Web服务公开。
There's a integration request from other team that want our system to fire a notification to other system after invocation (by web services or other means). 有一个来自其他团队的集成请求,希望我们的系统在调用之后(通过Web服务或其他方式)向其他系统发出通知。 Since this is not totally related to our system I would prefer to have this feature loosely coupled with our own system instead of hard coding these features in to our system code.
由于这与我们的系统并不完全相关,我宁愿将此功能与我们自己的系统松散耦合,而不是将这些功能硬编码到我们的系统代码中。
Is there any feature on EJB or web services that can achieve what I desire? EJB或Web服务上是否有任何功能可以实现我的目标? We would require a method level invocation listener so that when the EJB method/ web service get invoked, it can trigger a callback/message so we can do something according to it.
我们需要一个方法级别的调用监听器,以便在调用EJB方法/ Web服务时,它可以触发回调/消息,以便我们可以根据它执行某些操作。 I would expect it to be some kind of annotation/configuration for setting up JMS or something.
我希望它是用于设置JMS或其他东西的某种注释/配置。
We are using JBoss as the application server. 我们使用JBoss作为应用程序服务器。 If there's any JBoss specific solution it's also welcomed.
如果有任何JBoss特定的解决方案,它也受到欢迎。
I would suggest two options: 我建议两个选择:
use JMS. 使用JMS。 When you mentioned loose coupling, JMS first crossed my mind - you can put a message on some queue/topic after method invocation and let the listener to perform futher actions.
当你提到松散耦合时,JMS首先想到了 - 你可以在方法调用之后在某个队列/主题上放置一条消息,让监听器执行更多的操作。 JMS messages can carry various kinds of objects - the only request is that class implements Serializable ( ObjectMessage#setObject );
JMS消息可以携带各种对象 - 唯一的请求是该类实现Serializable( ObjectMessage#setObject ); other advantage is that you can (un)deploy your Stateless bean and other system independently.
另一个优点是您可以(un)独立部署无状态bean和其他系统。 They can be on different JVMs.
它们可以位于不同的JVM上。
use Interceptors. 使用拦截器。 Technically, they would be invoked before your methods runs, but of course there is always some nice workaround :-) Here is the official documentation about Interceptors, but since you mentioned that you're using JBoss, there can be also found some interesting material on JBoss pages .
从技术上讲,它们会在你的方法运行之前被调用,但当然总会有一些很好的解决方法 :-)这是关于拦截器的官方文档 ,但既然你提到你正在使用JBoss,那么也可以找到一些有趣的材料在JBoss页面上 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.