You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "Leonardo K. Shikida" <sh...@gmail.com> on 2013/10/08 18:47:25 UTC

Disable/Enable MDB

Hi

Is there any way to disable/enable a MDB programmatically?

Right now, it consumes from a JMS queue and the queue definitions are coded
using @ActivationConfigProperty. if I just set a flag in the database and
let the MDB check it before executing the onMessage() message, I guess I'd
have to re-enqueue the message. Instead, I'd like to just "pause" and
"restart" my MDBs, not touching the queue.

or example, for tomee/openjpa, is there something similar to this code for
jboss?

MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
    ObjectName objName = new
ObjectName("jboss.j2ee:ear=MessageGateway.ear,jar=MessageGateway-EJB.jar,name=MessageSenderMDB,service=EJB3");
    JMSContainerInvokerMBean invoker = (JMSContainerInvokerMBean)
MBeanProxy.get(JMSContainerInvokerMBean.class, objName, mbeanServer);

    invoker.stop(); //Stop MDB
    invoker.start(); //Start MDB

If I'd understood this well, the container consumes from the JMS queue
and then it sends to the MDB method.

So I guess what I am really looking for is some activemq or tomee JMX
instruction (and how to call it from inside a webapp code) telling
tomee to pause/resume it's JMS consumer.


TIA

Leo

Re: Disable/Enable MDB

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
Thx. I am there ;-)
Em 08/10/2013 17:48, "Christian Posta" <ch...@gmail.com> escreveu:

> May want to ask this on the TomEE mailing list. I would think there would
> be some JMX mbeans that can be used to start/stop a EJB/MDB
>
>
> On Tue, Oct 8, 2013 at 9:49 AM, Leonardo K. Shikida <shikida@gmail.com
> >wrote:
>
> > Hi
> >
> > Is there any way to disable/enable a MDB programmatically?
> >
> > Right now, it consumes from a JMS queue and the queue definitions are
> coded
> > using @ActivationConfigProperty. if I just set a flag in the database and
> > let the MDB check it before executing the onMessage() message, I guess
> I'd
> > have to re-enqueue the message. Instead, I'd like to just "pause" and
> > "restart" my MDBs, not touching the queue.
> >
> > or example, for tomee/activemq, is there something similar to this code
> for
> > jboss?
> >
> > MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
> >     ObjectName objName = new
> >
> >
> ObjectName("jboss.j2ee:ear=MessageGateway.ear,jar=MessageGateway-EJB.jar,name=MessageSenderMDB,service=EJB3");
> >     JMSContainerInvokerMBean invoker = (JMSContainerInvokerMBean)
> > MBeanProxy.get(JMSContainerInvokerMBean.class, objName, mbeanServer);
> >
> >     invoker.stop(); //Stop MDB
> >     invoker.start(); //Start MDB
> >
> > If I'd understood this well, the container consumes from the JMS queue
> > and then it sends to the MDB method.
> >
> >
> >
> > So I guess what I am really looking for is some activemq or tomee JMX
> > instruction (and how to call it from inside a webapp code) telling
> > tomee to pause/resume it's JMS consumer.
> >
> >
> >
> > TIA
> >
> > Leo
> >
>
>
>
> --
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta
>

Re: Disable/Enable MDB

Posted by Christian Posta <ch...@gmail.com>.
May want to ask this on the TomEE mailing list. I would think there would
be some JMX mbeans that can be used to start/stop a EJB/MDB


On Tue, Oct 8, 2013 at 9:49 AM, Leonardo K. Shikida <sh...@gmail.com>wrote:

> Hi
>
> Is there any way to disable/enable a MDB programmatically?
>
> Right now, it consumes from a JMS queue and the queue definitions are coded
> using @ActivationConfigProperty. if I just set a flag in the database and
> let the MDB check it before executing the onMessage() message, I guess I'd
> have to re-enqueue the message. Instead, I'd like to just "pause" and
> "restart" my MDBs, not touching the queue.
>
> or example, for tomee/activemq, is there something similar to this code for
> jboss?
>
> MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
>     ObjectName objName = new
>
> ObjectName("jboss.j2ee:ear=MessageGateway.ear,jar=MessageGateway-EJB.jar,name=MessageSenderMDB,service=EJB3");
>     JMSContainerInvokerMBean invoker = (JMSContainerInvokerMBean)
> MBeanProxy.get(JMSContainerInvokerMBean.class, objName, mbeanServer);
>
>     invoker.stop(); //Stop MDB
>     invoker.start(); //Start MDB
>
> If I'd understood this well, the container consumes from the JMS queue
> and then it sends to the MDB method.
>
>
>
> So I guess what I am really looking for is some activemq or tomee JMX
> instruction (and how to call it from inside a webapp code) telling
> tomee to pause/resume it's JMS consumer.
>
>
>
> TIA
>
> Leo
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Fwd: Disable/Enable MDB

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
Hi

Is there any way to disable/enable a MDB programmatically?

Right now, it consumes from a JMS queue and the queue definitions are coded
using @ActivationConfigProperty. if I just set a flag in the database and
let the MDB check it before executing the onMessage() message, I guess I'd
have to re-enqueue the message. Instead, I'd like to just "pause" and
"restart" my MDBs, not touching the queue.

or example, for tomee/activemq, is there something similar to this code for
jboss?

MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
    ObjectName objName = new
ObjectName("jboss.j2ee:ear=MessageGateway.ear,jar=MessageGateway-EJB.jar,name=MessageSenderMDB,service=EJB3");
    JMSContainerInvokerMBean invoker = (JMSContainerInvokerMBean)
MBeanProxy.get(JMSContainerInvokerMBean.class, objName, mbeanServer);

    invoker.stop(); //Stop MDB
    invoker.start(); //Start MDB

If I'd understood this well, the container consumes from the JMS queue
and then it sends to the MDB method.



So I guess what I am really looking for is some activemq or tomee JMX
instruction (and how to call it from inside a webapp code) telling
tomee to pause/resume it's JMS consumer.



TIA

Leo

Re: Disable/Enable MDB

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
Thx
Em 08/10/2013 17:30, "Romain Manni-Bucau" <rm...@gmail.com> escreveu:

>
> Systeminstance.get().getcomponent(containersystem.class).getbeancontext(ejbname).getcontainer()
> i think
> Le 8 oct. 2013 20:19, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :
>
> > Hi Romain
> >
> > where should I look first in the internals? :-)
> >
> > TIA
> >
> > Leo
> >
> >
> >
> >
> > []
> >
> > Leo
> >
> >
> > On Tue, Oct 8, 2013 at 2:15 PM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > >wrote:
> >
> > > Hi
> > >
> > > You can do it with our internals but it is risky for your app. Isnt it
> a
> > > design issue?
> > > Le 8 oct. 2013 18:48, "Leonardo K. Shikida" <sh...@gmail.com> a
> écrit
> > :
> > >
> > > > Hi
> > > >
> > > > Is there any way to disable/enable a MDB programmatically?
> > > >
> > > > Right now, it consumes from a JMS queue and the queue definitions are
> > > coded
> > > > using @ActivationConfigProperty. if I just set a flag in the database
> > and
> > > > let the MDB check it before executing the onMessage() message, I
> guess
> > > I'd
> > > > have to re-enqueue the message. Instead, I'd like to just "pause" and
> > > > "restart" my MDBs, not touching the queue.
> > > >
> > > > or example, for tomee/openjpa, is there something similar to this
> code
> > > for
> > > > jboss?
> > > >
> > > > MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
> > > >     ObjectName objName = new
> > > >
> > > >
> > >
> >
> ObjectName("jboss.j2ee:ear=MessageGateway.ear,jar=MessageGateway-EJB.jar,name=MessageSenderMDB,service=EJB3");
> > > >     JMSContainerInvokerMBean invoker = (JMSContainerInvokerMBean)
> > > > MBeanProxy.get(JMSContainerInvokerMBean.class, objName, mbeanServer);
> > > >
> > > >     invoker.stop(); //Stop MDB
> > > >     invoker.start(); //Start MDB
> > > >
> > > > If I'd understood this well, the container consumes from the JMS
> queue
> > > > and then it sends to the MDB method.
> > > >
> > > > So I guess what I am really looking for is some activemq or tomee JMX
> > > > instruction (and how to call it from inside a webapp code) telling
> > > > tomee to pause/resume it's JMS consumer.
> > > >
> > > >
> > > > TIA
> > > >
> > > > Leo
> > > >
> > >
> >
>

Re: Disable/Enable MDB

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Systeminstance.get().getcomponent(containersystem.class).getbeancontext(ejbname).getcontainer()
i think
Le 8 oct. 2013 20:19, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :

> Hi Romain
>
> where should I look first in the internals? :-)
>
> TIA
>
> Leo
>
>
>
>
> []
>
> Leo
>
>
> On Tue, Oct 8, 2013 at 2:15 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> >wrote:
>
> > Hi
> >
> > You can do it with our internals but it is risky for your app. Isnt it a
> > design issue?
> > Le 8 oct. 2013 18:48, "Leonardo K. Shikida" <sh...@gmail.com> a écrit
> :
> >
> > > Hi
> > >
> > > Is there any way to disable/enable a MDB programmatically?
> > >
> > > Right now, it consumes from a JMS queue and the queue definitions are
> > coded
> > > using @ActivationConfigProperty. if I just set a flag in the database
> and
> > > let the MDB check it before executing the onMessage() message, I guess
> > I'd
> > > have to re-enqueue the message. Instead, I'd like to just "pause" and
> > > "restart" my MDBs, not touching the queue.
> > >
> > > or example, for tomee/openjpa, is there something similar to this code
> > for
> > > jboss?
> > >
> > > MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
> > >     ObjectName objName = new
> > >
> > >
> >
> ObjectName("jboss.j2ee:ear=MessageGateway.ear,jar=MessageGateway-EJB.jar,name=MessageSenderMDB,service=EJB3");
> > >     JMSContainerInvokerMBean invoker = (JMSContainerInvokerMBean)
> > > MBeanProxy.get(JMSContainerInvokerMBean.class, objName, mbeanServer);
> > >
> > >     invoker.stop(); //Stop MDB
> > >     invoker.start(); //Start MDB
> > >
> > > If I'd understood this well, the container consumes from the JMS queue
> > > and then it sends to the MDB method.
> > >
> > > So I guess what I am really looking for is some activemq or tomee JMX
> > > instruction (and how to call it from inside a webapp code) telling
> > > tomee to pause/resume it's JMS consumer.
> > >
> > >
> > > TIA
> > >
> > > Leo
> > >
> >
>

Re: Disable/Enable MDB

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
Hi Romain

where should I look first in the internals? :-)

TIA

Leo




[]

Leo


On Tue, Oct 8, 2013 at 2:15 PM, Romain Manni-Bucau <rm...@gmail.com>wrote:

> Hi
>
> You can do it with our internals but it is risky for your app. Isnt it a
> design issue?
> Le 8 oct. 2013 18:48, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :
>
> > Hi
> >
> > Is there any way to disable/enable a MDB programmatically?
> >
> > Right now, it consumes from a JMS queue and the queue definitions are
> coded
> > using @ActivationConfigProperty. if I just set a flag in the database and
> > let the MDB check it before executing the onMessage() message, I guess
> I'd
> > have to re-enqueue the message. Instead, I'd like to just "pause" and
> > "restart" my MDBs, not touching the queue.
> >
> > or example, for tomee/openjpa, is there something similar to this code
> for
> > jboss?
> >
> > MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
> >     ObjectName objName = new
> >
> >
> ObjectName("jboss.j2ee:ear=MessageGateway.ear,jar=MessageGateway-EJB.jar,name=MessageSenderMDB,service=EJB3");
> >     JMSContainerInvokerMBean invoker = (JMSContainerInvokerMBean)
> > MBeanProxy.get(JMSContainerInvokerMBean.class, objName, mbeanServer);
> >
> >     invoker.stop(); //Stop MDB
> >     invoker.start(); //Start MDB
> >
> > If I'd understood this well, the container consumes from the JMS queue
> > and then it sends to the MDB method.
> >
> > So I guess what I am really looking for is some activemq or tomee JMX
> > instruction (and how to call it from inside a webapp code) telling
> > tomee to pause/resume it's JMS consumer.
> >
> >
> > TIA
> >
> > Leo
> >
>

Re: Disable/Enable MDB

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

You can do it with our internals but it is risky for your app. Isnt it a
design issue?
Le 8 oct. 2013 18:48, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :

> Hi
>
> Is there any way to disable/enable a MDB programmatically?
>
> Right now, it consumes from a JMS queue and the queue definitions are coded
> using @ActivationConfigProperty. if I just set a flag in the database and
> let the MDB check it before executing the onMessage() message, I guess I'd
> have to re-enqueue the message. Instead, I'd like to just "pause" and
> "restart" my MDBs, not touching the queue.
>
> or example, for tomee/openjpa, is there something similar to this code for
> jboss?
>
> MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
>     ObjectName objName = new
>
> ObjectName("jboss.j2ee:ear=MessageGateway.ear,jar=MessageGateway-EJB.jar,name=MessageSenderMDB,service=EJB3");
>     JMSContainerInvokerMBean invoker = (JMSContainerInvokerMBean)
> MBeanProxy.get(JMSContainerInvokerMBean.class, objName, mbeanServer);
>
>     invoker.stop(); //Stop MDB
>     invoker.start(); //Start MDB
>
> If I'd understood this well, the container consumes from the JMS queue
> and then it sends to the MDB method.
>
> So I guess what I am really looking for is some activemq or tomee JMX
> instruction (and how to call it from inside a webapp code) telling
> tomee to pause/resume it's JMS consumer.
>
>
> TIA
>
> Leo
>