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/14 19:38:50 UTC

MDB transaction timeout

Hi

How do I increase the MDB onMessage() transaction timeout?

[]

Leo

Re: MDB transaction timeout

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
thanks a lot :-)

gonna try this approach right now

you rock man

[]

Leo

On Wed, Apr 15, 2015 at 10:12 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> this is the default yes
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-15 15:09 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>
> > then the message will be acknowledged on userTransaction.commit() right?
> >
> > do I have to also use
> >
> > PersistenceContextType.TRANSACTION
> >
> > for the injected entity manager? (as showed at
> >
> http://tomee.apache.org/examples-trunk/testing-transactions-bmt/README.html
> > )
> >
> >
> >
> >
> > []
> >
> > Leo
> >
> > On Wed, Apr 15, 2015 at 10:04 AM, Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > wrote:
> >
> > > @javax.ejb.TransactionManagement(BEAN), then @TransactionAttribute will
> > get
> > > ignored.
> > >
> > > You can inject with ÀResource userTransaction ut the "transaction
> facade"
> > > you can use
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-04-15 14:39 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > >
> > > > yup :-)
> > > >
> > > > do I have to explicitly use
> > > >
> > > > @TransactionAttribute(TransactionAttributeType.REQUIRED)
> > > >
> > > > or change
> > > >
> > > > @ActivationConfigProperty(propertyName = "acknowledgeMode",
> > > > propertyValue = "Auto-acknowledge")
> > > >
> > > > to client in order to do that?
> > > >
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > > > On Wed, Apr 15, 2015 at 9:22 AM, Romain Manni-Bucau <
> > > rmannibucau@gmail.com
> > > > >
> > > > wrote:
> > > >
> > > > > well transaction timeout = exception + rollback if transaction took
> > > more
> > > > > than X but the execution time is still the real one.
> > > > >
> > > > > you can do using bean managed transactions:
> > > > >
> > > > > Exception oops = null;
> > > > > try {
> > > > >   userTransaction.begin();
> > > > > } cath (Exception e) {
> > > > >   oops = e;
> > > > > } finally { // add the logic you want here
> > > > >   if (oops == null) {
> > > > >     userTransaction.commit();
> > > > >     return;
> > > > >   }
> > > > >
> > > > >   userTransaction.rollback();
> > > > > }
> > > > >
> > > > > It doesnt match your need?
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-04-15 14:15 GMT+02:00 Leonardo K. Shikida <shikida@gmail.com
> >:
> > > > >
> > > > > > If there's an external event to the MDB like a timeout (which
> > > > exception I
> > > > > > cannot catch), then it should have something like a @Timeout
> > > annotation
> > > > > so
> > > > > > I could customize how the event could be handled.
> > > > > >
> > > > > > Not tomee's problem of course, tomee just implements a standard.
> > > > > >
> > > > > > :-(
> > > > > >
> > > > > > Gonna think on something else here.
> > > > > >
> > > > > >
> > > > > > []
> > > > > >
> > > > > > Leo
> > > > > >
> > > > > > On Wed, Apr 15, 2015 at 4:21 AM, Romain Manni-Bucau <
> > > > > rmannibucau@gmail.com
> > > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > hmm, my proposal was to use UserTransaction more than that.
> About
> > > > this
> > > > > > > particular exemple we would need a maven project to reproduce
> it.
> > > > > > >
> > > > > > >
> > > > > > > Romain Manni-Bucau
> > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > https://github.com/rmannibucau> |
> > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > > <http://www.tomitribe.com>
> > > > > > >
> > > > > > > 2015-04-15 4:05 GMT+02:00 Leonardo K. Shikida <
> shikida@gmail.com
> > >:
> > > > > > >
> > > > > > > > Hi
> > > > > > > >
> > > > > > > > So I've changed my MDBs to stateless
> > > > > > > >
> > > > > > > > public class Worker implements MessageListener {
> > > > > > > >
> > > > > > > >     @Resource(name="MyJmsConnectionFactory")
> > > > > > > >     private ConnectionFactory connectionFactory;
> > > > > > > >
> > > > > > > >     @Resource(name="DriverJobQueue")
> > > > > > > >     private Queue queue;
> > > > > > > >
> > > > > > > >     private Connection connection = null;
> > > > > > > >     private Session session = null;
> > > > > > > >     private MessageConsumer consumer = null;
> > > > > > > >
> > > > > > > >     @PostConstruct
> > > > > > > >     public void initialize() {
> > > > > > > >         System.out.println("Instantiating "+this);
> > > > > > > >         try {
> > > > > > > >             connection =
> connectionFactory.createConnection();
> > > > > > > >             connection.start(); //activemq site says it's
> here
> > > > > > > >             // Create a Session
> > > > > > > >             session = connection.createSession(false,
> > > > > > > > Session.AUTO_ACKNOWLEDGE);
> > > > > > > >
> > > > > > > >             // Create a MessageConsumer from the Session to
> the
> > > > Topic
> > > > > > or
> > > > > > > > Queue
> > > > > > > >             consumer = session.createConsumer(this.queue);
> > > > > > > >
> > > > > > > >             consumer.setMessageListener(this);
> > > > > > > >
> > > > > > > > //            connection.start(); //some sites says it's here
> > > > > > > >
> > > > > > > >         } catch(Exception e) {
> > > > > > > >             e.printStackTrace();
> > > > > > > >         } finally {
> > > > > > > >             if (consumer != null) {
> > > > > > > >                 try {
> > > > > > > >                     consumer.close();
> > > > > > > >                 } catch (JMSException e) {
> > > > > > > >                     e.printStackTrace();
> > > > > > > >                 }
> > > > > > > >             }
> > > > > > > >             if (session != null) {
> > > > > > > >                 try {
> > > > > > > >                     session.close();
> > > > > > > >                 } catch (JMSException e) {
> > > > > > > >                     e.printStackTrace();
> > > > > > > >                 }
> > > > > > > >             }
> > > > > > > >             if (connection != null) {
> > > > > > > >                 try {
> > > > > > > >                     connection.close();
> > > > > > > >                 } catch (JMSException e) {
> > > > > > > >                     e.printStackTrace();
> > > > > > > >                 }
> > > > > > > >             }
> > > > > > > >         }
> > > > > > > >     }
> > > > > > > >
> > > > > > > >     @Override
> > > > > > > >     public void onMessage(Message msg) {
> > > > > > > >         System.out.println("On message for "+this);
> > > > > > > >     }
> > > > > > > >
> > > > > > > > openejb-jar.xml
> > > > > > > >
> > > > > > > > <?xml version="1.0"?>
> > > > > > > > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
> > > > > > > >     <ejb-deployment
> > > > > > > >         ejb-name="Worker"
> > > > > > > >         deployment-id="Worker"
> > > > > > > >         container-id="pseudo_mdb" />
> > > > > > > > </openejb-jar>
> > > > > > > >
> > > > > > > > tomee.xml
> > > > > > > >
> > > > > > > >     <Container id="myAllContainer" type="STATELESS">
> > > > > > > >     strictPooling = false
> > > > > > > >     </Container>
> > > > > > > >
> > > > > > > >     <Container id="pseudo_mdb" type="STATELESS">
> > > > > > > >     strictPooling = true
> > > > > > > >     maxSize = 5
> > > > > > > >     minSize = 3
> > > > > > > >     </Container>
> > > > > > > >
> > > > > > > > The container part seems to be right, since only the Worker
> > bean
> > > is
> > > > > > > > instantiated early.
> > > > > > > >
> > > > > > > > But for some reason, it's not consuming from the queue.
> > > > > > > >
> > > > > > > > Am I missing something here?
> > > > > > > >
> > > > > > > > Still, I feel I am running in circles here... because even
> if I
> > > > have
> > > > > > some
> > > > > > > > control on the context, I still won't be able to catch the
> > > timeout
> > > > > > > > exception :-(
> > > > > > > >
> > > > > > > > grrrrrrrrrrrr
> > > > > > > >
> > > > > > > > []
> > > > > > > >
> > > > > > > > Leo
> > > > > > > >
> > > > > > > > On Tue, Apr 14, 2015 at 6:08 PM, Leonardo K. Shikida <
> > > > > > shikida@gmail.com>
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > thx!
> > > > > > > > >
> > > > > > > > > []
> > > > > > > > >
> > > > > > > > > Leo
> > > > > > > > >
> > > > > > > > > On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <
> > > > > > > > rmannibucau@gmail.com
> > > > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > >> using openejb-jar.xml you can wire a container to some
> beans
> > > > only.
> > > > > > > > >>
> > > > > > > > >>
> > > > > > > > >> Romain Manni-Bucau
> > > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > >> https://github.com/rmannibucau> |
> > > > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > Tomitriber
> > > > > > > > >> <http://www.tomitribe.com>
> > > > > > > > >>
> > > > > > > > >> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <
> > > > shikida@gmail.com
> > > > > >:
> > > > > > > > >>
> > > > > > > > >> > yeah, I think this will be the way to go
> > > > > > > > >> >
> > > > > > > > >> > since I can configure max/min instances for stateless (
> > > > > > > > >> > http://tomee.apache.org/statelesscontainer-config.html)
> I
> > > > > think I
> > > > > > > can
> > > > > > > > >> just
> > > > > > > > >> > create a pool of stateless instances to work as MDBs
> that
> > > can
> > > > > deal
> > > > > > > > with
> > > > > > > > >> > timeout :-)
> > > > > > > > >> >
> > > > > > > > >> > is there any way to configure a container just for these
> > > > specfic
> > > > > > > > >> stateless
> > > > > > > > >> > EJBs (so some other configuration can be used for
> > stateless
> > > by
> > > > > > > > default)?
> > > > > > > > >> >
> > > > > > > > >> > []
> > > > > > > > >> >
> > > > > > > > >> > Leo
> > > > > > > > >> >
> > > > > > > > >> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
> > > > > > > > >> rmannibucau@gmail.com
> > > > > > > > >> > >
> > > > > > > > >> > wrote:
> > > > > > > > >> >
> > > > > > > > >> > > so just handle transactions yourself
> > > > > > > > >> > >
> > > > > > > > >> > >
> > > > > > > > >> > > Romain Manni-Bucau
> > > > > > > > >> > > @rmannibucau <https://twitter.com/rmannibucau> |
> Blog
> > > > > > > > >> > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > >> > > https://github.com/rmannibucau> |
> > > > > > > > >> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > > Tomitriber
> > > > > > > > >> > > <http://www.tomitribe.com>
> > > > > > > > >> > >
> > > > > > > > >> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <
> > > > > > > > itsmeden@gmail.com
> > > > > > > > >> >:
> > > > > > > > >> > >
> > > > > > > > >> > > > Another option is to look at the redelivered
> > > > > > property/redelivery
> > > > > > > > >> count
> > > > > > > > >> > > and
> > > > > > > > >> > > > take action (write to db?) in case of redelivery....
> > > > > requires
> > > > > > > you
> > > > > > > > >> to
> > > > > > > > >> > > set a
> > > > > > > > >> > > > redelivery policy / number of retries etc
> > > > > > > > >> > > >
> > > > > > > > >> > > > /LF
> > > > > > > > >> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <
> > > > > > > > shikida@gmail.com>
> > > > > > > > >> > > wrote:
> > > > > > > > >> > > >
> > > > > > > > >> > > > > Yup, but if the MDB timeout, I need to set
> something
> > > in
> > > > > the
> > > > > > > DB,
> > > > > > > > >> > that's
> > > > > > > > >> > > > why
> > > > > > > > >> > > > > I need to treat the timeout.
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > If the job to be executed timeout, then it will
> > > probably
> > > > > > > timeout
> > > > > > > > >> for
> > > > > > > > >> > > any
> > > > > > > > >> > > > > retry, because it's caused by a poorly chosen
> > > parameter,
> > > > > so
> > > > > > > > >> retries
> > > > > > > > >> > are
> > > > > > > > >> > > > not
> > > > > > > > >> > > > > important here (although increasing timeouts on
> each
> > > > retry
> > > > > > > could
> > > > > > > > >> be
> > > > > > > > >> > an
> > > > > > > > >> > > > > interesting option)
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > []
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > Leo
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain
> Manni-Bucau
> > <
> > > > > > > > >> > > > rmannibucau@gmail.com
> > > > > > > > >> > > > > >
> > > > > > > > >> > > > > wrote:
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > > Hmm, with MDBs you have retries since they are
> > > > > > > transactional.
> > > > > > > > >> you
> > > > > > > > >> > can
> > > > > > > > >> > > > > even
> > > > > > > > >> > > > > > configure the redelivery policy with an
> > exponential
> > > > > > backoff
> > > > > > > > and
> > > > > > > > >> so
> > > > > > > > >> > on
> > > > > > > > >> > > > if
> > > > > > > > >> > > > > > really needed
> > > > > > > > >> > > > > >
> > > > > > > > >> > > > > >
> > > > > > > > >> > > > > > Romain Manni-Bucau
> > > > > > > > >> > > > > > @rmannibucau <https://twitter.com/rmannibucau>
> |
> > > > Blog
> > > > > > > > >> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > >> > > > > > https://github.com/rmannibucau> |
> > > > > > > > >> > > > > > LinkedIn <
> https://www.linkedin.com/in/rmannibucau
> > >
> > > |
> > > > > > > > Tomitriber
> > > > > > > > >> > > > > > <http://www.tomitribe.com>
> > > > > > > > >> > > > > >
> > > > > > > > >> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
> > > > > > > > >> shikida@gmail.com
> > > > > > > > >> > >:
> > > > > > > > >> > > > > >
> > > > > > > > >> > > > > > > Well, what I need is a pool of workers to
> listen
> > > to
> > > > a
> > > > > > > queue
> > > > > > > > >> and
> > > > > > > > >> > > > process
> > > > > > > > >> > > > > > > messages while they come, but I also need to
> > > > properly
> > > > > > > treat
> > > > > > > > >> them
> > > > > > > > >> > > when
> > > > > > > > >> > > > > the
> > > > > > > > >> > > > > > > JMS transaction times out.
> > > > > > > > >> > > > > > >
> > > > > > > > >> > > > > > > So I guess I can't use a MDB here right?
> > > > > > > > >> > > > > > >
> > > > > > > > >> > > > > > > What would be a good approach in this
> situation?
> > > > > > > > >> > > > > > >
> > > > > > > > >> > > > > > > []
> > > > > > > > >> > > > > > >
> > > > > > > > >> > > > > > > Leo
> > > > > > > > >> > > > > > >
> > > > > > > > >> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain
> > > Manni-Bucau
> > > > <
> > > > > > > > >> > > > > > rmannibucau@gmail.com
> > > > > > > > >> > > > > > > >
> > > > > > > > >> > > > > > > wrote:
> > > > > > > > >> > > > > > >
> > > > > > > > >> > > > > > > > if you want to control and be able to catch
> it
> > > you
> > > > > > need
> > > > > > > to
> > > > > > > > >> > handle
> > > > > > > > >> > > > > > > yourself
> > > > > > > > >> > > > > > > > the transaction otherwise if it takes more
> > then
> > > > > you'll
> > > > > > > > get a
> > > > > > > > >> > > > rollback
> > > > > > > > >> > > > > > > and a
> > > > > > > > >> > > > > > > > (surely wrapped) RollbackException
> > > > > > > > >> > > > > > > >
> > > > > > > > >> > > > > > > >
> > > > > > > > >> > > > > > > > Romain Manni-Bucau
> > > > > > > > >> > > > > > > > @rmannibucau <
> https://twitter.com/rmannibucau
> > >
> > > |
> > > > > > Blog
> > > > > > > > >> > > > > > > > <http://rmannibucau.wordpress.com> |
> Github <
> > > > > > > > >> > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > >> > > > > > > > LinkedIn <
> > > https://www.linkedin.com/in/rmannibucau
> > > > >
> > > > > |
> > > > > > > > >> > Tomitriber
> > > > > > > > >> > > > > > > > <http://www.tomitribe.com>
> > > > > > > > >> > > > > > > >
> > > > > > > > >> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K.
> > Shikida <
> > > > > > > > >> > > shikida@gmail.com
> > > > > > > > >> > > > >:
> > > > > > > > >> > > > > > > >
> > > > > > > > >> > > > > > > > > just checking
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > > I just add
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > >     @Resource
> > > > > > > > >> > > > > > > > >     private TransactionManager tx;
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > > and in the MDB initialization I set some
> > > timeout
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > >     @PostConstruct
> > > > > > > > >> > > > > > > > >     public void initialize() {
> > > > > > > > >> > > > > > > > >         try {
> > > > > > > > >> > > > > > > > >             tx.setTransactionTimeout(3);
> > > > > > > > >> > > > > > > > >         } catch (SystemException e) {
> > > > > > > > >> > > > > > > > >             e.printStackTrace();
> > > > > > > > >> > > > > > > > >         }
> > > > > > > > >> > > > > > > > >     }
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > > and when my onMessage() executes, if it
> > takes
> > > > more
> > > > > > > than
> > > > > > > > 3
> > > > > > > > >> > > seconds
> > > > > > > > >> > > > > to
> > > > > > > > >> > > > > > > > > complete, it throws and exception?
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > > and if so, how do I catch it? (or I
> don't?)
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > > []
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > > Leo
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo
> K.
> > > > > > Shikida <
> > > > > > > > >> > > > > > > shikida@gmail.com>
> > > > > > > > >> > > > > > > > > wrote:
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > > > > thx!
> > > > > > > > >> > > > > > > > > >
> > > > > > > > >> > > > > > > > > > []
> > > > > > > > >> > > > > > > > > >
> > > > > > > > >> > > > > > > > > > Leo
> > > > > > > > >> > > > > > > > > >
> > > > > > > > >> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain
> > > > > > Manni-Bucau
> > > > > > > <
> > > > > > > > >> > > > > > > > > rmannibucau@gmail.com
> > > > > > > > >> > > > > > > > > > > wrote:
> > > > > > > > >> > > > > > > > > >
> > > > > > > > >> > > > > > > > > >> Get the Transactionmanager injected
> > > > (@Resource)
> > > > > > and
> > > > > > > > >> call
> > > > > > > > >> > > > > > > > > >> setTransactionTimeout(seconds)
> > > > > > > > >> > > > > > > > > >>
> > > > > > > > >> > > > > > > > > >>
> > > > > > > > >> > > > > > > > > >> Romain Manni-Bucau
> > > > > > > > >> > > > > > > > > >> @rmannibucau <
> > > > https://twitter.com/rmannibucau>
> > > > > |
> > > > > > > > Blog
> > > > > > > > >> > > > > > > > > >> <http://rmannibucau.wordpress.com> |
> > > Github
> > > > <
> > > > > > > > >> > > > > > > > > >> https://github.com/rmannibucau> |
> > > > > > > > >> > > > > > > > > >> LinkedIn <
> > > > > > https://www.linkedin.com/in/rmannibucau>
> > > > > > > |
> > > > > > > > >> > > > Tomitriber
> > > > > > > > >> > > > > > > > > >> <http://www.tomitribe.com>
> > > > > > > > >> > > > > > > > > >>
> > > > > > > > >> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K.
> > > > Shikida
> > > > > <
> > > > > > > > >> > > > > shikida@gmail.com
> > > > > > > > >> > > > > > >:
> > > > > > > > >> > > > > > > > > >>
> > > > > > > > >> > > > > > > > > >> > Hi
> > > > > > > > >> > > > > > > > > >> >
> > > > > > > > >> > > > > > > > > >> > How do I increase the MDB onMessage()
> > > > > > transaction
> > > > > > > > >> > timeout?
> > > > > > > > >> > > > > > > > > >> >
> > > > > > > > >> > > > > > > > > >> > []
> > > > > > > > >> > > > > > > > > >> >
> > > > > > > > >> > > > > > > > > >> > Leo
> > > > > > > > >> > > > > > > > > >> >
> > > > > > > > >> > > > > > > > > >>
> > > > > > > > >> > > > > > > > > >
> > > > > > > > >> > > > > > > > > >
> > > > > > > > >> > > > > > > > >
> > > > > > > > >> > > > > > > >
> > > > > > > > >> > > > > > >
> > > > > > > > >> > > > > >
> > > > > > > > >> > > > >
> > > > > > > > >> > > >
> > > > > > > > >> > >
> > > > > > > > >> >
> > > > > > > > >>
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by Romain Manni-Bucau <rm...@gmail.com>.
this is the default yes


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-15 15:09 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:

> then the message will be acknowledged on userTransaction.commit() right?
>
> do I have to also use
>
> PersistenceContextType.TRANSACTION
>
> for the injected entity manager? (as showed at
> http://tomee.apache.org/examples-trunk/testing-transactions-bmt/README.html
> )
>
>
>
>
> []
>
> Leo
>
> On Wed, Apr 15, 2015 at 10:04 AM, Romain Manni-Bucau <
> rmannibucau@gmail.com>
> wrote:
>
> > @javax.ejb.TransactionManagement(BEAN), then @TransactionAttribute will
> get
> > ignored.
> >
> > You can inject with ÀResource userTransaction ut the "transaction facade"
> > you can use
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-04-15 14:39 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> >
> > > yup :-)
> > >
> > > do I have to explicitly use
> > >
> > > @TransactionAttribute(TransactionAttributeType.REQUIRED)
> > >
> > > or change
> > >
> > > @ActivationConfigProperty(propertyName = "acknowledgeMode",
> > > propertyValue = "Auto-acknowledge")
> > >
> > > to client in order to do that?
> > >
> > >
> > > []
> > >
> > > Leo
> > >
> > > On Wed, Apr 15, 2015 at 9:22 AM, Romain Manni-Bucau <
> > rmannibucau@gmail.com
> > > >
> > > wrote:
> > >
> > > > well transaction timeout = exception + rollback if transaction took
> > more
> > > > than X but the execution time is still the real one.
> > > >
> > > > you can do using bean managed transactions:
> > > >
> > > > Exception oops = null;
> > > > try {
> > > >   userTransaction.begin();
> > > > } cath (Exception e) {
> > > >   oops = e;
> > > > } finally { // add the logic you want here
> > > >   if (oops == null) {
> > > >     userTransaction.commit();
> > > >     return;
> > > >   }
> > > >
> > > >   userTransaction.rollback();
> > > > }
> > > >
> > > > It doesnt match your need?
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-04-15 14:15 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > > >
> > > > > If there's an external event to the MDB like a timeout (which
> > > exception I
> > > > > cannot catch), then it should have something like a @Timeout
> > annotation
> > > > so
> > > > > I could customize how the event could be handled.
> > > > >
> > > > > Not tomee's problem of course, tomee just implements a standard.
> > > > >
> > > > > :-(
> > > > >
> > > > > Gonna think on something else here.
> > > > >
> > > > >
> > > > > []
> > > > >
> > > > > Leo
> > > > >
> > > > > On Wed, Apr 15, 2015 at 4:21 AM, Romain Manni-Bucau <
> > > > rmannibucau@gmail.com
> > > > > >
> > > > > wrote:
> > > > >
> > > > > > hmm, my proposal was to use UserTransaction more than that. About
> > > this
> > > > > > particular exemple we would need a maven project to reproduce it.
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-04-15 4:05 GMT+02:00 Leonardo K. Shikida <shikida@gmail.com
> >:
> > > > > >
> > > > > > > Hi
> > > > > > >
> > > > > > > So I've changed my MDBs to stateless
> > > > > > >
> > > > > > > public class Worker implements MessageListener {
> > > > > > >
> > > > > > >     @Resource(name="MyJmsConnectionFactory")
> > > > > > >     private ConnectionFactory connectionFactory;
> > > > > > >
> > > > > > >     @Resource(name="DriverJobQueue")
> > > > > > >     private Queue queue;
> > > > > > >
> > > > > > >     private Connection connection = null;
> > > > > > >     private Session session = null;
> > > > > > >     private MessageConsumer consumer = null;
> > > > > > >
> > > > > > >     @PostConstruct
> > > > > > >     public void initialize() {
> > > > > > >         System.out.println("Instantiating "+this);
> > > > > > >         try {
> > > > > > >             connection = connectionFactory.createConnection();
> > > > > > >             connection.start(); //activemq site says it's here
> > > > > > >             // Create a Session
> > > > > > >             session = connection.createSession(false,
> > > > > > > Session.AUTO_ACKNOWLEDGE);
> > > > > > >
> > > > > > >             // Create a MessageConsumer from the Session to the
> > > Topic
> > > > > or
> > > > > > > Queue
> > > > > > >             consumer = session.createConsumer(this.queue);
> > > > > > >
> > > > > > >             consumer.setMessageListener(this);
> > > > > > >
> > > > > > > //            connection.start(); //some sites says it's here
> > > > > > >
> > > > > > >         } catch(Exception e) {
> > > > > > >             e.printStackTrace();
> > > > > > >         } finally {
> > > > > > >             if (consumer != null) {
> > > > > > >                 try {
> > > > > > >                     consumer.close();
> > > > > > >                 } catch (JMSException e) {
> > > > > > >                     e.printStackTrace();
> > > > > > >                 }
> > > > > > >             }
> > > > > > >             if (session != null) {
> > > > > > >                 try {
> > > > > > >                     session.close();
> > > > > > >                 } catch (JMSException e) {
> > > > > > >                     e.printStackTrace();
> > > > > > >                 }
> > > > > > >             }
> > > > > > >             if (connection != null) {
> > > > > > >                 try {
> > > > > > >                     connection.close();
> > > > > > >                 } catch (JMSException e) {
> > > > > > >                     e.printStackTrace();
> > > > > > >                 }
> > > > > > >             }
> > > > > > >         }
> > > > > > >     }
> > > > > > >
> > > > > > >     @Override
> > > > > > >     public void onMessage(Message msg) {
> > > > > > >         System.out.println("On message for "+this);
> > > > > > >     }
> > > > > > >
> > > > > > > openejb-jar.xml
> > > > > > >
> > > > > > > <?xml version="1.0"?>
> > > > > > > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
> > > > > > >     <ejb-deployment
> > > > > > >         ejb-name="Worker"
> > > > > > >         deployment-id="Worker"
> > > > > > >         container-id="pseudo_mdb" />
> > > > > > > </openejb-jar>
> > > > > > >
> > > > > > > tomee.xml
> > > > > > >
> > > > > > >     <Container id="myAllContainer" type="STATELESS">
> > > > > > >     strictPooling = false
> > > > > > >     </Container>
> > > > > > >
> > > > > > >     <Container id="pseudo_mdb" type="STATELESS">
> > > > > > >     strictPooling = true
> > > > > > >     maxSize = 5
> > > > > > >     minSize = 3
> > > > > > >     </Container>
> > > > > > >
> > > > > > > The container part seems to be right, since only the Worker
> bean
> > is
> > > > > > > instantiated early.
> > > > > > >
> > > > > > > But for some reason, it's not consuming from the queue.
> > > > > > >
> > > > > > > Am I missing something here?
> > > > > > >
> > > > > > > Still, I feel I am running in circles here... because even if I
> > > have
> > > > > some
> > > > > > > control on the context, I still won't be able to catch the
> > timeout
> > > > > > > exception :-(
> > > > > > >
> > > > > > > grrrrrrrrrrrr
> > > > > > >
> > > > > > > []
> > > > > > >
> > > > > > > Leo
> > > > > > >
> > > > > > > On Tue, Apr 14, 2015 at 6:08 PM, Leonardo K. Shikida <
> > > > > shikida@gmail.com>
> > > > > > > wrote:
> > > > > > >
> > > > > > > > thx!
> > > > > > > >
> > > > > > > > []
> > > > > > > >
> > > > > > > > Leo
> > > > > > > >
> > > > > > > > On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <
> > > > > > > rmannibucau@gmail.com
> > > > > > > > > wrote:
> > > > > > > >
> > > > > > > >> using openejb-jar.xml you can wire a container to some beans
> > > only.
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> Romain Manni-Bucau
> > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > > > > >> https://github.com/rmannibucau> |
> > > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > > > >> <http://www.tomitribe.com>
> > > > > > > >>
> > > > > > > >> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <
> > > shikida@gmail.com
> > > > >:
> > > > > > > >>
> > > > > > > >> > yeah, I think this will be the way to go
> > > > > > > >> >
> > > > > > > >> > since I can configure max/min instances for stateless (
> > > > > > > >> > http://tomee.apache.org/statelesscontainer-config.html) I
> > > > think I
> > > > > > can
> > > > > > > >> just
> > > > > > > >> > create a pool of stateless instances to work as MDBs that
> > can
> > > > deal
> > > > > > > with
> > > > > > > >> > timeout :-)
> > > > > > > >> >
> > > > > > > >> > is there any way to configure a container just for these
> > > specfic
> > > > > > > >> stateless
> > > > > > > >> > EJBs (so some other configuration can be used for
> stateless
> > by
> > > > > > > default)?
> > > > > > > >> >
> > > > > > > >> > []
> > > > > > > >> >
> > > > > > > >> > Leo
> > > > > > > >> >
> > > > > > > >> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
> > > > > > > >> rmannibucau@gmail.com
> > > > > > > >> > >
> > > > > > > >> > wrote:
> > > > > > > >> >
> > > > > > > >> > > so just handle transactions yourself
> > > > > > > >> > >
> > > > > > > >> > >
> > > > > > > >> > > Romain Manni-Bucau
> > > > > > > >> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > >> > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > >> > > https://github.com/rmannibucau> |
> > > > > > > >> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > Tomitriber
> > > > > > > >> > > <http://www.tomitribe.com>
> > > > > > > >> > >
> > > > > > > >> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <
> > > > > > > itsmeden@gmail.com
> > > > > > > >> >:
> > > > > > > >> > >
> > > > > > > >> > > > Another option is to look at the redelivered
> > > > > property/redelivery
> > > > > > > >> count
> > > > > > > >> > > and
> > > > > > > >> > > > take action (write to db?) in case of redelivery....
> > > > requires
> > > > > > you
> > > > > > > >> to
> > > > > > > >> > > set a
> > > > > > > >> > > > redelivery policy / number of retries etc
> > > > > > > >> > > >
> > > > > > > >> > > > /LF
> > > > > > > >> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <
> > > > > > > shikida@gmail.com>
> > > > > > > >> > > wrote:
> > > > > > > >> > > >
> > > > > > > >> > > > > Yup, but if the MDB timeout, I need to set something
> > in
> > > > the
> > > > > > DB,
> > > > > > > >> > that's
> > > > > > > >> > > > why
> > > > > > > >> > > > > I need to treat the timeout.
> > > > > > > >> > > > >
> > > > > > > >> > > > > If the job to be executed timeout, then it will
> > probably
> > > > > > timeout
> > > > > > > >> for
> > > > > > > >> > > any
> > > > > > > >> > > > > retry, because it's caused by a poorly chosen
> > parameter,
> > > > so
> > > > > > > >> retries
> > > > > > > >> > are
> > > > > > > >> > > > not
> > > > > > > >> > > > > important here (although increasing timeouts on each
> > > retry
> > > > > > could
> > > > > > > >> be
> > > > > > > >> > an
> > > > > > > >> > > > > interesting option)
> > > > > > > >> > > > >
> > > > > > > >> > > > > []
> > > > > > > >> > > > >
> > > > > > > >> > > > > Leo
> > > > > > > >> > > > >
> > > > > > > >> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau
> <
> > > > > > > >> > > > rmannibucau@gmail.com
> > > > > > > >> > > > > >
> > > > > > > >> > > > > wrote:
> > > > > > > >> > > > >
> > > > > > > >> > > > > > Hmm, with MDBs you have retries since they are
> > > > > > transactional.
> > > > > > > >> you
> > > > > > > >> > can
> > > > > > > >> > > > > even
> > > > > > > >> > > > > > configure the redelivery policy with an
> exponential
> > > > > backoff
> > > > > > > and
> > > > > > > >> so
> > > > > > > >> > on
> > > > > > > >> > > > if
> > > > > > > >> > > > > > really needed
> > > > > > > >> > > > > >
> > > > > > > >> > > > > >
> > > > > > > >> > > > > > Romain Manni-Bucau
> > > > > > > >> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> > > Blog
> > > > > > > >> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > >> > > > > > https://github.com/rmannibucau> |
> > > > > > > >> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau
> >
> > |
> > > > > > > Tomitriber
> > > > > > > >> > > > > > <http://www.tomitribe.com>
> > > > > > > >> > > > > >
> > > > > > > >> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
> > > > > > > >> shikida@gmail.com
> > > > > > > >> > >:
> > > > > > > >> > > > > >
> > > > > > > >> > > > > > > Well, what I need is a pool of workers to listen
> > to
> > > a
> > > > > > queue
> > > > > > > >> and
> > > > > > > >> > > > process
> > > > > > > >> > > > > > > messages while they come, but I also need to
> > > properly
> > > > > > treat
> > > > > > > >> them
> > > > > > > >> > > when
> > > > > > > >> > > > > the
> > > > > > > >> > > > > > > JMS transaction times out.
> > > > > > > >> > > > > > >
> > > > > > > >> > > > > > > So I guess I can't use a MDB here right?
> > > > > > > >> > > > > > >
> > > > > > > >> > > > > > > What would be a good approach in this situation?
> > > > > > > >> > > > > > >
> > > > > > > >> > > > > > > []
> > > > > > > >> > > > > > >
> > > > > > > >> > > > > > > Leo
> > > > > > > >> > > > > > >
> > > > > > > >> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain
> > Manni-Bucau
> > > <
> > > > > > > >> > > > > > rmannibucau@gmail.com
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > wrote:
> > > > > > > >> > > > > > >
> > > > > > > >> > > > > > > > if you want to control and be able to catch it
> > you
> > > > > need
> > > > > > to
> > > > > > > >> > handle
> > > > > > > >> > > > > > > yourself
> > > > > > > >> > > > > > > > the transaction otherwise if it takes more
> then
> > > > you'll
> > > > > > > get a
> > > > > > > >> > > > rollback
> > > > > > > >> > > > > > > and a
> > > > > > > >> > > > > > > > (surely wrapped) RollbackException
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > > Romain Manni-Bucau
> > > > > > > >> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau
> >
> > |
> > > > > Blog
> > > > > > > >> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > >> > > > > > > > https://github.com/rmannibucau> |
> > > > > > > >> > > > > > > > LinkedIn <
> > https://www.linkedin.com/in/rmannibucau
> > > >
> > > > |
> > > > > > > >> > Tomitriber
> > > > > > > >> > > > > > > > <http://www.tomitribe.com>
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K.
> Shikida <
> > > > > > > >> > > shikida@gmail.com
> > > > > > > >> > > > >:
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > > > just checking
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > > I just add
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > >     @Resource
> > > > > > > >> > > > > > > > >     private TransactionManager tx;
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > > and in the MDB initialization I set some
> > timeout
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > >     @PostConstruct
> > > > > > > >> > > > > > > > >     public void initialize() {
> > > > > > > >> > > > > > > > >         try {
> > > > > > > >> > > > > > > > >             tx.setTransactionTimeout(3);
> > > > > > > >> > > > > > > > >         } catch (SystemException e) {
> > > > > > > >> > > > > > > > >             e.printStackTrace();
> > > > > > > >> > > > > > > > >         }
> > > > > > > >> > > > > > > > >     }
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > > and when my onMessage() executes, if it
> takes
> > > more
> > > > > > than
> > > > > > > 3
> > > > > > > >> > > seconds
> > > > > > > >> > > > > to
> > > > > > > >> > > > > > > > > complete, it throws and exception?
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > > and if so, how do I catch it? (or I don't?)
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > > []
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > > Leo
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K.
> > > > > Shikida <
> > > > > > > >> > > > > > > shikida@gmail.com>
> > > > > > > >> > > > > > > > > wrote:
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > > > > thx!
> > > > > > > >> > > > > > > > > >
> > > > > > > >> > > > > > > > > > []
> > > > > > > >> > > > > > > > > >
> > > > > > > >> > > > > > > > > > Leo
> > > > > > > >> > > > > > > > > >
> > > > > > > >> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain
> > > > > Manni-Bucau
> > > > > > <
> > > > > > > >> > > > > > > > > rmannibucau@gmail.com
> > > > > > > >> > > > > > > > > > > wrote:
> > > > > > > >> > > > > > > > > >
> > > > > > > >> > > > > > > > > >> Get the Transactionmanager injected
> > > (@Resource)
> > > > > and
> > > > > > > >> call
> > > > > > > >> > > > > > > > > >> setTransactionTimeout(seconds)
> > > > > > > >> > > > > > > > > >>
> > > > > > > >> > > > > > > > > >>
> > > > > > > >> > > > > > > > > >> Romain Manni-Bucau
> > > > > > > >> > > > > > > > > >> @rmannibucau <
> > > https://twitter.com/rmannibucau>
> > > > |
> > > > > > > Blog
> > > > > > > >> > > > > > > > > >> <http://rmannibucau.wordpress.com> |
> > Github
> > > <
> > > > > > > >> > > > > > > > > >> https://github.com/rmannibucau> |
> > > > > > > >> > > > > > > > > >> LinkedIn <
> > > > > https://www.linkedin.com/in/rmannibucau>
> > > > > > |
> > > > > > > >> > > > Tomitriber
> > > > > > > >> > > > > > > > > >> <http://www.tomitribe.com>
> > > > > > > >> > > > > > > > > >>
> > > > > > > >> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K.
> > > Shikida
> > > > <
> > > > > > > >> > > > > shikida@gmail.com
> > > > > > > >> > > > > > >:
> > > > > > > >> > > > > > > > > >>
> > > > > > > >> > > > > > > > > >> > Hi
> > > > > > > >> > > > > > > > > >> >
> > > > > > > >> > > > > > > > > >> > How do I increase the MDB onMessage()
> > > > > transaction
> > > > > > > >> > timeout?
> > > > > > > >> > > > > > > > > >> >
> > > > > > > >> > > > > > > > > >> > []
> > > > > > > >> > > > > > > > > >> >
> > > > > > > >> > > > > > > > > >> > Leo
> > > > > > > >> > > > > > > > > >> >
> > > > > > > >> > > > > > > > > >>
> > > > > > > >> > > > > > > > > >
> > > > > > > >> > > > > > > > > >
> > > > > > > >> > > > > > > > >
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > >
> > > > > > > >> > > > > >
> > > > > > > >> > > > >
> > > > > > > >> > > >
> > > > > > > >> > >
> > > > > > > >> >
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
then the message will be acknowledged on userTransaction.commit() right?

do I have to also use

PersistenceContextType.TRANSACTION

for the injected entity manager? (as showed at
http://tomee.apache.org/examples-trunk/testing-transactions-bmt/README.html)




[]

Leo

On Wed, Apr 15, 2015 at 10:04 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> @javax.ejb.TransactionManagement(BEAN), then @TransactionAttribute will get
> ignored.
>
> You can inject with ÀResource userTransaction ut the "transaction facade"
> you can use
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-15 14:39 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>
> > yup :-)
> >
> > do I have to explicitly use
> >
> > @TransactionAttribute(TransactionAttributeType.REQUIRED)
> >
> > or change
> >
> > @ActivationConfigProperty(propertyName = "acknowledgeMode",
> > propertyValue = "Auto-acknowledge")
> >
> > to client in order to do that?
> >
> >
> > []
> >
> > Leo
> >
> > On Wed, Apr 15, 2015 at 9:22 AM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > >
> > wrote:
> >
> > > well transaction timeout = exception + rollback if transaction took
> more
> > > than X but the execution time is still the real one.
> > >
> > > you can do using bean managed transactions:
> > >
> > > Exception oops = null;
> > > try {
> > >   userTransaction.begin();
> > > } cath (Exception e) {
> > >   oops = e;
> > > } finally { // add the logic you want here
> > >   if (oops == null) {
> > >     userTransaction.commit();
> > >     return;
> > >   }
> > >
> > >   userTransaction.rollback();
> > > }
> > >
> > > It doesnt match your need?
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-04-15 14:15 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > >
> > > > If there's an external event to the MDB like a timeout (which
> > exception I
> > > > cannot catch), then it should have something like a @Timeout
> annotation
> > > so
> > > > I could customize how the event could be handled.
> > > >
> > > > Not tomee's problem of course, tomee just implements a standard.
> > > >
> > > > :-(
> > > >
> > > > Gonna think on something else here.
> > > >
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > > > On Wed, Apr 15, 2015 at 4:21 AM, Romain Manni-Bucau <
> > > rmannibucau@gmail.com
> > > > >
> > > > wrote:
> > > >
> > > > > hmm, my proposal was to use UserTransaction more than that. About
> > this
> > > > > particular exemple we would need a maven project to reproduce it.
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-04-15 4:05 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > > > >
> > > > > > Hi
> > > > > >
> > > > > > So I've changed my MDBs to stateless
> > > > > >
> > > > > > public class Worker implements MessageListener {
> > > > > >
> > > > > >     @Resource(name="MyJmsConnectionFactory")
> > > > > >     private ConnectionFactory connectionFactory;
> > > > > >
> > > > > >     @Resource(name="DriverJobQueue")
> > > > > >     private Queue queue;
> > > > > >
> > > > > >     private Connection connection = null;
> > > > > >     private Session session = null;
> > > > > >     private MessageConsumer consumer = null;
> > > > > >
> > > > > >     @PostConstruct
> > > > > >     public void initialize() {
> > > > > >         System.out.println("Instantiating "+this);
> > > > > >         try {
> > > > > >             connection = connectionFactory.createConnection();
> > > > > >             connection.start(); //activemq site says it's here
> > > > > >             // Create a Session
> > > > > >             session = connection.createSession(false,
> > > > > > Session.AUTO_ACKNOWLEDGE);
> > > > > >
> > > > > >             // Create a MessageConsumer from the Session to the
> > Topic
> > > > or
> > > > > > Queue
> > > > > >             consumer = session.createConsumer(this.queue);
> > > > > >
> > > > > >             consumer.setMessageListener(this);
> > > > > >
> > > > > > //            connection.start(); //some sites says it's here
> > > > > >
> > > > > >         } catch(Exception e) {
> > > > > >             e.printStackTrace();
> > > > > >         } finally {
> > > > > >             if (consumer != null) {
> > > > > >                 try {
> > > > > >                     consumer.close();
> > > > > >                 } catch (JMSException e) {
> > > > > >                     e.printStackTrace();
> > > > > >                 }
> > > > > >             }
> > > > > >             if (session != null) {
> > > > > >                 try {
> > > > > >                     session.close();
> > > > > >                 } catch (JMSException e) {
> > > > > >                     e.printStackTrace();
> > > > > >                 }
> > > > > >             }
> > > > > >             if (connection != null) {
> > > > > >                 try {
> > > > > >                     connection.close();
> > > > > >                 } catch (JMSException e) {
> > > > > >                     e.printStackTrace();
> > > > > >                 }
> > > > > >             }
> > > > > >         }
> > > > > >     }
> > > > > >
> > > > > >     @Override
> > > > > >     public void onMessage(Message msg) {
> > > > > >         System.out.println("On message for "+this);
> > > > > >     }
> > > > > >
> > > > > > openejb-jar.xml
> > > > > >
> > > > > > <?xml version="1.0"?>
> > > > > > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
> > > > > >     <ejb-deployment
> > > > > >         ejb-name="Worker"
> > > > > >         deployment-id="Worker"
> > > > > >         container-id="pseudo_mdb" />
> > > > > > </openejb-jar>
> > > > > >
> > > > > > tomee.xml
> > > > > >
> > > > > >     <Container id="myAllContainer" type="STATELESS">
> > > > > >     strictPooling = false
> > > > > >     </Container>
> > > > > >
> > > > > >     <Container id="pseudo_mdb" type="STATELESS">
> > > > > >     strictPooling = true
> > > > > >     maxSize = 5
> > > > > >     minSize = 3
> > > > > >     </Container>
> > > > > >
> > > > > > The container part seems to be right, since only the Worker bean
> is
> > > > > > instantiated early.
> > > > > >
> > > > > > But for some reason, it's not consuming from the queue.
> > > > > >
> > > > > > Am I missing something here?
> > > > > >
> > > > > > Still, I feel I am running in circles here... because even if I
> > have
> > > > some
> > > > > > control on the context, I still won't be able to catch the
> timeout
> > > > > > exception :-(
> > > > > >
> > > > > > grrrrrrrrrrrr
> > > > > >
> > > > > > []
> > > > > >
> > > > > > Leo
> > > > > >
> > > > > > On Tue, Apr 14, 2015 at 6:08 PM, Leonardo K. Shikida <
> > > > shikida@gmail.com>
> > > > > > wrote:
> > > > > >
> > > > > > > thx!
> > > > > > >
> > > > > > > []
> > > > > > >
> > > > > > > Leo
> > > > > > >
> > > > > > > On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <
> > > > > > rmannibucau@gmail.com
> > > > > > > > wrote:
> > > > > > >
> > > > > > >> using openejb-jar.xml you can wire a container to some beans
> > only.
> > > > > > >>
> > > > > > >>
> > > > > > >> Romain Manni-Bucau
> > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > > > >> https://github.com/rmannibucau> |
> > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > >> <http://www.tomitribe.com>
> > > > > > >>
> > > > > > >> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <
> > shikida@gmail.com
> > > >:
> > > > > > >>
> > > > > > >> > yeah, I think this will be the way to go
> > > > > > >> >
> > > > > > >> > since I can configure max/min instances for stateless (
> > > > > > >> > http://tomee.apache.org/statelesscontainer-config.html) I
> > > think I
> > > > > can
> > > > > > >> just
> > > > > > >> > create a pool of stateless instances to work as MDBs that
> can
> > > deal
> > > > > > with
> > > > > > >> > timeout :-)
> > > > > > >> >
> > > > > > >> > is there any way to configure a container just for these
> > specfic
> > > > > > >> stateless
> > > > > > >> > EJBs (so some other configuration can be used for stateless
> by
> > > > > > default)?
> > > > > > >> >
> > > > > > >> > []
> > > > > > >> >
> > > > > > >> > Leo
> > > > > > >> >
> > > > > > >> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
> > > > > > >> rmannibucau@gmail.com
> > > > > > >> > >
> > > > > > >> > wrote:
> > > > > > >> >
> > > > > > >> > > so just handle transactions yourself
> > > > > > >> > >
> > > > > > >> > >
> > > > > > >> > > Romain Manni-Bucau
> > > > > > >> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > >> > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > >> > > https://github.com/rmannibucau> |
> > > > > > >> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > Tomitriber
> > > > > > >> > > <http://www.tomitribe.com>
> > > > > > >> > >
> > > > > > >> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <
> > > > > > itsmeden@gmail.com
> > > > > > >> >:
> > > > > > >> > >
> > > > > > >> > > > Another option is to look at the redelivered
> > > > property/redelivery
> > > > > > >> count
> > > > > > >> > > and
> > > > > > >> > > > take action (write to db?) in case of redelivery....
> > > requires
> > > > > you
> > > > > > >> to
> > > > > > >> > > set a
> > > > > > >> > > > redelivery policy / number of retries etc
> > > > > > >> > > >
> > > > > > >> > > > /LF
> > > > > > >> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <
> > > > > > shikida@gmail.com>
> > > > > > >> > > wrote:
> > > > > > >> > > >
> > > > > > >> > > > > Yup, but if the MDB timeout, I need to set something
> in
> > > the
> > > > > DB,
> > > > > > >> > that's
> > > > > > >> > > > why
> > > > > > >> > > > > I need to treat the timeout.
> > > > > > >> > > > >
> > > > > > >> > > > > If the job to be executed timeout, then it will
> probably
> > > > > timeout
> > > > > > >> for
> > > > > > >> > > any
> > > > > > >> > > > > retry, because it's caused by a poorly chosen
> parameter,
> > > so
> > > > > > >> retries
> > > > > > >> > are
> > > > > > >> > > > not
> > > > > > >> > > > > important here (although increasing timeouts on each
> > retry
> > > > > could
> > > > > > >> be
> > > > > > >> > an
> > > > > > >> > > > > interesting option)
> > > > > > >> > > > >
> > > > > > >> > > > > []
> > > > > > >> > > > >
> > > > > > >> > > > > Leo
> > > > > > >> > > > >
> > > > > > >> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> > > > > > >> > > > rmannibucau@gmail.com
> > > > > > >> > > > > >
> > > > > > >> > > > > wrote:
> > > > > > >> > > > >
> > > > > > >> > > > > > Hmm, with MDBs you have retries since they are
> > > > > transactional.
> > > > > > >> you
> > > > > > >> > can
> > > > > > >> > > > > even
> > > > > > >> > > > > > configure the redelivery policy with an exponential
> > > > backoff
> > > > > > and
> > > > > > >> so
> > > > > > >> > on
> > > > > > >> > > > if
> > > > > > >> > > > > > really needed
> > > > > > >> > > > > >
> > > > > > >> > > > > >
> > > > > > >> > > > > > Romain Manni-Bucau
> > > > > > >> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> > Blog
> > > > > > >> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > >> > > > > > https://github.com/rmannibucau> |
> > > > > > >> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau>
> |
> > > > > > Tomitriber
> > > > > > >> > > > > > <http://www.tomitribe.com>
> > > > > > >> > > > > >
> > > > > > >> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
> > > > > > >> shikida@gmail.com
> > > > > > >> > >:
> > > > > > >> > > > > >
> > > > > > >> > > > > > > Well, what I need is a pool of workers to listen
> to
> > a
> > > > > queue
> > > > > > >> and
> > > > > > >> > > > process
> > > > > > >> > > > > > > messages while they come, but I also need to
> > properly
> > > > > treat
> > > > > > >> them
> > > > > > >> > > when
> > > > > > >> > > > > the
> > > > > > >> > > > > > > JMS transaction times out.
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > So I guess I can't use a MDB here right?
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > What would be a good approach in this situation?
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > []
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > Leo
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain
> Manni-Bucau
> > <
> > > > > > >> > > > > > rmannibucau@gmail.com
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > wrote:
> > > > > > >> > > > > > >
> > > > > > >> > > > > > > > if you want to control and be able to catch it
> you
> > > > need
> > > > > to
> > > > > > >> > handle
> > > > > > >> > > > > > > yourself
> > > > > > >> > > > > > > > the transaction otherwise if it takes more then
> > > you'll
> > > > > > get a
> > > > > > >> > > > rollback
> > > > > > >> > > > > > > and a
> > > > > > >> > > > > > > > (surely wrapped) RollbackException
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > > Romain Manni-Bucau
> > > > > > >> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau>
> |
> > > > Blog
> > > > > > >> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > >> > > > > > > > https://github.com/rmannibucau> |
> > > > > > >> > > > > > > > LinkedIn <
> https://www.linkedin.com/in/rmannibucau
> > >
> > > |
> > > > > > >> > Tomitriber
> > > > > > >> > > > > > > > <http://www.tomitribe.com>
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
> > > > > > >> > > shikida@gmail.com
> > > > > > >> > > > >:
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > > > > just checking
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > I just add
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > >     @Resource
> > > > > > >> > > > > > > > >     private TransactionManager tx;
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > and in the MDB initialization I set some
> timeout
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > >     @PostConstruct
> > > > > > >> > > > > > > > >     public void initialize() {
> > > > > > >> > > > > > > > >         try {
> > > > > > >> > > > > > > > >             tx.setTransactionTimeout(3);
> > > > > > >> > > > > > > > >         } catch (SystemException e) {
> > > > > > >> > > > > > > > >             e.printStackTrace();
> > > > > > >> > > > > > > > >         }
> > > > > > >> > > > > > > > >     }
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > and when my onMessage() executes, if it takes
> > more
> > > > > than
> > > > > > 3
> > > > > > >> > > seconds
> > > > > > >> > > > > to
> > > > > > >> > > > > > > > > complete, it throws and exception?
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > and if so, how do I catch it? (or I don't?)
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > []
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > Leo
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K.
> > > > Shikida <
> > > > > > >> > > > > > > shikida@gmail.com>
> > > > > > >> > > > > > > > > wrote:
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > > > > thx!
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > > > []
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > > > Leo
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain
> > > > Manni-Bucau
> > > > > <
> > > > > > >> > > > > > > > > rmannibucau@gmail.com
> > > > > > >> > > > > > > > > > > wrote:
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > > >> Get the Transactionmanager injected
> > (@Resource)
> > > > and
> > > > > > >> call
> > > > > > >> > > > > > > > > >> setTransactionTimeout(seconds)
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >> Romain Manni-Bucau
> > > > > > >> > > > > > > > > >> @rmannibucau <
> > https://twitter.com/rmannibucau>
> > > |
> > > > > > Blog
> > > > > > >> > > > > > > > > >> <http://rmannibucau.wordpress.com> |
> Github
> > <
> > > > > > >> > > > > > > > > >> https://github.com/rmannibucau> |
> > > > > > >> > > > > > > > > >> LinkedIn <
> > > > https://www.linkedin.com/in/rmannibucau>
> > > > > |
> > > > > > >> > > > Tomitriber
> > > > > > >> > > > > > > > > >> <http://www.tomitribe.com>
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K.
> > Shikida
> > > <
> > > > > > >> > > > > shikida@gmail.com
> > > > > > >> > > > > > >:
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >> > Hi
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > > > > > >> > How do I increase the MDB onMessage()
> > > > transaction
> > > > > > >> > timeout?
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > > > > > >> > []
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > > > > > >> > Leo
> > > > > > >> > > > > > > > > >> >
> > > > > > >> > > > > > > > > >>
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > > >
> > > > > > >> > > > > > > > >
> > > > > > >> > > > > > > >
> > > > > > >> > > > > > >
> > > > > > >> > > > > >
> > > > > > >> > > > >
> > > > > > >> > > >
> > > > > > >> > >
> > > > > > >> >
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by Romain Manni-Bucau <rm...@gmail.com>.
@javax.ejb.TransactionManagement(BEAN), then @TransactionAttribute will get
ignored.

You can inject with ÀResource userTransaction ut the "transaction facade"
you can use


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-15 14:39 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:

> yup :-)
>
> do I have to explicitly use
>
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
>
> or change
>
> @ActivationConfigProperty(propertyName = "acknowledgeMode",
> propertyValue = "Auto-acknowledge")
>
> to client in order to do that?
>
>
> []
>
> Leo
>
> On Wed, Apr 15, 2015 at 9:22 AM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > well transaction timeout = exception + rollback if transaction took more
> > than X but the execution time is still the real one.
> >
> > you can do using bean managed transactions:
> >
> > Exception oops = null;
> > try {
> >   userTransaction.begin();
> > } cath (Exception e) {
> >   oops = e;
> > } finally { // add the logic you want here
> >   if (oops == null) {
> >     userTransaction.commit();
> >     return;
> >   }
> >
> >   userTransaction.rollback();
> > }
> >
> > It doesnt match your need?
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-04-15 14:15 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> >
> > > If there's an external event to the MDB like a timeout (which
> exception I
> > > cannot catch), then it should have something like a @Timeout annotation
> > so
> > > I could customize how the event could be handled.
> > >
> > > Not tomee's problem of course, tomee just implements a standard.
> > >
> > > :-(
> > >
> > > Gonna think on something else here.
> > >
> > >
> > > []
> > >
> > > Leo
> > >
> > > On Wed, Apr 15, 2015 at 4:21 AM, Romain Manni-Bucau <
> > rmannibucau@gmail.com
> > > >
> > > wrote:
> > >
> > > > hmm, my proposal was to use UserTransaction more than that. About
> this
> > > > particular exemple we would need a maven project to reproduce it.
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-04-15 4:05 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > > >
> > > > > Hi
> > > > >
> > > > > So I've changed my MDBs to stateless
> > > > >
> > > > > public class Worker implements MessageListener {
> > > > >
> > > > >     @Resource(name="MyJmsConnectionFactory")
> > > > >     private ConnectionFactory connectionFactory;
> > > > >
> > > > >     @Resource(name="DriverJobQueue")
> > > > >     private Queue queue;
> > > > >
> > > > >     private Connection connection = null;
> > > > >     private Session session = null;
> > > > >     private MessageConsumer consumer = null;
> > > > >
> > > > >     @PostConstruct
> > > > >     public void initialize() {
> > > > >         System.out.println("Instantiating "+this);
> > > > >         try {
> > > > >             connection = connectionFactory.createConnection();
> > > > >             connection.start(); //activemq site says it's here
> > > > >             // Create a Session
> > > > >             session = connection.createSession(false,
> > > > > Session.AUTO_ACKNOWLEDGE);
> > > > >
> > > > >             // Create a MessageConsumer from the Session to the
> Topic
> > > or
> > > > > Queue
> > > > >             consumer = session.createConsumer(this.queue);
> > > > >
> > > > >             consumer.setMessageListener(this);
> > > > >
> > > > > //            connection.start(); //some sites says it's here
> > > > >
> > > > >         } catch(Exception e) {
> > > > >             e.printStackTrace();
> > > > >         } finally {
> > > > >             if (consumer != null) {
> > > > >                 try {
> > > > >                     consumer.close();
> > > > >                 } catch (JMSException e) {
> > > > >                     e.printStackTrace();
> > > > >                 }
> > > > >             }
> > > > >             if (session != null) {
> > > > >                 try {
> > > > >                     session.close();
> > > > >                 } catch (JMSException e) {
> > > > >                     e.printStackTrace();
> > > > >                 }
> > > > >             }
> > > > >             if (connection != null) {
> > > > >                 try {
> > > > >                     connection.close();
> > > > >                 } catch (JMSException e) {
> > > > >                     e.printStackTrace();
> > > > >                 }
> > > > >             }
> > > > >         }
> > > > >     }
> > > > >
> > > > >     @Override
> > > > >     public void onMessage(Message msg) {
> > > > >         System.out.println("On message for "+this);
> > > > >     }
> > > > >
> > > > > openejb-jar.xml
> > > > >
> > > > > <?xml version="1.0"?>
> > > > > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
> > > > >     <ejb-deployment
> > > > >         ejb-name="Worker"
> > > > >         deployment-id="Worker"
> > > > >         container-id="pseudo_mdb" />
> > > > > </openejb-jar>
> > > > >
> > > > > tomee.xml
> > > > >
> > > > >     <Container id="myAllContainer" type="STATELESS">
> > > > >     strictPooling = false
> > > > >     </Container>
> > > > >
> > > > >     <Container id="pseudo_mdb" type="STATELESS">
> > > > >     strictPooling = true
> > > > >     maxSize = 5
> > > > >     minSize = 3
> > > > >     </Container>
> > > > >
> > > > > The container part seems to be right, since only the Worker bean is
> > > > > instantiated early.
> > > > >
> > > > > But for some reason, it's not consuming from the queue.
> > > > >
> > > > > Am I missing something here?
> > > > >
> > > > > Still, I feel I am running in circles here... because even if I
> have
> > > some
> > > > > control on the context, I still won't be able to catch the timeout
> > > > > exception :-(
> > > > >
> > > > > grrrrrrrrrrrr
> > > > >
> > > > > []
> > > > >
> > > > > Leo
> > > > >
> > > > > On Tue, Apr 14, 2015 at 6:08 PM, Leonardo K. Shikida <
> > > shikida@gmail.com>
> > > > > wrote:
> > > > >
> > > > > > thx!
> > > > > >
> > > > > > []
> > > > > >
> > > > > > Leo
> > > > > >
> > > > > > On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <
> > > > > rmannibucau@gmail.com
> > > > > > > wrote:
> > > > > >
> > > > > >> using openejb-jar.xml you can wire a container to some beans
> only.
> > > > > >>
> > > > > >>
> > > > > >> Romain Manni-Bucau
> > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > > >> https://github.com/rmannibucau> |
> > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > >> <http://www.tomitribe.com>
> > > > > >>
> > > > > >> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <
> shikida@gmail.com
> > >:
> > > > > >>
> > > > > >> > yeah, I think this will be the way to go
> > > > > >> >
> > > > > >> > since I can configure max/min instances for stateless (
> > > > > >> > http://tomee.apache.org/statelesscontainer-config.html) I
> > think I
> > > > can
> > > > > >> just
> > > > > >> > create a pool of stateless instances to work as MDBs that can
> > deal
> > > > > with
> > > > > >> > timeout :-)
> > > > > >> >
> > > > > >> > is there any way to configure a container just for these
> specfic
> > > > > >> stateless
> > > > > >> > EJBs (so some other configuration can be used for stateless by
> > > > > default)?
> > > > > >> >
> > > > > >> > []
> > > > > >> >
> > > > > >> > Leo
> > > > > >> >
> > > > > >> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
> > > > > >> rmannibucau@gmail.com
> > > > > >> > >
> > > > > >> > wrote:
> > > > > >> >
> > > > > >> > > so just handle transactions yourself
> > > > > >> > >
> > > > > >> > >
> > > > > >> > > Romain Manni-Bucau
> > > > > >> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > >> > > <http://rmannibucau.wordpress.com> | Github <
> > > > > >> > > https://github.com/rmannibucau> |
> > > > > >> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > >> > > <http://www.tomitribe.com>
> > > > > >> > >
> > > > > >> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <
> > > > > itsmeden@gmail.com
> > > > > >> >:
> > > > > >> > >
> > > > > >> > > > Another option is to look at the redelivered
> > > property/redelivery
> > > > > >> count
> > > > > >> > > and
> > > > > >> > > > take action (write to db?) in case of redelivery....
> > requires
> > > > you
> > > > > >> to
> > > > > >> > > set a
> > > > > >> > > > redelivery policy / number of retries etc
> > > > > >> > > >
> > > > > >> > > > /LF
> > > > > >> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <
> > > > > shikida@gmail.com>
> > > > > >> > > wrote:
> > > > > >> > > >
> > > > > >> > > > > Yup, but if the MDB timeout, I need to set something in
> > the
> > > > DB,
> > > > > >> > that's
> > > > > >> > > > why
> > > > > >> > > > > I need to treat the timeout.
> > > > > >> > > > >
> > > > > >> > > > > If the job to be executed timeout, then it will probably
> > > > timeout
> > > > > >> for
> > > > > >> > > any
> > > > > >> > > > > retry, because it's caused by a poorly chosen parameter,
> > so
> > > > > >> retries
> > > > > >> > are
> > > > > >> > > > not
> > > > > >> > > > > important here (although increasing timeouts on each
> retry
> > > > could
> > > > > >> be
> > > > > >> > an
> > > > > >> > > > > interesting option)
> > > > > >> > > > >
> > > > > >> > > > > []
> > > > > >> > > > >
> > > > > >> > > > > Leo
> > > > > >> > > > >
> > > > > >> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> > > > > >> > > > rmannibucau@gmail.com
> > > > > >> > > > > >
> > > > > >> > > > > wrote:
> > > > > >> > > > >
> > > > > >> > > > > > Hmm, with MDBs you have retries since they are
> > > > transactional.
> > > > > >> you
> > > > > >> > can
> > > > > >> > > > > even
> > > > > >> > > > > > configure the redelivery policy with an exponential
> > > backoff
> > > > > and
> > > > > >> so
> > > > > >> > on
> > > > > >> > > > if
> > > > > >> > > > > > really needed
> > > > > >> > > > > >
> > > > > >> > > > > >
> > > > > >> > > > > > Romain Manni-Bucau
> > > > > >> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> Blog
> > > > > >> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > >> > > > > > https://github.com/rmannibucau> |
> > > > > >> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > > Tomitriber
> > > > > >> > > > > > <http://www.tomitribe.com>
> > > > > >> > > > > >
> > > > > >> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
> > > > > >> shikida@gmail.com
> > > > > >> > >:
> > > > > >> > > > > >
> > > > > >> > > > > > > Well, what I need is a pool of workers to listen to
> a
> > > > queue
> > > > > >> and
> > > > > >> > > > process
> > > > > >> > > > > > > messages while they come, but I also need to
> properly
> > > > treat
> > > > > >> them
> > > > > >> > > when
> > > > > >> > > > > the
> > > > > >> > > > > > > JMS transaction times out.
> > > > > >> > > > > > >
> > > > > >> > > > > > > So I guess I can't use a MDB here right?
> > > > > >> > > > > > >
> > > > > >> > > > > > > What would be a good approach in this situation?
> > > > > >> > > > > > >
> > > > > >> > > > > > > []
> > > > > >> > > > > > >
> > > > > >> > > > > > > Leo
> > > > > >> > > > > > >
> > > > > >> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau
> <
> > > > > >> > > > > > rmannibucau@gmail.com
> > > > > >> > > > > > > >
> > > > > >> > > > > > > wrote:
> > > > > >> > > > > > >
> > > > > >> > > > > > > > if you want to control and be able to catch it you
> > > need
> > > > to
> > > > > >> > handle
> > > > > >> > > > > > > yourself
> > > > > >> > > > > > > > the transaction otherwise if it takes more then
> > you'll
> > > > > get a
> > > > > >> > > > rollback
> > > > > >> > > > > > > and a
> > > > > >> > > > > > > > (surely wrapped) RollbackException
> > > > > >> > > > > > > >
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > Romain Manni-Bucau
> > > > > >> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> > > Blog
> > > > > >> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > >> > > > > > > > https://github.com/rmannibucau> |
> > > > > >> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau
> >
> > |
> > > > > >> > Tomitriber
> > > > > >> > > > > > > > <http://www.tomitribe.com>
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
> > > > > >> > > shikida@gmail.com
> > > > > >> > > > >:
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > > just checking
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > I just add
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > >     @Resource
> > > > > >> > > > > > > > >     private TransactionManager tx;
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > and in the MDB initialization I set some timeout
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > >     @PostConstruct
> > > > > >> > > > > > > > >     public void initialize() {
> > > > > >> > > > > > > > >         try {
> > > > > >> > > > > > > > >             tx.setTransactionTimeout(3);
> > > > > >> > > > > > > > >         } catch (SystemException e) {
> > > > > >> > > > > > > > >             e.printStackTrace();
> > > > > >> > > > > > > > >         }
> > > > > >> > > > > > > > >     }
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > and when my onMessage() executes, if it takes
> more
> > > > than
> > > > > 3
> > > > > >> > > seconds
> > > > > >> > > > > to
> > > > > >> > > > > > > > > complete, it throws and exception?
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > and if so, how do I catch it? (or I don't?)
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > []
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > Leo
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K.
> > > Shikida <
> > > > > >> > > > > > > shikida@gmail.com>
> > > > > >> > > > > > > > > wrote:
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > > thx!
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > > > []
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > > > Leo
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain
> > > Manni-Bucau
> > > > <
> > > > > >> > > > > > > > > rmannibucau@gmail.com
> > > > > >> > > > > > > > > > > wrote:
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > > >> Get the Transactionmanager injected
> (@Resource)
> > > and
> > > > > >> call
> > > > > >> > > > > > > > > >> setTransactionTimeout(seconds)
> > > > > >> > > > > > > > > >>
> > > > > >> > > > > > > > > >>
> > > > > >> > > > > > > > > >> Romain Manni-Bucau
> > > > > >> > > > > > > > > >> @rmannibucau <
> https://twitter.com/rmannibucau>
> > |
> > > > > Blog
> > > > > >> > > > > > > > > >> <http://rmannibucau.wordpress.com> | Github
> <
> > > > > >> > > > > > > > > >> https://github.com/rmannibucau> |
> > > > > >> > > > > > > > > >> LinkedIn <
> > > https://www.linkedin.com/in/rmannibucau>
> > > > |
> > > > > >> > > > Tomitriber
> > > > > >> > > > > > > > > >> <http://www.tomitribe.com>
> > > > > >> > > > > > > > > >>
> > > > > >> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K.
> Shikida
> > <
> > > > > >> > > > > shikida@gmail.com
> > > > > >> > > > > > >:
> > > > > >> > > > > > > > > >>
> > > > > >> > > > > > > > > >> > Hi
> > > > > >> > > > > > > > > >> >
> > > > > >> > > > > > > > > >> > How do I increase the MDB onMessage()
> > > transaction
> > > > > >> > timeout?
> > > > > >> > > > > > > > > >> >
> > > > > >> > > > > > > > > >> > []
> > > > > >> > > > > > > > > >> >
> > > > > >> > > > > > > > > >> > Leo
> > > > > >> > > > > > > > > >> >
> > > > > >> > > > > > > > > >>
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > > >
> > > > > >> > > > >
> > > > > >> > > >
> > > > > >> > >
> > > > > >> >
> > > > > >>
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
yup :-)

do I have to explicitly use

@TransactionAttribute(TransactionAttributeType.REQUIRED)

or change

@ActivationConfigProperty(propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge")

to client in order to do that?


[]

Leo

On Wed, Apr 15, 2015 at 9:22 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> well transaction timeout = exception + rollback if transaction took more
> than X but the execution time is still the real one.
>
> you can do using bean managed transactions:
>
> Exception oops = null;
> try {
>   userTransaction.begin();
> } cath (Exception e) {
>   oops = e;
> } finally { // add the logic you want here
>   if (oops == null) {
>     userTransaction.commit();
>     return;
>   }
>
>   userTransaction.rollback();
> }
>
> It doesnt match your need?
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-15 14:15 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>
> > If there's an external event to the MDB like a timeout (which exception I
> > cannot catch), then it should have something like a @Timeout annotation
> so
> > I could customize how the event could be handled.
> >
> > Not tomee's problem of course, tomee just implements a standard.
> >
> > :-(
> >
> > Gonna think on something else here.
> >
> >
> > []
> >
> > Leo
> >
> > On Wed, Apr 15, 2015 at 4:21 AM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > >
> > wrote:
> >
> > > hmm, my proposal was to use UserTransaction more than that. About this
> > > particular exemple we would need a maven project to reproduce it.
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-04-15 4:05 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > >
> > > > Hi
> > > >
> > > > So I've changed my MDBs to stateless
> > > >
> > > > public class Worker implements MessageListener {
> > > >
> > > >     @Resource(name="MyJmsConnectionFactory")
> > > >     private ConnectionFactory connectionFactory;
> > > >
> > > >     @Resource(name="DriverJobQueue")
> > > >     private Queue queue;
> > > >
> > > >     private Connection connection = null;
> > > >     private Session session = null;
> > > >     private MessageConsumer consumer = null;
> > > >
> > > >     @PostConstruct
> > > >     public void initialize() {
> > > >         System.out.println("Instantiating "+this);
> > > >         try {
> > > >             connection = connectionFactory.createConnection();
> > > >             connection.start(); //activemq site says it's here
> > > >             // Create a Session
> > > >             session = connection.createSession(false,
> > > > Session.AUTO_ACKNOWLEDGE);
> > > >
> > > >             // Create a MessageConsumer from the Session to the Topic
> > or
> > > > Queue
> > > >             consumer = session.createConsumer(this.queue);
> > > >
> > > >             consumer.setMessageListener(this);
> > > >
> > > > //            connection.start(); //some sites says it's here
> > > >
> > > >         } catch(Exception e) {
> > > >             e.printStackTrace();
> > > >         } finally {
> > > >             if (consumer != null) {
> > > >                 try {
> > > >                     consumer.close();
> > > >                 } catch (JMSException e) {
> > > >                     e.printStackTrace();
> > > >                 }
> > > >             }
> > > >             if (session != null) {
> > > >                 try {
> > > >                     session.close();
> > > >                 } catch (JMSException e) {
> > > >                     e.printStackTrace();
> > > >                 }
> > > >             }
> > > >             if (connection != null) {
> > > >                 try {
> > > >                     connection.close();
> > > >                 } catch (JMSException e) {
> > > >                     e.printStackTrace();
> > > >                 }
> > > >             }
> > > >         }
> > > >     }
> > > >
> > > >     @Override
> > > >     public void onMessage(Message msg) {
> > > >         System.out.println("On message for "+this);
> > > >     }
> > > >
> > > > openejb-jar.xml
> > > >
> > > > <?xml version="1.0"?>
> > > > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
> > > >     <ejb-deployment
> > > >         ejb-name="Worker"
> > > >         deployment-id="Worker"
> > > >         container-id="pseudo_mdb" />
> > > > </openejb-jar>
> > > >
> > > > tomee.xml
> > > >
> > > >     <Container id="myAllContainer" type="STATELESS">
> > > >     strictPooling = false
> > > >     </Container>
> > > >
> > > >     <Container id="pseudo_mdb" type="STATELESS">
> > > >     strictPooling = true
> > > >     maxSize = 5
> > > >     minSize = 3
> > > >     </Container>
> > > >
> > > > The container part seems to be right, since only the Worker bean is
> > > > instantiated early.
> > > >
> > > > But for some reason, it's not consuming from the queue.
> > > >
> > > > Am I missing something here?
> > > >
> > > > Still, I feel I am running in circles here... because even if I have
> > some
> > > > control on the context, I still won't be able to catch the timeout
> > > > exception :-(
> > > >
> > > > grrrrrrrrrrrr
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > > > On Tue, Apr 14, 2015 at 6:08 PM, Leonardo K. Shikida <
> > shikida@gmail.com>
> > > > wrote:
> > > >
> > > > > thx!
> > > > >
> > > > > []
> > > > >
> > > > > Leo
> > > > >
> > > > > On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <
> > > > rmannibucau@gmail.com
> > > > > > wrote:
> > > > >
> > > > >> using openejb-jar.xml you can wire a container to some beans only.
> > > > >>
> > > > >>
> > > > >> Romain Manni-Bucau
> > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > >> https://github.com/rmannibucau> |
> > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > >> <http://www.tomitribe.com>
> > > > >>
> > > > >> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <shikida@gmail.com
> >:
> > > > >>
> > > > >> > yeah, I think this will be the way to go
> > > > >> >
> > > > >> > since I can configure max/min instances for stateless (
> > > > >> > http://tomee.apache.org/statelesscontainer-config.html) I
> think I
> > > can
> > > > >> just
> > > > >> > create a pool of stateless instances to work as MDBs that can
> deal
> > > > with
> > > > >> > timeout :-)
> > > > >> >
> > > > >> > is there any way to configure a container just for these specfic
> > > > >> stateless
> > > > >> > EJBs (so some other configuration can be used for stateless by
> > > > default)?
> > > > >> >
> > > > >> > []
> > > > >> >
> > > > >> > Leo
> > > > >> >
> > > > >> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
> > > > >> rmannibucau@gmail.com
> > > > >> > >
> > > > >> > wrote:
> > > > >> >
> > > > >> > > so just handle transactions yourself
> > > > >> > >
> > > > >> > >
> > > > >> > > Romain Manni-Bucau
> > > > >> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > >> > > <http://rmannibucau.wordpress.com> | Github <
> > > > >> > > https://github.com/rmannibucau> |
> > > > >> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > >> > > <http://www.tomitribe.com>
> > > > >> > >
> > > > >> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <
> > > > itsmeden@gmail.com
> > > > >> >:
> > > > >> > >
> > > > >> > > > Another option is to look at the redelivered
> > property/redelivery
> > > > >> count
> > > > >> > > and
> > > > >> > > > take action (write to db?) in case of redelivery....
> requires
> > > you
> > > > >> to
> > > > >> > > set a
> > > > >> > > > redelivery policy / number of retries etc
> > > > >> > > >
> > > > >> > > > /LF
> > > > >> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <
> > > > shikida@gmail.com>
> > > > >> > > wrote:
> > > > >> > > >
> > > > >> > > > > Yup, but if the MDB timeout, I need to set something in
> the
> > > DB,
> > > > >> > that's
> > > > >> > > > why
> > > > >> > > > > I need to treat the timeout.
> > > > >> > > > >
> > > > >> > > > > If the job to be executed timeout, then it will probably
> > > timeout
> > > > >> for
> > > > >> > > any
> > > > >> > > > > retry, because it's caused by a poorly chosen parameter,
> so
> > > > >> retries
> > > > >> > are
> > > > >> > > > not
> > > > >> > > > > important here (although increasing timeouts on each retry
> > > could
> > > > >> be
> > > > >> > an
> > > > >> > > > > interesting option)
> > > > >> > > > >
> > > > >> > > > > []
> > > > >> > > > >
> > > > >> > > > > Leo
> > > > >> > > > >
> > > > >> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> > > > >> > > > rmannibucau@gmail.com
> > > > >> > > > > >
> > > > >> > > > > wrote:
> > > > >> > > > >
> > > > >> > > > > > Hmm, with MDBs you have retries since they are
> > > transactional.
> > > > >> you
> > > > >> > can
> > > > >> > > > > even
> > > > >> > > > > > configure the redelivery policy with an exponential
> > backoff
> > > > and
> > > > >> so
> > > > >> > on
> > > > >> > > > if
> > > > >> > > > > > really needed
> > > > >> > > > > >
> > > > >> > > > > >
> > > > >> > > > > > Romain Manni-Bucau
> > > > >> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > >> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > >> > > > > > https://github.com/rmannibucau> |
> > > > >> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > Tomitriber
> > > > >> > > > > > <http://www.tomitribe.com>
> > > > >> > > > > >
> > > > >> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
> > > > >> shikida@gmail.com
> > > > >> > >:
> > > > >> > > > > >
> > > > >> > > > > > > Well, what I need is a pool of workers to listen to a
> > > queue
> > > > >> and
> > > > >> > > > process
> > > > >> > > > > > > messages while they come, but I also need to properly
> > > treat
> > > > >> them
> > > > >> > > when
> > > > >> > > > > the
> > > > >> > > > > > > JMS transaction times out.
> > > > >> > > > > > >
> > > > >> > > > > > > So I guess I can't use a MDB here right?
> > > > >> > > > > > >
> > > > >> > > > > > > What would be a good approach in this situation?
> > > > >> > > > > > >
> > > > >> > > > > > > []
> > > > >> > > > > > >
> > > > >> > > > > > > Leo
> > > > >> > > > > > >
> > > > >> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> > > > >> > > > > > rmannibucau@gmail.com
> > > > >> > > > > > > >
> > > > >> > > > > > > wrote:
> > > > >> > > > > > >
> > > > >> > > > > > > > if you want to control and be able to catch it you
> > need
> > > to
> > > > >> > handle
> > > > >> > > > > > > yourself
> > > > >> > > > > > > > the transaction otherwise if it takes more then
> you'll
> > > > get a
> > > > >> > > > rollback
> > > > >> > > > > > > and a
> > > > >> > > > > > > > (surely wrapped) RollbackException
> > > > >> > > > > > > >
> > > > >> > > > > > > >
> > > > >> > > > > > > > Romain Manni-Bucau
> > > > >> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> > Blog
> > > > >> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > >> > > > > > > > https://github.com/rmannibucau> |
> > > > >> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau>
> |
> > > > >> > Tomitriber
> > > > >> > > > > > > > <http://www.tomitribe.com>
> > > > >> > > > > > > >
> > > > >> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
> > > > >> > > shikida@gmail.com
> > > > >> > > > >:
> > > > >> > > > > > > >
> > > > >> > > > > > > > > just checking
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > I just add
> > > > >> > > > > > > > >
> > > > >> > > > > > > > >     @Resource
> > > > >> > > > > > > > >     private TransactionManager tx;
> > > > >> > > > > > > > >
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > and in the MDB initialization I set some timeout
> > > > >> > > > > > > > >
> > > > >> > > > > > > > >     @PostConstruct
> > > > >> > > > > > > > >     public void initialize() {
> > > > >> > > > > > > > >         try {
> > > > >> > > > > > > > >             tx.setTransactionTimeout(3);
> > > > >> > > > > > > > >         } catch (SystemException e) {
> > > > >> > > > > > > > >             e.printStackTrace();
> > > > >> > > > > > > > >         }
> > > > >> > > > > > > > >     }
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > and when my onMessage() executes, if it takes more
> > > than
> > > > 3
> > > > >> > > seconds
> > > > >> > > > > to
> > > > >> > > > > > > > > complete, it throws and exception?
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > and if so, how do I catch it? (or I don't?)
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > []
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > Leo
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K.
> > Shikida <
> > > > >> > > > > > > shikida@gmail.com>
> > > > >> > > > > > > > > wrote:
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > > thx!
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > > []
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > > Leo
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain
> > Manni-Bucau
> > > <
> > > > >> > > > > > > > > rmannibucau@gmail.com
> > > > >> > > > > > > > > > > wrote:
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > >> Get the Transactionmanager injected (@Resource)
> > and
> > > > >> call
> > > > >> > > > > > > > > >> setTransactionTimeout(seconds)
> > > > >> > > > > > > > > >>
> > > > >> > > > > > > > > >>
> > > > >> > > > > > > > > >> Romain Manni-Bucau
> > > > >> > > > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau>
> |
> > > > Blog
> > > > >> > > > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > >> > > > > > > > > >> https://github.com/rmannibucau> |
> > > > >> > > > > > > > > >> LinkedIn <
> > https://www.linkedin.com/in/rmannibucau>
> > > |
> > > > >> > > > Tomitriber
> > > > >> > > > > > > > > >> <http://www.tomitribe.com>
> > > > >> > > > > > > > > >>
> > > > >> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida
> <
> > > > >> > > > > shikida@gmail.com
> > > > >> > > > > > >:
> > > > >> > > > > > > > > >>
> > > > >> > > > > > > > > >> > Hi
> > > > >> > > > > > > > > >> >
> > > > >> > > > > > > > > >> > How do I increase the MDB onMessage()
> > transaction
> > > > >> > timeout?
> > > > >> > > > > > > > > >> >
> > > > >> > > > > > > > > >> > []
> > > > >> > > > > > > > > >> >
> > > > >> > > > > > > > > >> > Leo
> > > > >> > > > > > > > > >> >
> > > > >> > > > > > > > > >>
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > >
> > > > >> > > > > > > >
> > > > >> > > > > > >
> > > > >> > > > > >
> > > > >> > > > >
> > > > >> > > >
> > > > >> > >
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by Romain Manni-Bucau <rm...@gmail.com>.
well transaction timeout = exception + rollback if transaction took more
than X but the execution time is still the real one.

you can do using bean managed transactions:

Exception oops = null;
try {
  userTransaction.begin();
} cath (Exception e) {
  oops = e;
} finally { // add the logic you want here
  if (oops == null) {
    userTransaction.commit();
    return;
  }

  userTransaction.rollback();
}

It doesnt match your need?


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-15 14:15 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:

> If there's an external event to the MDB like a timeout (which exception I
> cannot catch), then it should have something like a @Timeout annotation so
> I could customize how the event could be handled.
>
> Not tomee's problem of course, tomee just implements a standard.
>
> :-(
>
> Gonna think on something else here.
>
>
> []
>
> Leo
>
> On Wed, Apr 15, 2015 at 4:21 AM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > hmm, my proposal was to use UserTransaction more than that. About this
> > particular exemple we would need a maven project to reproduce it.
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-04-15 4:05 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> >
> > > Hi
> > >
> > > So I've changed my MDBs to stateless
> > >
> > > public class Worker implements MessageListener {
> > >
> > >     @Resource(name="MyJmsConnectionFactory")
> > >     private ConnectionFactory connectionFactory;
> > >
> > >     @Resource(name="DriverJobQueue")
> > >     private Queue queue;
> > >
> > >     private Connection connection = null;
> > >     private Session session = null;
> > >     private MessageConsumer consumer = null;
> > >
> > >     @PostConstruct
> > >     public void initialize() {
> > >         System.out.println("Instantiating "+this);
> > >         try {
> > >             connection = connectionFactory.createConnection();
> > >             connection.start(); //activemq site says it's here
> > >             // Create a Session
> > >             session = connection.createSession(false,
> > > Session.AUTO_ACKNOWLEDGE);
> > >
> > >             // Create a MessageConsumer from the Session to the Topic
> or
> > > Queue
> > >             consumer = session.createConsumer(this.queue);
> > >
> > >             consumer.setMessageListener(this);
> > >
> > > //            connection.start(); //some sites says it's here
> > >
> > >         } catch(Exception e) {
> > >             e.printStackTrace();
> > >         } finally {
> > >             if (consumer != null) {
> > >                 try {
> > >                     consumer.close();
> > >                 } catch (JMSException e) {
> > >                     e.printStackTrace();
> > >                 }
> > >             }
> > >             if (session != null) {
> > >                 try {
> > >                     session.close();
> > >                 } catch (JMSException e) {
> > >                     e.printStackTrace();
> > >                 }
> > >             }
> > >             if (connection != null) {
> > >                 try {
> > >                     connection.close();
> > >                 } catch (JMSException e) {
> > >                     e.printStackTrace();
> > >                 }
> > >             }
> > >         }
> > >     }
> > >
> > >     @Override
> > >     public void onMessage(Message msg) {
> > >         System.out.println("On message for "+this);
> > >     }
> > >
> > > openejb-jar.xml
> > >
> > > <?xml version="1.0"?>
> > > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
> > >     <ejb-deployment
> > >         ejb-name="Worker"
> > >         deployment-id="Worker"
> > >         container-id="pseudo_mdb" />
> > > </openejb-jar>
> > >
> > > tomee.xml
> > >
> > >     <Container id="myAllContainer" type="STATELESS">
> > >     strictPooling = false
> > >     </Container>
> > >
> > >     <Container id="pseudo_mdb" type="STATELESS">
> > >     strictPooling = true
> > >     maxSize = 5
> > >     minSize = 3
> > >     </Container>
> > >
> > > The container part seems to be right, since only the Worker bean is
> > > instantiated early.
> > >
> > > But for some reason, it's not consuming from the queue.
> > >
> > > Am I missing something here?
> > >
> > > Still, I feel I am running in circles here... because even if I have
> some
> > > control on the context, I still won't be able to catch the timeout
> > > exception :-(
> > >
> > > grrrrrrrrrrrr
> > >
> > > []
> > >
> > > Leo
> > >
> > > On Tue, Apr 14, 2015 at 6:08 PM, Leonardo K. Shikida <
> shikida@gmail.com>
> > > wrote:
> > >
> > > > thx!
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > > > On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <
> > > rmannibucau@gmail.com
> > > > > wrote:
> > > >
> > > >> using openejb-jar.xml you can wire a container to some beans only.
> > > >>
> > > >>
> > > >> Romain Manni-Bucau
> > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > >> <http://rmannibucau.wordpress.com> | Github <
> > > >> https://github.com/rmannibucau> |
> > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > >> <http://www.tomitribe.com>
> > > >>
> > > >> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > > >>
> > > >> > yeah, I think this will be the way to go
> > > >> >
> > > >> > since I can configure max/min instances for stateless (
> > > >> > http://tomee.apache.org/statelesscontainer-config.html) I think I
> > can
> > > >> just
> > > >> > create a pool of stateless instances to work as MDBs that can deal
> > > with
> > > >> > timeout :-)
> > > >> >
> > > >> > is there any way to configure a container just for these specfic
> > > >> stateless
> > > >> > EJBs (so some other configuration can be used for stateless by
> > > default)?
> > > >> >
> > > >> > []
> > > >> >
> > > >> > Leo
> > > >> >
> > > >> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
> > > >> rmannibucau@gmail.com
> > > >> > >
> > > >> > wrote:
> > > >> >
> > > >> > > so just handle transactions yourself
> > > >> > >
> > > >> > >
> > > >> > > Romain Manni-Bucau
> > > >> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > >> > > <http://rmannibucau.wordpress.com> | Github <
> > > >> > > https://github.com/rmannibucau> |
> > > >> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > >> > > <http://www.tomitribe.com>
> > > >> > >
> > > >> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <
> > > itsmeden@gmail.com
> > > >> >:
> > > >> > >
> > > >> > > > Another option is to look at the redelivered
> property/redelivery
> > > >> count
> > > >> > > and
> > > >> > > > take action (write to db?) in case of redelivery....  requires
> > you
> > > >> to
> > > >> > > set a
> > > >> > > > redelivery policy / number of retries etc
> > > >> > > >
> > > >> > > > /LF
> > > >> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <
> > > shikida@gmail.com>
> > > >> > > wrote:
> > > >> > > >
> > > >> > > > > Yup, but if the MDB timeout, I need to set something in the
> > DB,
> > > >> > that's
> > > >> > > > why
> > > >> > > > > I need to treat the timeout.
> > > >> > > > >
> > > >> > > > > If the job to be executed timeout, then it will probably
> > timeout
> > > >> for
> > > >> > > any
> > > >> > > > > retry, because it's caused by a poorly chosen parameter, so
> > > >> retries
> > > >> > are
> > > >> > > > not
> > > >> > > > > important here (although increasing timeouts on each retry
> > could
> > > >> be
> > > >> > an
> > > >> > > > > interesting option)
> > > >> > > > >
> > > >> > > > > []
> > > >> > > > >
> > > >> > > > > Leo
> > > >> > > > >
> > > >> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> > > >> > > > rmannibucau@gmail.com
> > > >> > > > > >
> > > >> > > > > wrote:
> > > >> > > > >
> > > >> > > > > > Hmm, with MDBs you have retries since they are
> > transactional.
> > > >> you
> > > >> > can
> > > >> > > > > even
> > > >> > > > > > configure the redelivery policy with an exponential
> backoff
> > > and
> > > >> so
> > > >> > on
> > > >> > > > if
> > > >> > > > > > really needed
> > > >> > > > > >
> > > >> > > > > >
> > > >> > > > > > Romain Manni-Bucau
> > > >> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > >> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > >> > > > > > https://github.com/rmannibucau> |
> > > >> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > Tomitriber
> > > >> > > > > > <http://www.tomitribe.com>
> > > >> > > > > >
> > > >> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
> > > >> shikida@gmail.com
> > > >> > >:
> > > >> > > > > >
> > > >> > > > > > > Well, what I need is a pool of workers to listen to a
> > queue
> > > >> and
> > > >> > > > process
> > > >> > > > > > > messages while they come, but I also need to properly
> > treat
> > > >> them
> > > >> > > when
> > > >> > > > > the
> > > >> > > > > > > JMS transaction times out.
> > > >> > > > > > >
> > > >> > > > > > > So I guess I can't use a MDB here right?
> > > >> > > > > > >
> > > >> > > > > > > What would be a good approach in this situation?
> > > >> > > > > > >
> > > >> > > > > > > []
> > > >> > > > > > >
> > > >> > > > > > > Leo
> > > >> > > > > > >
> > > >> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> > > >> > > > > > rmannibucau@gmail.com
> > > >> > > > > > > >
> > > >> > > > > > > wrote:
> > > >> > > > > > >
> > > >> > > > > > > > if you want to control and be able to catch it you
> need
> > to
> > > >> > handle
> > > >> > > > > > > yourself
> > > >> > > > > > > > the transaction otherwise if it takes more then you'll
> > > get a
> > > >> > > > rollback
> > > >> > > > > > > and a
> > > >> > > > > > > > (surely wrapped) RollbackException
> > > >> > > > > > > >
> > > >> > > > > > > >
> > > >> > > > > > > > Romain Manni-Bucau
> > > >> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> Blog
> > > >> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > >> > > > > > > > https://github.com/rmannibucau> |
> > > >> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > >> > Tomitriber
> > > >> > > > > > > > <http://www.tomitribe.com>
> > > >> > > > > > > >
> > > >> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
> > > >> > > shikida@gmail.com
> > > >> > > > >:
> > > >> > > > > > > >
> > > >> > > > > > > > > just checking
> > > >> > > > > > > > >
> > > >> > > > > > > > > I just add
> > > >> > > > > > > > >
> > > >> > > > > > > > >     @Resource
> > > >> > > > > > > > >     private TransactionManager tx;
> > > >> > > > > > > > >
> > > >> > > > > > > > >
> > > >> > > > > > > > > and in the MDB initialization I set some timeout
> > > >> > > > > > > > >
> > > >> > > > > > > > >     @PostConstruct
> > > >> > > > > > > > >     public void initialize() {
> > > >> > > > > > > > >         try {
> > > >> > > > > > > > >             tx.setTransactionTimeout(3);
> > > >> > > > > > > > >         } catch (SystemException e) {
> > > >> > > > > > > > >             e.printStackTrace();
> > > >> > > > > > > > >         }
> > > >> > > > > > > > >     }
> > > >> > > > > > > > >
> > > >> > > > > > > > > and when my onMessage() executes, if it takes more
> > than
> > > 3
> > > >> > > seconds
> > > >> > > > > to
> > > >> > > > > > > > > complete, it throws and exception?
> > > >> > > > > > > > >
> > > >> > > > > > > > > and if so, how do I catch it? (or I don't?)
> > > >> > > > > > > > >
> > > >> > > > > > > > > []
> > > >> > > > > > > > >
> > > >> > > > > > > > > Leo
> > > >> > > > > > > > >
> > > >> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K.
> Shikida <
> > > >> > > > > > > shikida@gmail.com>
> > > >> > > > > > > > > wrote:
> > > >> > > > > > > > >
> > > >> > > > > > > > > > thx!
> > > >> > > > > > > > > >
> > > >> > > > > > > > > > []
> > > >> > > > > > > > > >
> > > >> > > > > > > > > > Leo
> > > >> > > > > > > > > >
> > > >> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain
> Manni-Bucau
> > <
> > > >> > > > > > > > > rmannibucau@gmail.com
> > > >> > > > > > > > > > > wrote:
> > > >> > > > > > > > > >
> > > >> > > > > > > > > >> Get the Transactionmanager injected (@Resource)
> and
> > > >> call
> > > >> > > > > > > > > >> setTransactionTimeout(seconds)
> > > >> > > > > > > > > >>
> > > >> > > > > > > > > >>
> > > >> > > > > > > > > >> Romain Manni-Bucau
> > > >> > > > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |
> > > Blog
> > > >> > > > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > >> > > > > > > > > >> https://github.com/rmannibucau> |
> > > >> > > > > > > > > >> LinkedIn <
> https://www.linkedin.com/in/rmannibucau>
> > |
> > > >> > > > Tomitriber
> > > >> > > > > > > > > >> <http://www.tomitribe.com>
> > > >> > > > > > > > > >>
> > > >> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <
> > > >> > > > > shikida@gmail.com
> > > >> > > > > > >:
> > > >> > > > > > > > > >>
> > > >> > > > > > > > > >> > Hi
> > > >> > > > > > > > > >> >
> > > >> > > > > > > > > >> > How do I increase the MDB onMessage()
> transaction
> > > >> > timeout?
> > > >> > > > > > > > > >> >
> > > >> > > > > > > > > >> > []
> > > >> > > > > > > > > >> >
> > > >> > > > > > > > > >> > Leo
> > > >> > > > > > > > > >> >
> > > >> > > > > > > > > >>
> > > >> > > > > > > > > >
> > > >> > > > > > > > > >
> > > >> > > > > > > > >
> > > >> > > > > > > >
> > > >> > > > > > >
> > > >> > > > > >
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
If there's an external event to the MDB like a timeout (which exception I
cannot catch), then it should have something like a @Timeout annotation so
I could customize how the event could be handled.

Not tomee's problem of course, tomee just implements a standard.

:-(

Gonna think on something else here.


[]

Leo

On Wed, Apr 15, 2015 at 4:21 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> hmm, my proposal was to use UserTransaction more than that. About this
> particular exemple we would need a maven project to reproduce it.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-15 4:05 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>
> > Hi
> >
> > So I've changed my MDBs to stateless
> >
> > public class Worker implements MessageListener {
> >
> >     @Resource(name="MyJmsConnectionFactory")
> >     private ConnectionFactory connectionFactory;
> >
> >     @Resource(name="DriverJobQueue")
> >     private Queue queue;
> >
> >     private Connection connection = null;
> >     private Session session = null;
> >     private MessageConsumer consumer = null;
> >
> >     @PostConstruct
> >     public void initialize() {
> >         System.out.println("Instantiating "+this);
> >         try {
> >             connection = connectionFactory.createConnection();
> >             connection.start(); //activemq site says it's here
> >             // Create a Session
> >             session = connection.createSession(false,
> > Session.AUTO_ACKNOWLEDGE);
> >
> >             // Create a MessageConsumer from the Session to the Topic or
> > Queue
> >             consumer = session.createConsumer(this.queue);
> >
> >             consumer.setMessageListener(this);
> >
> > //            connection.start(); //some sites says it's here
> >
> >         } catch(Exception e) {
> >             e.printStackTrace();
> >         } finally {
> >             if (consumer != null) {
> >                 try {
> >                     consumer.close();
> >                 } catch (JMSException e) {
> >                     e.printStackTrace();
> >                 }
> >             }
> >             if (session != null) {
> >                 try {
> >                     session.close();
> >                 } catch (JMSException e) {
> >                     e.printStackTrace();
> >                 }
> >             }
> >             if (connection != null) {
> >                 try {
> >                     connection.close();
> >                 } catch (JMSException e) {
> >                     e.printStackTrace();
> >                 }
> >             }
> >         }
> >     }
> >
> >     @Override
> >     public void onMessage(Message msg) {
> >         System.out.println("On message for "+this);
> >     }
> >
> > openejb-jar.xml
> >
> > <?xml version="1.0"?>
> > <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
> >     <ejb-deployment
> >         ejb-name="Worker"
> >         deployment-id="Worker"
> >         container-id="pseudo_mdb" />
> > </openejb-jar>
> >
> > tomee.xml
> >
> >     <Container id="myAllContainer" type="STATELESS">
> >     strictPooling = false
> >     </Container>
> >
> >     <Container id="pseudo_mdb" type="STATELESS">
> >     strictPooling = true
> >     maxSize = 5
> >     minSize = 3
> >     </Container>
> >
> > The container part seems to be right, since only the Worker bean is
> > instantiated early.
> >
> > But for some reason, it's not consuming from the queue.
> >
> > Am I missing something here?
> >
> > Still, I feel I am running in circles here... because even if I have some
> > control on the context, I still won't be able to catch the timeout
> > exception :-(
> >
> > grrrrrrrrrrrr
> >
> > []
> >
> > Leo
> >
> > On Tue, Apr 14, 2015 at 6:08 PM, Leonardo K. Shikida <sh...@gmail.com>
> > wrote:
> >
> > > thx!
> > >
> > > []
> > >
> > > Leo
> > >
> > > On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <
> > rmannibucau@gmail.com
> > > > wrote:
> > >
> > >> using openejb-jar.xml you can wire a container to some beans only.
> > >>
> > >>
> > >> Romain Manni-Bucau
> > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > >> <http://rmannibucau.wordpress.com> | Github <
> > >> https://github.com/rmannibucau> |
> > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > >> <http://www.tomitribe.com>
> > >>
> > >> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > >>
> > >> > yeah, I think this will be the way to go
> > >> >
> > >> > since I can configure max/min instances for stateless (
> > >> > http://tomee.apache.org/statelesscontainer-config.html) I think I
> can
> > >> just
> > >> > create a pool of stateless instances to work as MDBs that can deal
> > with
> > >> > timeout :-)
> > >> >
> > >> > is there any way to configure a container just for these specfic
> > >> stateless
> > >> > EJBs (so some other configuration can be used for stateless by
> > default)?
> > >> >
> > >> > []
> > >> >
> > >> > Leo
> > >> >
> > >> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
> > >> rmannibucau@gmail.com
> > >> > >
> > >> > wrote:
> > >> >
> > >> > > so just handle transactions yourself
> > >> > >
> > >> > >
> > >> > > Romain Manni-Bucau
> > >> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > >> > > <http://rmannibucau.wordpress.com> | Github <
> > >> > > https://github.com/rmannibucau> |
> > >> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > >> > > <http://www.tomitribe.com>
> > >> > >
> > >> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <
> > itsmeden@gmail.com
> > >> >:
> > >> > >
> > >> > > > Another option is to look at the redelivered property/redelivery
> > >> count
> > >> > > and
> > >> > > > take action (write to db?) in case of redelivery....  requires
> you
> > >> to
> > >> > > set a
> > >> > > > redelivery policy / number of retries etc
> > >> > > >
> > >> > > > /LF
> > >> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <
> > shikida@gmail.com>
> > >> > > wrote:
> > >> > > >
> > >> > > > > Yup, but if the MDB timeout, I need to set something in the
> DB,
> > >> > that's
> > >> > > > why
> > >> > > > > I need to treat the timeout.
> > >> > > > >
> > >> > > > > If the job to be executed timeout, then it will probably
> timeout
> > >> for
> > >> > > any
> > >> > > > > retry, because it's caused by a poorly chosen parameter, so
> > >> retries
> > >> > are
> > >> > > > not
> > >> > > > > important here (although increasing timeouts on each retry
> could
> > >> be
> > >> > an
> > >> > > > > interesting option)
> > >> > > > >
> > >> > > > > []
> > >> > > > >
> > >> > > > > Leo
> > >> > > > >
> > >> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> > >> > > > rmannibucau@gmail.com
> > >> > > > > >
> > >> > > > > wrote:
> > >> > > > >
> > >> > > > > > Hmm, with MDBs you have retries since they are
> transactional.
> > >> you
> > >> > can
> > >> > > > > even
> > >> > > > > > configure the redelivery policy with an exponential backoff
> > and
> > >> so
> > >> > on
> > >> > > > if
> > >> > > > > > really needed
> > >> > > > > >
> > >> > > > > >
> > >> > > > > > Romain Manni-Bucau
> > >> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > >> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > >> > > > > > https://github.com/rmannibucau> |
> > >> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > >> > > > > > <http://www.tomitribe.com>
> > >> > > > > >
> > >> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
> > >> shikida@gmail.com
> > >> > >:
> > >> > > > > >
> > >> > > > > > > Well, what I need is a pool of workers to listen to a
> queue
> > >> and
> > >> > > > process
> > >> > > > > > > messages while they come, but I also need to properly
> treat
> > >> them
> > >> > > when
> > >> > > > > the
> > >> > > > > > > JMS transaction times out.
> > >> > > > > > >
> > >> > > > > > > So I guess I can't use a MDB here right?
> > >> > > > > > >
> > >> > > > > > > What would be a good approach in this situation?
> > >> > > > > > >
> > >> > > > > > > []
> > >> > > > > > >
> > >> > > > > > > Leo
> > >> > > > > > >
> > >> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> > >> > > > > > rmannibucau@gmail.com
> > >> > > > > > > >
> > >> > > > > > > wrote:
> > >> > > > > > >
> > >> > > > > > > > if you want to control and be able to catch it you need
> to
> > >> > handle
> > >> > > > > > > yourself
> > >> > > > > > > > the transaction otherwise if it takes more then you'll
> > get a
> > >> > > > rollback
> > >> > > > > > > and a
> > >> > > > > > > > (surely wrapped) RollbackException
> > >> > > > > > > >
> > >> > > > > > > >
> > >> > > > > > > > Romain Manni-Bucau
> > >> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > >> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > >> > > > > > > > https://github.com/rmannibucau> |
> > >> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > >> > Tomitriber
> > >> > > > > > > > <http://www.tomitribe.com>
> > >> > > > > > > >
> > >> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
> > >> > > shikida@gmail.com
> > >> > > > >:
> > >> > > > > > > >
> > >> > > > > > > > > just checking
> > >> > > > > > > > >
> > >> > > > > > > > > I just add
> > >> > > > > > > > >
> > >> > > > > > > > >     @Resource
> > >> > > > > > > > >     private TransactionManager tx;
> > >> > > > > > > > >
> > >> > > > > > > > >
> > >> > > > > > > > > and in the MDB initialization I set some timeout
> > >> > > > > > > > >
> > >> > > > > > > > >     @PostConstruct
> > >> > > > > > > > >     public void initialize() {
> > >> > > > > > > > >         try {
> > >> > > > > > > > >             tx.setTransactionTimeout(3);
> > >> > > > > > > > >         } catch (SystemException e) {
> > >> > > > > > > > >             e.printStackTrace();
> > >> > > > > > > > >         }
> > >> > > > > > > > >     }
> > >> > > > > > > > >
> > >> > > > > > > > > and when my onMessage() executes, if it takes more
> than
> > 3
> > >> > > seconds
> > >> > > > > to
> > >> > > > > > > > > complete, it throws and exception?
> > >> > > > > > > > >
> > >> > > > > > > > > and if so, how do I catch it? (or I don't?)
> > >> > > > > > > > >
> > >> > > > > > > > > []
> > >> > > > > > > > >
> > >> > > > > > > > > Leo
> > >> > > > > > > > >
> > >> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
> > >> > > > > > > shikida@gmail.com>
> > >> > > > > > > > > wrote:
> > >> > > > > > > > >
> > >> > > > > > > > > > thx!
> > >> > > > > > > > > >
> > >> > > > > > > > > > []
> > >> > > > > > > > > >
> > >> > > > > > > > > > Leo
> > >> > > > > > > > > >
> > >> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau
> <
> > >> > > > > > > > > rmannibucau@gmail.com
> > >> > > > > > > > > > > wrote:
> > >> > > > > > > > > >
> > >> > > > > > > > > >> Get the Transactionmanager injected (@Resource) and
> > >> call
> > >> > > > > > > > > >> setTransactionTimeout(seconds)
> > >> > > > > > > > > >>
> > >> > > > > > > > > >>
> > >> > > > > > > > > >> Romain Manni-Bucau
> > >> > > > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |
> > Blog
> > >> > > > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > >> > > > > > > > > >> https://github.com/rmannibucau> |
> > >> > > > > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau>
> |
> > >> > > > Tomitriber
> > >> > > > > > > > > >> <http://www.tomitribe.com>
> > >> > > > > > > > > >>
> > >> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <
> > >> > > > > shikida@gmail.com
> > >> > > > > > >:
> > >> > > > > > > > > >>
> > >> > > > > > > > > >> > Hi
> > >> > > > > > > > > >> >
> > >> > > > > > > > > >> > How do I increase the MDB onMessage() transaction
> > >> > timeout?
> > >> > > > > > > > > >> >
> > >> > > > > > > > > >> > []
> > >> > > > > > > > > >> >
> > >> > > > > > > > > >> > Leo
> > >> > > > > > > > > >> >
> > >> > > > > > > > > >>
> > >> > > > > > > > > >
> > >> > > > > > > > > >
> > >> > > > > > > > >
> > >> > > > > > > >
> > >> > > > > > >
> > >> > > > > >
> > >> > > > >
> > >> > > >
> > >> > >
> > >> >
> > >>
> > >
> > >
> >
>

Re: MDB transaction timeout

Posted by Romain Manni-Bucau <rm...@gmail.com>.
hmm, my proposal was to use UserTransaction more than that. About this
particular exemple we would need a maven project to reproduce it.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-15 4:05 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:

> Hi
>
> So I've changed my MDBs to stateless
>
> public class Worker implements MessageListener {
>
>     @Resource(name="MyJmsConnectionFactory")
>     private ConnectionFactory connectionFactory;
>
>     @Resource(name="DriverJobQueue")
>     private Queue queue;
>
>     private Connection connection = null;
>     private Session session = null;
>     private MessageConsumer consumer = null;
>
>     @PostConstruct
>     public void initialize() {
>         System.out.println("Instantiating "+this);
>         try {
>             connection = connectionFactory.createConnection();
>             connection.start(); //activemq site says it's here
>             // Create a Session
>             session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
>             // Create a MessageConsumer from the Session to the Topic or
> Queue
>             consumer = session.createConsumer(this.queue);
>
>             consumer.setMessageListener(this);
>
> //            connection.start(); //some sites says it's here
>
>         } catch(Exception e) {
>             e.printStackTrace();
>         } finally {
>             if (consumer != null) {
>                 try {
>                     consumer.close();
>                 } catch (JMSException e) {
>                     e.printStackTrace();
>                 }
>             }
>             if (session != null) {
>                 try {
>                     session.close();
>                 } catch (JMSException e) {
>                     e.printStackTrace();
>                 }
>             }
>             if (connection != null) {
>                 try {
>                     connection.close();
>                 } catch (JMSException e) {
>                     e.printStackTrace();
>                 }
>             }
>         }
>     }
>
>     @Override
>     public void onMessage(Message msg) {
>         System.out.println("On message for "+this);
>     }
>
> openejb-jar.xml
>
> <?xml version="1.0"?>
> <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
>     <ejb-deployment
>         ejb-name="Worker"
>         deployment-id="Worker"
>         container-id="pseudo_mdb" />
> </openejb-jar>
>
> tomee.xml
>
>     <Container id="myAllContainer" type="STATELESS">
>     strictPooling = false
>     </Container>
>
>     <Container id="pseudo_mdb" type="STATELESS">
>     strictPooling = true
>     maxSize = 5
>     minSize = 3
>     </Container>
>
> The container part seems to be right, since only the Worker bean is
> instantiated early.
>
> But for some reason, it's not consuming from the queue.
>
> Am I missing something here?
>
> Still, I feel I am running in circles here... because even if I have some
> control on the context, I still won't be able to catch the timeout
> exception :-(
>
> grrrrrrrrrrrr
>
> []
>
> Leo
>
> On Tue, Apr 14, 2015 at 6:08 PM, Leonardo K. Shikida <sh...@gmail.com>
> wrote:
>
> > thx!
> >
> > []
> >
> > Leo
> >
> > On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > > wrote:
> >
> >> using openejb-jar.xml you can wire a container to some beans only.
> >>
> >>
> >> Romain Manni-Bucau
> >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> >> <http://rmannibucau.wordpress.com> | Github <
> >> https://github.com/rmannibucau> |
> >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> >> <http://www.tomitribe.com>
> >>
> >> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> >>
> >> > yeah, I think this will be the way to go
> >> >
> >> > since I can configure max/min instances for stateless (
> >> > http://tomee.apache.org/statelesscontainer-config.html) I think I can
> >> just
> >> > create a pool of stateless instances to work as MDBs that can deal
> with
> >> > timeout :-)
> >> >
> >> > is there any way to configure a container just for these specfic
> >> stateless
> >> > EJBs (so some other configuration can be used for stateless by
> default)?
> >> >
> >> > []
> >> >
> >> > Leo
> >> >
> >> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
> >> rmannibucau@gmail.com
> >> > >
> >> > wrote:
> >> >
> >> > > so just handle transactions yourself
> >> > >
> >> > >
> >> > > Romain Manni-Bucau
> >> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> >> > > <http://rmannibucau.wordpress.com> | Github <
> >> > > https://github.com/rmannibucau> |
> >> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> >> > > <http://www.tomitribe.com>
> >> > >
> >> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <
> itsmeden@gmail.com
> >> >:
> >> > >
> >> > > > Another option is to look at the redelivered property/redelivery
> >> count
> >> > > and
> >> > > > take action (write to db?) in case of redelivery....  requires you
> >> to
> >> > > set a
> >> > > > redelivery policy / number of retries etc
> >> > > >
> >> > > > /LF
> >> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <
> shikida@gmail.com>
> >> > > wrote:
> >> > > >
> >> > > > > Yup, but if the MDB timeout, I need to set something in the DB,
> >> > that's
> >> > > > why
> >> > > > > I need to treat the timeout.
> >> > > > >
> >> > > > > If the job to be executed timeout, then it will probably timeout
> >> for
> >> > > any
> >> > > > > retry, because it's caused by a poorly chosen parameter, so
> >> retries
> >> > are
> >> > > > not
> >> > > > > important here (although increasing timeouts on each retry could
> >> be
> >> > an
> >> > > > > interesting option)
> >> > > > >
> >> > > > > []
> >> > > > >
> >> > > > > Leo
> >> > > > >
> >> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> >> > > > rmannibucau@gmail.com
> >> > > > > >
> >> > > > > wrote:
> >> > > > >
> >> > > > > > Hmm, with MDBs you have retries since they are transactional.
> >> you
> >> > can
> >> > > > > even
> >> > > > > > configure the redelivery policy with an exponential backoff
> and
> >> so
> >> > on
> >> > > > if
> >> > > > > > really needed
> >> > > > > >
> >> > > > > >
> >> > > > > > Romain Manni-Bucau
> >> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> >> > > > > > <http://rmannibucau.wordpress.com> | Github <
> >> > > > > > https://github.com/rmannibucau> |
> >> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> >> > > > > > <http://www.tomitribe.com>
> >> > > > > >
> >> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
> >> shikida@gmail.com
> >> > >:
> >> > > > > >
> >> > > > > > > Well, what I need is a pool of workers to listen to a queue
> >> and
> >> > > > process
> >> > > > > > > messages while they come, but I also need to properly treat
> >> them
> >> > > when
> >> > > > > the
> >> > > > > > > JMS transaction times out.
> >> > > > > > >
> >> > > > > > > So I guess I can't use a MDB here right?
> >> > > > > > >
> >> > > > > > > What would be a good approach in this situation?
> >> > > > > > >
> >> > > > > > > []
> >> > > > > > >
> >> > > > > > > Leo
> >> > > > > > >
> >> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> >> > > > > > rmannibucau@gmail.com
> >> > > > > > > >
> >> > > > > > > wrote:
> >> > > > > > >
> >> > > > > > > > if you want to control and be able to catch it you need to
> >> > handle
> >> > > > > > > yourself
> >> > > > > > > > the transaction otherwise if it takes more then you'll
> get a
> >> > > > rollback
> >> > > > > > > and a
> >> > > > > > > > (surely wrapped) RollbackException
> >> > > > > > > >
> >> > > > > > > >
> >> > > > > > > > Romain Manni-Bucau
> >> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> >> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> >> > > > > > > > https://github.com/rmannibucau> |
> >> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> >> > Tomitriber
> >> > > > > > > > <http://www.tomitribe.com>
> >> > > > > > > >
> >> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
> >> > > shikida@gmail.com
> >> > > > >:
> >> > > > > > > >
> >> > > > > > > > > just checking
> >> > > > > > > > >
> >> > > > > > > > > I just add
> >> > > > > > > > >
> >> > > > > > > > >     @Resource
> >> > > > > > > > >     private TransactionManager tx;
> >> > > > > > > > >
> >> > > > > > > > >
> >> > > > > > > > > and in the MDB initialization I set some timeout
> >> > > > > > > > >
> >> > > > > > > > >     @PostConstruct
> >> > > > > > > > >     public void initialize() {
> >> > > > > > > > >         try {
> >> > > > > > > > >             tx.setTransactionTimeout(3);
> >> > > > > > > > >         } catch (SystemException e) {
> >> > > > > > > > >             e.printStackTrace();
> >> > > > > > > > >         }
> >> > > > > > > > >     }
> >> > > > > > > > >
> >> > > > > > > > > and when my onMessage() executes, if it takes more than
> 3
> >> > > seconds
> >> > > > > to
> >> > > > > > > > > complete, it throws and exception?
> >> > > > > > > > >
> >> > > > > > > > > and if so, how do I catch it? (or I don't?)
> >> > > > > > > > >
> >> > > > > > > > > []
> >> > > > > > > > >
> >> > > > > > > > > Leo
> >> > > > > > > > >
> >> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
> >> > > > > > > shikida@gmail.com>
> >> > > > > > > > > wrote:
> >> > > > > > > > >
> >> > > > > > > > > > thx!
> >> > > > > > > > > >
> >> > > > > > > > > > []
> >> > > > > > > > > >
> >> > > > > > > > > > Leo
> >> > > > > > > > > >
> >> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> >> > > > > > > > > rmannibucau@gmail.com
> >> > > > > > > > > > > wrote:
> >> > > > > > > > > >
> >> > > > > > > > > >> Get the Transactionmanager injected (@Resource) and
> >> call
> >> > > > > > > > > >> setTransactionTimeout(seconds)
> >> > > > > > > > > >>
> >> > > > > > > > > >>
> >> > > > > > > > > >> Romain Manni-Bucau
> >> > > > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |
> Blog
> >> > > > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> >> > > > > > > > > >> https://github.com/rmannibucau> |
> >> > > > > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> >> > > > Tomitriber
> >> > > > > > > > > >> <http://www.tomitribe.com>
> >> > > > > > > > > >>
> >> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <
> >> > > > > shikida@gmail.com
> >> > > > > > >:
> >> > > > > > > > > >>
> >> > > > > > > > > >> > Hi
> >> > > > > > > > > >> >
> >> > > > > > > > > >> > How do I increase the MDB onMessage() transaction
> >> > timeout?
> >> > > > > > > > > >> >
> >> > > > > > > > > >> > []
> >> > > > > > > > > >> >
> >> > > > > > > > > >> > Leo
> >> > > > > > > > > >> >
> >> > > > > > > > > >>
> >> > > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > >
> >> > > > > > > >
> >> > > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> >
> >
>

Re: MDB transaction timeout

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

So I've changed my MDBs to stateless

public class Worker implements MessageListener {

    @Resource(name="MyJmsConnectionFactory")
    private ConnectionFactory connectionFactory;

    @Resource(name="DriverJobQueue")
    private Queue queue;

    private Connection connection = null;
    private Session session = null;
    private MessageConsumer consumer = null;

    @PostConstruct
    public void initialize() {
        System.out.println("Instantiating "+this);
        try {
            connection = connectionFactory.createConnection();
            connection.start(); //activemq site says it's here
            // Create a Session
            session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);

            // Create a MessageConsumer from the Session to the Topic or
Queue
            consumer = session.createConsumer(this.queue);

            consumer.setMessageListener(this);

//            connection.start(); //some sites says it's here

        } catch(Exception e) {
            e.printStackTrace();
        } finally {
            if (consumer != null) {
                try {
                    consumer.close();
                } catch (JMSException e) {
                    e.printStackTrace();
                }
            }
            if (session != null) {
                try {
                    session.close();
                } catch (JMSException e) {
                    e.printStackTrace();
                }
            }
            if (connection != null) {
                try {
                    connection.close();
                } catch (JMSException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    @Override
    public void onMessage(Message msg) {
        System.out.println("On message for "+this);
    }

openejb-jar.xml

<?xml version="1.0"?>
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
    <ejb-deployment
        ejb-name="Worker"
        deployment-id="Worker"
        container-id="pseudo_mdb" />
</openejb-jar>

tomee.xml

    <Container id="myAllContainer" type="STATELESS">
    strictPooling = false
    </Container>

    <Container id="pseudo_mdb" type="STATELESS">
    strictPooling = true
    maxSize = 5
    minSize = 3
    </Container>

The container part seems to be right, since only the Worker bean is
instantiated early.

But for some reason, it's not consuming from the queue.

Am I missing something here?

Still, I feel I am running in circles here... because even if I have some
control on the context, I still won't be able to catch the timeout
exception :-(

grrrrrrrrrrrr

[]

Leo

On Tue, Apr 14, 2015 at 6:08 PM, Leonardo K. Shikida <sh...@gmail.com>
wrote:

> thx!
>
> []
>
> Leo
>
> On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> > wrote:
>
>> using openejb-jar.xml you can wire a container to some beans only.
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> <http://rmannibucau.wordpress.com> | Github <
>> https://github.com/rmannibucau> |
>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
>> <http://www.tomitribe.com>
>>
>> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>>
>> > yeah, I think this will be the way to go
>> >
>> > since I can configure max/min instances for stateless (
>> > http://tomee.apache.org/statelesscontainer-config.html) I think I can
>> just
>> > create a pool of stateless instances to work as MDBs that can deal with
>> > timeout :-)
>> >
>> > is there any way to configure a container just for these specfic
>> stateless
>> > EJBs (so some other configuration can be used for stateless by default)?
>> >
>> > []
>> >
>> > Leo
>> >
>> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
>> rmannibucau@gmail.com
>> > >
>> > wrote:
>> >
>> > > so just handle transactions yourself
>> > >
>> > >
>> > > Romain Manni-Bucau
>> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> > > <http://rmannibucau.wordpress.com> | Github <
>> > > https://github.com/rmannibucau> |
>> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
>> > > <http://www.tomitribe.com>
>> > >
>> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <itsmeden@gmail.com
>> >:
>> > >
>> > > > Another option is to look at the redelivered property/redelivery
>> count
>> > > and
>> > > > take action (write to db?) in case of redelivery....  requires you
>> to
>> > > set a
>> > > > redelivery policy / number of retries etc
>> > > >
>> > > > /LF
>> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <sh...@gmail.com>
>> > > wrote:
>> > > >
>> > > > > Yup, but if the MDB timeout, I need to set something in the DB,
>> > that's
>> > > > why
>> > > > > I need to treat the timeout.
>> > > > >
>> > > > > If the job to be executed timeout, then it will probably timeout
>> for
>> > > any
>> > > > > retry, because it's caused by a poorly chosen parameter, so
>> retries
>> > are
>> > > > not
>> > > > > important here (although increasing timeouts on each retry could
>> be
>> > an
>> > > > > interesting option)
>> > > > >
>> > > > > []
>> > > > >
>> > > > > Leo
>> > > > >
>> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
>> > > > rmannibucau@gmail.com
>> > > > > >
>> > > > > wrote:
>> > > > >
>> > > > > > Hmm, with MDBs you have retries since they are transactional.
>> you
>> > can
>> > > > > even
>> > > > > > configure the redelivery policy with an exponential backoff and
>> so
>> > on
>> > > > if
>> > > > > > really needed
>> > > > > >
>> > > > > >
>> > > > > > Romain Manni-Bucau
>> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> > > > > > <http://rmannibucau.wordpress.com> | Github <
>> > > > > > https://github.com/rmannibucau> |
>> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
>> > > > > > <http://www.tomitribe.com>
>> > > > > >
>> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
>> shikida@gmail.com
>> > >:
>> > > > > >
>> > > > > > > Well, what I need is a pool of workers to listen to a queue
>> and
>> > > > process
>> > > > > > > messages while they come, but I also need to properly treat
>> them
>> > > when
>> > > > > the
>> > > > > > > JMS transaction times out.
>> > > > > > >
>> > > > > > > So I guess I can't use a MDB here right?
>> > > > > > >
>> > > > > > > What would be a good approach in this situation?
>> > > > > > >
>> > > > > > > []
>> > > > > > >
>> > > > > > > Leo
>> > > > > > >
>> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
>> > > > > > rmannibucau@gmail.com
>> > > > > > > >
>> > > > > > > wrote:
>> > > > > > >
>> > > > > > > > if you want to control and be able to catch it you need to
>> > handle
>> > > > > > > yourself
>> > > > > > > > the transaction otherwise if it takes more then you'll get a
>> > > > rollback
>> > > > > > > and a
>> > > > > > > > (surely wrapped) RollbackException
>> > > > > > > >
>> > > > > > > >
>> > > > > > > > Romain Manni-Bucau
>> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
>> > > > > > > > https://github.com/rmannibucau> |
>> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
>> > Tomitriber
>> > > > > > > > <http://www.tomitribe.com>
>> > > > > > > >
>> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
>> > > shikida@gmail.com
>> > > > >:
>> > > > > > > >
>> > > > > > > > > just checking
>> > > > > > > > >
>> > > > > > > > > I just add
>> > > > > > > > >
>> > > > > > > > >     @Resource
>> > > > > > > > >     private TransactionManager tx;
>> > > > > > > > >
>> > > > > > > > >
>> > > > > > > > > and in the MDB initialization I set some timeout
>> > > > > > > > >
>> > > > > > > > >     @PostConstruct
>> > > > > > > > >     public void initialize() {
>> > > > > > > > >         try {
>> > > > > > > > >             tx.setTransactionTimeout(3);
>> > > > > > > > >         } catch (SystemException e) {
>> > > > > > > > >             e.printStackTrace();
>> > > > > > > > >         }
>> > > > > > > > >     }
>> > > > > > > > >
>> > > > > > > > > and when my onMessage() executes, if it takes more than 3
>> > > seconds
>> > > > > to
>> > > > > > > > > complete, it throws and exception?
>> > > > > > > > >
>> > > > > > > > > and if so, how do I catch it? (or I don't?)
>> > > > > > > > >
>> > > > > > > > > []
>> > > > > > > > >
>> > > > > > > > > Leo
>> > > > > > > > >
>> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
>> > > > > > > shikida@gmail.com>
>> > > > > > > > > wrote:
>> > > > > > > > >
>> > > > > > > > > > thx!
>> > > > > > > > > >
>> > > > > > > > > > []
>> > > > > > > > > >
>> > > > > > > > > > Leo
>> > > > > > > > > >
>> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
>> > > > > > > > > rmannibucau@gmail.com
>> > > > > > > > > > > wrote:
>> > > > > > > > > >
>> > > > > > > > > >> Get the Transactionmanager injected (@Resource) and
>> call
>> > > > > > > > > >> setTransactionTimeout(seconds)
>> > > > > > > > > >>
>> > > > > > > > > >>
>> > > > > > > > > >> Romain Manni-Bucau
>> > > > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> > > > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
>> > > > > > > > > >> https://github.com/rmannibucau> |
>> > > > > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> |
>> > > > Tomitriber
>> > > > > > > > > >> <http://www.tomitribe.com>
>> > > > > > > > > >>
>> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <
>> > > > > shikida@gmail.com
>> > > > > > >:
>> > > > > > > > > >>
>> > > > > > > > > >> > Hi
>> > > > > > > > > >> >
>> > > > > > > > > >> > How do I increase the MDB onMessage() transaction
>> > timeout?
>> > > > > > > > > >> >
>> > > > > > > > > >> > []
>> > > > > > > > > >> >
>> > > > > > > > > >> > Leo
>> > > > > > > > > >> >
>> > > > > > > > > >>
>> > > > > > > > > >
>> > > > > > > > > >
>> > > > > > > > >
>> > > > > > > >
>> > > > > > >
>> > > > > >
>> > > > >
>> > > >
>> > >
>> >
>>
>
>

Re: MDB transaction timeout

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

[]

Leo

On Tue, Apr 14, 2015 at 6:03 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> using openejb-jar.xml you can wire a container to some beans only.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>
> > yeah, I think this will be the way to go
> >
> > since I can configure max/min instances for stateless (
> > http://tomee.apache.org/statelesscontainer-config.html) I think I can
> just
> > create a pool of stateless instances to work as MDBs that can deal with
> > timeout :-)
> >
> > is there any way to configure a container just for these specfic
> stateless
> > EJBs (so some other configuration can be used for stateless by default)?
> >
> > []
> >
> > Leo
> >
> > On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > >
> > wrote:
> >
> > > so just handle transactions yourself
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> > >
> > > > Another option is to look at the redelivered property/redelivery
> count
> > > and
> > > > take action (write to db?) in case of redelivery....  requires you to
> > > set a
> > > > redelivery policy / number of retries etc
> > > >
> > > > /LF
> > > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <sh...@gmail.com>
> > > wrote:
> > > >
> > > > > Yup, but if the MDB timeout, I need to set something in the DB,
> > that's
> > > > why
> > > > > I need to treat the timeout.
> > > > >
> > > > > If the job to be executed timeout, then it will probably timeout
> for
> > > any
> > > > > retry, because it's caused by a poorly chosen parameter, so retries
> > are
> > > > not
> > > > > important here (although increasing timeouts on each retry could be
> > an
> > > > > interesting option)
> > > > >
> > > > > []
> > > > >
> > > > > Leo
> > > > >
> > > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> > > > rmannibucau@gmail.com
> > > > > >
> > > > > wrote:
> > > > >
> > > > > > Hmm, with MDBs you have retries since they are transactional. you
> > can
> > > > > even
> > > > > > configure the redelivery policy with an exponential backoff and
> so
> > on
> > > > if
> > > > > > really needed
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <
> shikida@gmail.com
> > >:
> > > > > >
> > > > > > > Well, what I need is a pool of workers to listen to a queue and
> > > > process
> > > > > > > messages while they come, but I also need to properly treat
> them
> > > when
> > > > > the
> > > > > > > JMS transaction times out.
> > > > > > >
> > > > > > > So I guess I can't use a MDB here right?
> > > > > > >
> > > > > > > What would be a good approach in this situation?
> > > > > > >
> > > > > > > []
> > > > > > >
> > > > > > > Leo
> > > > > > >
> > > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> > > > > > rmannibucau@gmail.com
> > > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > if you want to control and be able to catch it you need to
> > handle
> > > > > > > yourself
> > > > > > > > the transaction otherwise if it takes more then you'll get a
> > > > rollback
> > > > > > > and a
> > > > > > > > (surely wrapped) RollbackException
> > > > > > > >
> > > > > > > >
> > > > > > > > Romain Manni-Bucau
> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > > > > <http://www.tomitribe.com>
> > > > > > > >
> > > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
> > > shikida@gmail.com
> > > > >:
> > > > > > > >
> > > > > > > > > just checking
> > > > > > > > >
> > > > > > > > > I just add
> > > > > > > > >
> > > > > > > > >     @Resource
> > > > > > > > >     private TransactionManager tx;
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > and in the MDB initialization I set some timeout
> > > > > > > > >
> > > > > > > > >     @PostConstruct
> > > > > > > > >     public void initialize() {
> > > > > > > > >         try {
> > > > > > > > >             tx.setTransactionTimeout(3);
> > > > > > > > >         } catch (SystemException e) {
> > > > > > > > >             e.printStackTrace();
> > > > > > > > >         }
> > > > > > > > >     }
> > > > > > > > >
> > > > > > > > > and when my onMessage() executes, if it takes more than 3
> > > seconds
> > > > > to
> > > > > > > > > complete, it throws and exception?
> > > > > > > > >
> > > > > > > > > and if so, how do I catch it? (or I don't?)
> > > > > > > > >
> > > > > > > > > []
> > > > > > > > >
> > > > > > > > > Leo
> > > > > > > > >
> > > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
> > > > > > > shikida@gmail.com>
> > > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > thx!
> > > > > > > > > >
> > > > > > > > > > []
> > > > > > > > > >
> > > > > > > > > > Leo
> > > > > > > > > >
> > > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> > > > > > > > > rmannibucau@gmail.com
> > > > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > >> Get the Transactionmanager injected (@Resource) and call
> > > > > > > > > >> setTransactionTimeout(seconds)
> > > > > > > > > >>
> > > > > > > > > >>
> > > > > > > > > >> Romain Manni-Bucau
> > > > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > >> https://github.com/rmannibucau> |
> > > > > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > Tomitriber
> > > > > > > > > >> <http://www.tomitribe.com>
> > > > > > > > > >>
> > > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <
> > > > > shikida@gmail.com
> > > > > > >:
> > > > > > > > > >>
> > > > > > > > > >> > Hi
> > > > > > > > > >> >
> > > > > > > > > >> > How do I increase the MDB onMessage() transaction
> > timeout?
> > > > > > > > > >> >
> > > > > > > > > >> > []
> > > > > > > > > >> >
> > > > > > > > > >> > Leo
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by Romain Manni-Bucau <rm...@gmail.com>.
using openejb-jar.xml you can wire a container to some beans only.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-14 22:59 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:

> yeah, I think this will be the way to go
>
> since I can configure max/min instances for stateless (
> http://tomee.apache.org/statelesscontainer-config.html) I think I can just
> create a pool of stateless instances to work as MDBs that can deal with
> timeout :-)
>
> is there any way to configure a container just for these specfic stateless
> EJBs (so some other configuration can be used for stateless by default)?
>
> []
>
> Leo
>
> On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > so just handle transactions yourself
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> >
> > > Another option is to look at the redelivered property/redelivery count
> > and
> > > take action (write to db?) in case of redelivery....  requires you to
> > set a
> > > redelivery policy / number of retries etc
> > >
> > > /LF
> > > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <sh...@gmail.com>
> > wrote:
> > >
> > > > Yup, but if the MDB timeout, I need to set something in the DB,
> that's
> > > why
> > > > I need to treat the timeout.
> > > >
> > > > If the job to be executed timeout, then it will probably timeout for
> > any
> > > > retry, because it's caused by a poorly chosen parameter, so retries
> are
> > > not
> > > > important here (although increasing timeouts on each retry could be
> an
> > > > interesting option)
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> > > rmannibucau@gmail.com
> > > > >
> > > > wrote:
> > > >
> > > > > Hmm, with MDBs you have retries since they are transactional. you
> can
> > > > even
> > > > > configure the redelivery policy with an exponential backoff and so
> on
> > > if
> > > > > really needed
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <shikida@gmail.com
> >:
> > > > >
> > > > > > Well, what I need is a pool of workers to listen to a queue and
> > > process
> > > > > > messages while they come, but I also need to properly treat them
> > when
> > > > the
> > > > > > JMS transaction times out.
> > > > > >
> > > > > > So I guess I can't use a MDB here right?
> > > > > >
> > > > > > What would be a good approach in this situation?
> > > > > >
> > > > > > []
> > > > > >
> > > > > > Leo
> > > > > >
> > > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> > > > > rmannibucau@gmail.com
> > > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > if you want to control and be able to catch it you need to
> handle
> > > > > > yourself
> > > > > > > the transaction otherwise if it takes more then you'll get a
> > > rollback
> > > > > > and a
> > > > > > > (surely wrapped) RollbackException
> > > > > > >
> > > > > > >
> > > > > > > Romain Manni-Bucau
> > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > https://github.com/rmannibucau> |
> > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > > <http://www.tomitribe.com>
> > > > > > >
> > > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
> > shikida@gmail.com
> > > >:
> > > > > > >
> > > > > > > > just checking
> > > > > > > >
> > > > > > > > I just add
> > > > > > > >
> > > > > > > >     @Resource
> > > > > > > >     private TransactionManager tx;
> > > > > > > >
> > > > > > > >
> > > > > > > > and in the MDB initialization I set some timeout
> > > > > > > >
> > > > > > > >     @PostConstruct
> > > > > > > >     public void initialize() {
> > > > > > > >         try {
> > > > > > > >             tx.setTransactionTimeout(3);
> > > > > > > >         } catch (SystemException e) {
> > > > > > > >             e.printStackTrace();
> > > > > > > >         }
> > > > > > > >     }
> > > > > > > >
> > > > > > > > and when my onMessage() executes, if it takes more than 3
> > seconds
> > > > to
> > > > > > > > complete, it throws and exception?
> > > > > > > >
> > > > > > > > and if so, how do I catch it? (or I don't?)
> > > > > > > >
> > > > > > > > []
> > > > > > > >
> > > > > > > > Leo
> > > > > > > >
> > > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
> > > > > > shikida@gmail.com>
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > thx!
> > > > > > > > >
> > > > > > > > > []
> > > > > > > > >
> > > > > > > > > Leo
> > > > > > > > >
> > > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> > > > > > > > rmannibucau@gmail.com
> > > > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > >> Get the Transactionmanager injected (@Resource) and call
> > > > > > > > >> setTransactionTimeout(seconds)
> > > > > > > > >>
> > > > > > > > >>
> > > > > > > > >> Romain Manni-Bucau
> > > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > >> https://github.com/rmannibucau> |
> > > > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > Tomitriber
> > > > > > > > >> <http://www.tomitribe.com>
> > > > > > > > >>
> > > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <
> > > > shikida@gmail.com
> > > > > >:
> > > > > > > > >>
> > > > > > > > >> > Hi
> > > > > > > > >> >
> > > > > > > > >> > How do I increase the MDB onMessage() transaction
> timeout?
> > > > > > > > >> >
> > > > > > > > >> > []
> > > > > > > > >> >
> > > > > > > > >> > Leo
> > > > > > > > >> >
> > > > > > > > >>
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
yeah, I think this will be the way to go

since I can configure max/min instances for stateless (
http://tomee.apache.org/statelesscontainer-config.html) I think I can just
create a pool of stateless instances to work as MDBs that can deal with
timeout :-)

is there any way to configure a container just for these specfic stateless
EJBs (so some other configuration can be used for stateless by default)?

[]

Leo

On Tue, Apr 14, 2015 at 5:46 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> so just handle transactions yourself
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
>
> > Another option is to look at the redelivered property/redelivery count
> and
> > take action (write to db?) in case of redelivery....  requires you to
> set a
> > redelivery policy / number of retries etc
> >
> > /LF
> > On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <sh...@gmail.com>
> wrote:
> >
> > > Yup, but if the MDB timeout, I need to set something in the DB, that's
> > why
> > > I need to treat the timeout.
> > >
> > > If the job to be executed timeout, then it will probably timeout for
> any
> > > retry, because it's caused by a poorly chosen parameter, so retries are
> > not
> > > important here (although increasing timeouts on each retry could be an
> > > interesting option)
> > >
> > > []
> > >
> > > Leo
> > >
> > > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> > rmannibucau@gmail.com
> > > >
> > > wrote:
> > >
> > > > Hmm, with MDBs you have retries since they are transactional. you can
> > > even
> > > > configure the redelivery policy with an exponential backoff and so on
> > if
> > > > really needed
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > > >
> > > > > Well, what I need is a pool of workers to listen to a queue and
> > process
> > > > > messages while they come, but I also need to properly treat them
> when
> > > the
> > > > > JMS transaction times out.
> > > > >
> > > > > So I guess I can't use a MDB here right?
> > > > >
> > > > > What would be a good approach in this situation?
> > > > >
> > > > > []
> > > > >
> > > > > Leo
> > > > >
> > > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> > > > rmannibucau@gmail.com
> > > > > >
> > > > > wrote:
> > > > >
> > > > > > if you want to control and be able to catch it you need to handle
> > > > > yourself
> > > > > > the transaction otherwise if it takes more then you'll get a
> > rollback
> > > > > and a
> > > > > > (surely wrapped) RollbackException
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <
> shikida@gmail.com
> > >:
> > > > > >
> > > > > > > just checking
> > > > > > >
> > > > > > > I just add
> > > > > > >
> > > > > > >     @Resource
> > > > > > >     private TransactionManager tx;
> > > > > > >
> > > > > > >
> > > > > > > and in the MDB initialization I set some timeout
> > > > > > >
> > > > > > >     @PostConstruct
> > > > > > >     public void initialize() {
> > > > > > >         try {
> > > > > > >             tx.setTransactionTimeout(3);
> > > > > > >         } catch (SystemException e) {
> > > > > > >             e.printStackTrace();
> > > > > > >         }
> > > > > > >     }
> > > > > > >
> > > > > > > and when my onMessage() executes, if it takes more than 3
> seconds
> > > to
> > > > > > > complete, it throws and exception?
> > > > > > >
> > > > > > > and if so, how do I catch it? (or I don't?)
> > > > > > >
> > > > > > > []
> > > > > > >
> > > > > > > Leo
> > > > > > >
> > > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
> > > > > shikida@gmail.com>
> > > > > > > wrote:
> > > > > > >
> > > > > > > > thx!
> > > > > > > >
> > > > > > > > []
> > > > > > > >
> > > > > > > > Leo
> > > > > > > >
> > > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> > > > > > > rmannibucau@gmail.com
> > > > > > > > > wrote:
> > > > > > > >
> > > > > > > >> Get the Transactionmanager injected (@Resource) and call
> > > > > > > >> setTransactionTimeout(seconds)
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> Romain Manni-Bucau
> > > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > > > > >> https://github.com/rmannibucau> |
> > > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > > > >> <http://www.tomitribe.com>
> > > > > > > >>
> > > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <
> > > shikida@gmail.com
> > > > >:
> > > > > > > >>
> > > > > > > >> > Hi
> > > > > > > >> >
> > > > > > > >> > How do I increase the MDB onMessage() transaction timeout?
> > > > > > > >> >
> > > > > > > >> > []
> > > > > > > >> >
> > > > > > > >> > Leo
> > > > > > > >> >
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by Romain Manni-Bucau <rm...@gmail.com>.
so just handle transactions yourself


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-14 22:42 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:

> Another option is to look at the redelivered property/redelivery count and
> take action (write to db?) in case of redelivery....  requires you to set a
> redelivery policy / number of retries etc
>
> /LF
> On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <sh...@gmail.com> wrote:
>
> > Yup, but if the MDB timeout, I need to set something in the DB, that's
> why
> > I need to treat the timeout.
> >
> > If the job to be executed timeout, then it will probably timeout for any
> > retry, because it's caused by a poorly chosen parameter, so retries are
> not
> > important here (although increasing timeouts on each retry could be an
> > interesting option)
> >
> > []
> >
> > Leo
> >
> > On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > >
> > wrote:
> >
> > > Hmm, with MDBs you have retries since they are transactional. you can
> > even
> > > configure the redelivery policy with an exponential backoff and so on
> if
> > > really needed
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > >
> > > > Well, what I need is a pool of workers to listen to a queue and
> process
> > > > messages while they come, but I also need to properly treat them when
> > the
> > > > JMS transaction times out.
> > > >
> > > > So I guess I can't use a MDB here right?
> > > >
> > > > What would be a good approach in this situation?
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> > > rmannibucau@gmail.com
> > > > >
> > > > wrote:
> > > >
> > > > > if you want to control and be able to catch it you need to handle
> > > > yourself
> > > > > the transaction otherwise if it takes more then you'll get a
> rollback
> > > > and a
> > > > > (surely wrapped) RollbackException
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <shikida@gmail.com
> >:
> > > > >
> > > > > > just checking
> > > > > >
> > > > > > I just add
> > > > > >
> > > > > >     @Resource
> > > > > >     private TransactionManager tx;
> > > > > >
> > > > > >
> > > > > > and in the MDB initialization I set some timeout
> > > > > >
> > > > > >     @PostConstruct
> > > > > >     public void initialize() {
> > > > > >         try {
> > > > > >             tx.setTransactionTimeout(3);
> > > > > >         } catch (SystemException e) {
> > > > > >             e.printStackTrace();
> > > > > >         }
> > > > > >     }
> > > > > >
> > > > > > and when my onMessage() executes, if it takes more than 3 seconds
> > to
> > > > > > complete, it throws and exception?
> > > > > >
> > > > > > and if so, how do I catch it? (or I don't?)
> > > > > >
> > > > > > []
> > > > > >
> > > > > > Leo
> > > > > >
> > > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
> > > > shikida@gmail.com>
> > > > > > wrote:
> > > > > >
> > > > > > > thx!
> > > > > > >
> > > > > > > []
> > > > > > >
> > > > > > > Leo
> > > > > > >
> > > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> > > > > > rmannibucau@gmail.com
> > > > > > > > wrote:
> > > > > > >
> > > > > > >> Get the Transactionmanager injected (@Resource) and call
> > > > > > >> setTransactionTimeout(seconds)
> > > > > > >>
> > > > > > >>
> > > > > > >> Romain Manni-Bucau
> > > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > > > >> https://github.com/rmannibucau> |
> > > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > >> <http://www.tomitribe.com>
> > > > > > >>
> > > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <
> > shikida@gmail.com
> > > >:
> > > > > > >>
> > > > > > >> > Hi
> > > > > > >> >
> > > > > > >> > How do I increase the MDB onMessage() transaction timeout?
> > > > > > >> >
> > > > > > >> > []
> > > > > > >> >
> > > > > > >> > Leo
> > > > > > >> >
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by Lars-Fredrik Smedberg <it...@gmail.com>.
Another option is to look at the redelivered property/redelivery count and
take action (write to db?) in case of redelivery....  requires you to set a
redelivery policy / number of retries etc

/LF
On Apr 14, 2015 10:39 PM, "Leonardo K. Shikida" <sh...@gmail.com> wrote:

> Yup, but if the MDB timeout, I need to set something in the DB, that's why
> I need to treat the timeout.
>
> If the job to be executed timeout, then it will probably timeout for any
> retry, because it's caused by a poorly chosen parameter, so retries are not
> important here (although increasing timeouts on each retry could be an
> interesting option)
>
> []
>
> Leo
>
> On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > Hmm, with MDBs you have retries since they are transactional. you can
> even
> > configure the redelivery policy with an exponential backoff and so on if
> > really needed
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> >
> > > Well, what I need is a pool of workers to listen to a queue and process
> > > messages while they come, but I also need to properly treat them when
> the
> > > JMS transaction times out.
> > >
> > > So I guess I can't use a MDB here right?
> > >
> > > What would be a good approach in this situation?
> > >
> > > []
> > >
> > > Leo
> > >
> > > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> > rmannibucau@gmail.com
> > > >
> > > wrote:
> > >
> > > > if you want to control and be able to catch it you need to handle
> > > yourself
> > > > the transaction otherwise if it takes more then you'll get a rollback
> > > and a
> > > > (surely wrapped) RollbackException
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > > >
> > > > > just checking
> > > > >
> > > > > I just add
> > > > >
> > > > >     @Resource
> > > > >     private TransactionManager tx;
> > > > >
> > > > >
> > > > > and in the MDB initialization I set some timeout
> > > > >
> > > > >     @PostConstruct
> > > > >     public void initialize() {
> > > > >         try {
> > > > >             tx.setTransactionTimeout(3);
> > > > >         } catch (SystemException e) {
> > > > >             e.printStackTrace();
> > > > >         }
> > > > >     }
> > > > >
> > > > > and when my onMessage() executes, if it takes more than 3 seconds
> to
> > > > > complete, it throws and exception?
> > > > >
> > > > > and if so, how do I catch it? (or I don't?)
> > > > >
> > > > > []
> > > > >
> > > > > Leo
> > > > >
> > > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
> > > shikida@gmail.com>
> > > > > wrote:
> > > > >
> > > > > > thx!
> > > > > >
> > > > > > []
> > > > > >
> > > > > > Leo
> > > > > >
> > > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> > > > > rmannibucau@gmail.com
> > > > > > > wrote:
> > > > > >
> > > > > >> Get the Transactionmanager injected (@Resource) and call
> > > > > >> setTransactionTimeout(seconds)
> > > > > >>
> > > > > >>
> > > > > >> Romain Manni-Bucau
> > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > > >> https://github.com/rmannibucau> |
> > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > >> <http://www.tomitribe.com>
> > > > > >>
> > > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <
> shikida@gmail.com
> > >:
> > > > > >>
> > > > > >> > Hi
> > > > > >> >
> > > > > >> > How do I increase the MDB onMessage() transaction timeout?
> > > > > >> >
> > > > > >> > []
> > > > > >> >
> > > > > >> > Leo
> > > > > >> >
> > > > > >>
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
Yup, but if the MDB timeout, I need to set something in the DB, that's why
I need to treat the timeout.

If the job to be executed timeout, then it will probably timeout for any
retry, because it's caused by a poorly chosen parameter, so retries are not
important here (although increasing timeouts on each retry could be an
interesting option)

[]

Leo

On Tue, Apr 14, 2015 at 5:27 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Hmm, with MDBs you have retries since they are transactional. you can even
> configure the redelivery policy with an exponential backoff and so on if
> really needed
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>
> > Well, what I need is a pool of workers to listen to a queue and process
> > messages while they come, but I also need to properly treat them when the
> > JMS transaction times out.
> >
> > So I guess I can't use a MDB here right?
> >
> > What would be a good approach in this situation?
> >
> > []
> >
> > Leo
> >
> > On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > >
> > wrote:
> >
> > > if you want to control and be able to catch it you need to handle
> > yourself
> > > the transaction otherwise if it takes more then you'll get a rollback
> > and a
> > > (surely wrapped) RollbackException
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > >
> > > > just checking
> > > >
> > > > I just add
> > > >
> > > >     @Resource
> > > >     private TransactionManager tx;
> > > >
> > > >
> > > > and in the MDB initialization I set some timeout
> > > >
> > > >     @PostConstruct
> > > >     public void initialize() {
> > > >         try {
> > > >             tx.setTransactionTimeout(3);
> > > >         } catch (SystemException e) {
> > > >             e.printStackTrace();
> > > >         }
> > > >     }
> > > >
> > > > and when my onMessage() executes, if it takes more than 3 seconds to
> > > > complete, it throws and exception?
> > > >
> > > > and if so, how do I catch it? (or I don't?)
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
> > shikida@gmail.com>
> > > > wrote:
> > > >
> > > > > thx!
> > > > >
> > > > > []
> > > > >
> > > > > Leo
> > > > >
> > > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> > > > rmannibucau@gmail.com
> > > > > > wrote:
> > > > >
> > > > >> Get the Transactionmanager injected (@Resource) and call
> > > > >> setTransactionTimeout(seconds)
> > > > >>
> > > > >>
> > > > >> Romain Manni-Bucau
> > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > >> <http://rmannibucau.wordpress.com> | Github <
> > > > >> https://github.com/rmannibucau> |
> > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > >> <http://www.tomitribe.com>
> > > > >>
> > > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <shikida@gmail.com
> >:
> > > > >>
> > > > >> > Hi
> > > > >> >
> > > > >> > How do I increase the MDB onMessage() transaction timeout?
> > > > >> >
> > > > >> > []
> > > > >> >
> > > > >> > Leo
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hmm, with MDBs you have retries since they are transactional. you can even
configure the redelivery policy with an exponential backoff and so on if
really needed


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-14 22:13 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:

> Well, what I need is a pool of workers to listen to a queue and process
> messages while they come, but I also need to properly treat them when the
> JMS transaction times out.
>
> So I guess I can't use a MDB here right?
>
> What would be a good approach in this situation?
>
> []
>
> Leo
>
> On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > if you want to control and be able to catch it you need to handle
> yourself
> > the transaction otherwise if it takes more then you'll get a rollback
> and a
> > (surely wrapped) RollbackException
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> >
> > > just checking
> > >
> > > I just add
> > >
> > >     @Resource
> > >     private TransactionManager tx;
> > >
> > >
> > > and in the MDB initialization I set some timeout
> > >
> > >     @PostConstruct
> > >     public void initialize() {
> > >         try {
> > >             tx.setTransactionTimeout(3);
> > >         } catch (SystemException e) {
> > >             e.printStackTrace();
> > >         }
> > >     }
> > >
> > > and when my onMessage() executes, if it takes more than 3 seconds to
> > > complete, it throws and exception?
> > >
> > > and if so, how do I catch it? (or I don't?)
> > >
> > > []
> > >
> > > Leo
> > >
> > > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <
> shikida@gmail.com>
> > > wrote:
> > >
> > > > thx!
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> > > rmannibucau@gmail.com
> > > > > wrote:
> > > >
> > > >> Get the Transactionmanager injected (@Resource) and call
> > > >> setTransactionTimeout(seconds)
> > > >>
> > > >>
> > > >> Romain Manni-Bucau
> > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > >> <http://rmannibucau.wordpress.com> | Github <
> > > >> https://github.com/rmannibucau> |
> > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > >> <http://www.tomitribe.com>
> > > >>
> > > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > > >>
> > > >> > Hi
> > > >> >
> > > >> > How do I increase the MDB onMessage() transaction timeout?
> > > >> >
> > > >> > []
> > > >> >
> > > >> > Leo
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
>

Re: MDB transaction timeout

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
Well, what I need is a pool of workers to listen to a queue and process
messages while they come, but I also need to properly treat them when the
JMS transaction times out.

So I guess I can't use a MDB here right?

What would be a good approach in this situation?

[]

Leo

On Tue, Apr 14, 2015 at 4:53 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> if you want to control and be able to catch it you need to handle yourself
> the transaction otherwise if it takes more then you'll get a rollback and a
> (surely wrapped) RollbackException
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>
> > just checking
> >
> > I just add
> >
> >     @Resource
> >     private TransactionManager tx;
> >
> >
> > and in the MDB initialization I set some timeout
> >
> >     @PostConstruct
> >     public void initialize() {
> >         try {
> >             tx.setTransactionTimeout(3);
> >         } catch (SystemException e) {
> >             e.printStackTrace();
> >         }
> >     }
> >
> > and when my onMessage() executes, if it takes more than 3 seconds to
> > complete, it throws and exception?
> >
> > and if so, how do I catch it? (or I don't?)
> >
> > []
> >
> > Leo
> >
> > On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <sh...@gmail.com>
> > wrote:
> >
> > > thx!
> > >
> > > []
> > >
> > > Leo
> > >
> > > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> > rmannibucau@gmail.com
> > > > wrote:
> > >
> > >> Get the Transactionmanager injected (@Resource) and call
> > >> setTransactionTimeout(seconds)
> > >>
> > >>
> > >> Romain Manni-Bucau
> > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > >> <http://rmannibucau.wordpress.com> | Github <
> > >> https://github.com/rmannibucau> |
> > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > >> <http://www.tomitribe.com>
> > >>
> > >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> > >>
> > >> > Hi
> > >> >
> > >> > How do I increase the MDB onMessage() transaction timeout?
> > >> >
> > >> > []
> > >> >
> > >> > Leo
> > >> >
> > >>
> > >
> > >
> >
>

Re: MDB transaction timeout

Posted by Romain Manni-Bucau <rm...@gmail.com>.
if you want to control and be able to catch it you need to handle yourself
the transaction otherwise if it takes more then you'll get a rollback and a
(surely wrapped) RollbackException


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-14 21:45 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:

> just checking
>
> I just add
>
>     @Resource
>     private TransactionManager tx;
>
>
> and in the MDB initialization I set some timeout
>
>     @PostConstruct
>     public void initialize() {
>         try {
>             tx.setTransactionTimeout(3);
>         } catch (SystemException e) {
>             e.printStackTrace();
>         }
>     }
>
> and when my onMessage() executes, if it takes more than 3 seconds to
> complete, it throws and exception?
>
> and if so, how do I catch it? (or I don't?)
>
> []
>
> Leo
>
> On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <sh...@gmail.com>
> wrote:
>
> > thx!
> >
> > []
> >
> > Leo
> >
> > On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > > wrote:
> >
> >> Get the Transactionmanager injected (@Resource) and call
> >> setTransactionTimeout(seconds)
> >>
> >>
> >> Romain Manni-Bucau
> >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> >> <http://rmannibucau.wordpress.com> | Github <
> >> https://github.com/rmannibucau> |
> >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> >> <http://www.tomitribe.com>
> >>
> >> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
> >>
> >> > Hi
> >> >
> >> > How do I increase the MDB onMessage() transaction timeout?
> >> >
> >> > []
> >> >
> >> > Leo
> >> >
> >>
> >
> >
>

Re: MDB transaction timeout

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

I just add

    @Resource
    private TransactionManager tx;


and in the MDB initialization I set some timeout

    @PostConstruct
    public void initialize() {
        try {
            tx.setTransactionTimeout(3);
        } catch (SystemException e) {
            e.printStackTrace();
        }
    }

and when my onMessage() executes, if it takes more than 3 seconds to
complete, it throws and exception?

and if so, how do I catch it? (or I don't?)

[]

Leo

On Tue, Apr 14, 2015 at 4:20 PM, Leonardo K. Shikida <sh...@gmail.com>
wrote:

> thx!
>
> []
>
> Leo
>
> On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> > wrote:
>
>> Get the Transactionmanager injected (@Resource) and call
>> setTransactionTimeout(seconds)
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> <http://rmannibucau.wordpress.com> | Github <
>> https://github.com/rmannibucau> |
>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
>> <http://www.tomitribe.com>
>>
>> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>>
>> > Hi
>> >
>> > How do I increase the MDB onMessage() transaction timeout?
>> >
>> > []
>> >
>> > Leo
>> >
>>
>
>

Re: MDB transaction timeout

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

[]

Leo

On Tue, Apr 14, 2015 at 4:16 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Get the Transactionmanager injected (@Resource) and call
> setTransactionTimeout(seconds)
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:
>
> > Hi
> >
> > How do I increase the MDB onMessage() transaction timeout?
> >
> > []
> >
> > Leo
> >
>

Re: MDB transaction timeout

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Get the Transactionmanager injected (@Resource) and call
setTransactionTimeout(seconds)


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-14 19:38 GMT+02:00 Leonardo K. Shikida <sh...@gmail.com>:

> Hi
>
> How do I increase the MDB onMessage() transaction timeout?
>
> []
>
> Leo
>