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 2015/04/07 16:24:13 UTC

Stopping a bean context

Hi

I am trying to control a specific MDB using TomEE internals like this

        SystemInstance inst = SystemInstance.get();
        ContainerSystem container =
inst.getComponent(ContainerSystem.class);
        Container ctn = container.getContainer("msg");

        BeanContext myBeanContext = null;
        BeanContext[] deployments = container.deployments();
        for(BeanContext d:deployments) {
            if (d.getId().equals("myMDBName")) {
                myBeanContext = d;
                break;
            }
        }

        try {
            ctn.stop(myBeanContext);
        }catch(Exception e) {
            e.printStackTrace();
        }

But when I enqueue a new JMS message, the MDB is still consuming it.

Am I missing something here?

No exception is raised, could not find any javadoc explaining.

TIA

Leo

Re: Stopping a bean context

Posted by Romain Manni-Bucau <rm...@gmail.com>.
You can get it injected with @Resource. But yes it is done for all
listeners. Otherwise just reroute messages to somewhere else.
 Le 7 avr. 2015 19:17, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :

> Nice
>
> and how do I access it? It's not a container, it's a resource
>
> and is there any way to access only the consumer from the right MDB? I
> don't want to stop all MDBs.
>
> []
>
> Leo
>
> On Tue, Apr 7, 2015 at 12:28 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > ActiveMQResourceAdapter surely then digging in amq sessions
> > Le 7 avr. 2015 17:16, "Leonardo K. Shikida" <sh...@gmail.com> a écrit
> :
> >
> > > sounds like a good idea.
> > >
> > > from what class should I start to do that?
> > >
> > > []
> > >
> > > Leo
> > >
> > > On Tue, Apr 7, 2015 at 12:08 PM, Romain Manni-Bucau <
> > rmannibucau@gmail.com
> > > >
> > > wrote:
> > >
> > > > You dont want to stop the mdb but the amq listener no? Check amq
> > > > resourceadapter rather than openejb internals maybe
> > > > Le 7 avr. 2015 16:26, "Leonardo K. Shikida" <sh...@gmail.com> a
> > écrit
> > > :
> > > >
> > > > > Hi
> > > > >
> > > > > I am trying to control a specific MDB using TomEE internals like
> this
> > > > >
> > > > >         SystemInstance inst = SystemInstance.get();
> > > > >         ContainerSystem container =
> > > > > inst.getComponent(ContainerSystem.class);
> > > > >         Container ctn = container.getContainer("msg");
> > > > >
> > > > >         BeanContext myBeanContext = null;
> > > > >         BeanContext[] deployments = container.deployments();
> > > > >         for(BeanContext d:deployments) {
> > > > >             if (d.getId().equals("myMDBName")) {
> > > > >                 myBeanContext = d;
> > > > >                 break;
> > > > >             }
> > > > >         }
> > > > >
> > > > >         try {
> > > > >             ctn.stop(myBeanContext);
> > > > >         }catch(Exception e) {
> > > > >             e.printStackTrace();
> > > > >         }
> > > > >
> > > > > But when I enqueue a new JMS message, the MDB is still consuming
> it.
> > > > >
> > > > > Am I missing something here?
> > > > >
> > > > > No exception is raised, could not find any javadoc explaining.
> > > > >
> > > > > TIA
> > > > >
> > > > > Leo
> > > > >
> > > >
> > >
> >
>

Re: Stopping a bean context

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

and how do I access it? It's not a container, it's a resource

and is there any way to access only the consumer from the right MDB? I
don't want to stop all MDBs.

[]

Leo

On Tue, Apr 7, 2015 at 12:28 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> ActiveMQResourceAdapter surely then digging in amq sessions
> Le 7 avr. 2015 17:16, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :
>
> > sounds like a good idea.
> >
> > from what class should I start to do that?
> >
> > []
> >
> > Leo
> >
> > On Tue, Apr 7, 2015 at 12:08 PM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > >
> > wrote:
> >
> > > You dont want to stop the mdb but the amq listener no? Check amq
> > > resourceadapter rather than openejb internals maybe
> > > Le 7 avr. 2015 16:26, "Leonardo K. Shikida" <sh...@gmail.com> a
> écrit
> > :
> > >
> > > > Hi
> > > >
> > > > I am trying to control a specific MDB using TomEE internals like this
> > > >
> > > >         SystemInstance inst = SystemInstance.get();
> > > >         ContainerSystem container =
> > > > inst.getComponent(ContainerSystem.class);
> > > >         Container ctn = container.getContainer("msg");
> > > >
> > > >         BeanContext myBeanContext = null;
> > > >         BeanContext[] deployments = container.deployments();
> > > >         for(BeanContext d:deployments) {
> > > >             if (d.getId().equals("myMDBName")) {
> > > >                 myBeanContext = d;
> > > >                 break;
> > > >             }
> > > >         }
> > > >
> > > >         try {
> > > >             ctn.stop(myBeanContext);
> > > >         }catch(Exception e) {
> > > >             e.printStackTrace();
> > > >         }
> > > >
> > > > But when I enqueue a new JMS message, the MDB is still consuming it.
> > > >
> > > > Am I missing something here?
> > > >
> > > > No exception is raised, could not find any javadoc explaining.
> > > >
> > > > TIA
> > > >
> > > > Leo
> > > >
> > >
> >
>

Re: Stopping a bean context

Posted by Romain Manni-Bucau <rm...@gmail.com>.
ActiveMQResourceAdapter surely then digging in amq sessions
Le 7 avr. 2015 17:16, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :

> sounds like a good idea.
>
> from what class should I start to do that?
>
> []
>
> Leo
>
> On Tue, Apr 7, 2015 at 12:08 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > You dont want to stop the mdb but the amq listener no? Check amq
> > resourceadapter rather than openejb internals maybe
> > Le 7 avr. 2015 16:26, "Leonardo K. Shikida" <sh...@gmail.com> a écrit
> :
> >
> > > Hi
> > >
> > > I am trying to control a specific MDB using TomEE internals like this
> > >
> > >         SystemInstance inst = SystemInstance.get();
> > >         ContainerSystem container =
> > > inst.getComponent(ContainerSystem.class);
> > >         Container ctn = container.getContainer("msg");
> > >
> > >         BeanContext myBeanContext = null;
> > >         BeanContext[] deployments = container.deployments();
> > >         for(BeanContext d:deployments) {
> > >             if (d.getId().equals("myMDBName")) {
> > >                 myBeanContext = d;
> > >                 break;
> > >             }
> > >         }
> > >
> > >         try {
> > >             ctn.stop(myBeanContext);
> > >         }catch(Exception e) {
> > >             e.printStackTrace();
> > >         }
> > >
> > > But when I enqueue a new JMS message, the MDB is still consuming it.
> > >
> > > Am I missing something here?
> > >
> > > No exception is raised, could not find any javadoc explaining.
> > >
> > > TIA
> > >
> > > Leo
> > >
> >
>

Re: Stopping a bean context

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
sounds like a good idea.

from what class should I start to do that?

[]

Leo

On Tue, Apr 7, 2015 at 12:08 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> You dont want to stop the mdb but the amq listener no? Check amq
> resourceadapter rather than openejb internals maybe
> Le 7 avr. 2015 16:26, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :
>
> > Hi
> >
> > I am trying to control a specific MDB using TomEE internals like this
> >
> >         SystemInstance inst = SystemInstance.get();
> >         ContainerSystem container =
> > inst.getComponent(ContainerSystem.class);
> >         Container ctn = container.getContainer("msg");
> >
> >         BeanContext myBeanContext = null;
> >         BeanContext[] deployments = container.deployments();
> >         for(BeanContext d:deployments) {
> >             if (d.getId().equals("myMDBName")) {
> >                 myBeanContext = d;
> >                 break;
> >             }
> >         }
> >
> >         try {
> >             ctn.stop(myBeanContext);
> >         }catch(Exception e) {
> >             e.printStackTrace();
> >         }
> >
> > But when I enqueue a new JMS message, the MDB is still consuming it.
> >
> > Am I missing something here?
> >
> > No exception is raised, could not find any javadoc explaining.
> >
> > TIA
> >
> > Leo
> >
>

Re: Stopping a bean context

Posted by Romain Manni-Bucau <rm...@gmail.com>.
You dont want to stop the mdb but the amq listener no? Check amq
resourceadapter rather than openejb internals maybe
Le 7 avr. 2015 16:26, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :

> Hi
>
> I am trying to control a specific MDB using TomEE internals like this
>
>         SystemInstance inst = SystemInstance.get();
>         ContainerSystem container =
> inst.getComponent(ContainerSystem.class);
>         Container ctn = container.getContainer("msg");
>
>         BeanContext myBeanContext = null;
>         BeanContext[] deployments = container.deployments();
>         for(BeanContext d:deployments) {
>             if (d.getId().equals("myMDBName")) {
>                 myBeanContext = d;
>                 break;
>             }
>         }
>
>         try {
>             ctn.stop(myBeanContext);
>         }catch(Exception e) {
>             e.printStackTrace();
>         }
>
> But when I enqueue a new JMS message, the MDB is still consuming it.
>
> Am I missing something here?
>
> No exception is raised, could not find any javadoc explaining.
>
> TIA
>
> Leo
>