How do I programmatically start/stop an EJB

老子叫甜甜 提交于 2019-12-24 14:13:00

问题


Does anyone know if it's possible to start/stop an EJB within my application code? Eg. I have some MDBs that I wish to selectively start/stop while my application is running? Any ideas? Can this maybe be done via JMX?

Cheers!


回答1:


The EJB spec has no mechanism to start/stop individual EJBs (or even modules) within an application. It is possible to start/stop applications dynamically using JMX via JSR 77.

(I see you're using the jboss tag. I have no expertise in JBoss, so I don't know if it provides extensions that support what you want to do.)




回答2:


An EJB is not something that can be "started" or "stopped". Sure, it has a life cycle but that is more concerned with creation, activation, passivation and removal of EJB instances, and it's entirely up to the EJB container to manage the life cycle.

In short: you can't manage an EJB's life cycle programmatically.




回答3:


Each deployed MDB has a management MBean. The MBean class is org.jboss.ejb3.mdb.MdbDelegateWrapper. The JMX ObjectName varies between versions of JBoss 4, and vary depending on how you deployed them. Assuming you deployed an MDB called MyMDB in a jar called myapp.jar which was in an ear called myapp.ear, the name might be:

jboss.j2ee:ear=myapp.ear,jar=myapp.jar,name=MyMDB,service=EJB3

Older version of JBoss 4 also had a system hashcode in there. And if you're not using EJB3, I think the service will still be there only it will be EJB2.

Anyways, once you find the management bean, you can call the stop and start operations. We use this frequently to pause message delivery.



来源:https://stackoverflow.com/questions/10580951/how-do-i-programmatically-start-stop-an-ejb

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