dev@glassfish.java.net

Re: How do we move the control of transaction from MDB to Container in Glassfish

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Tue, 26 Aug 2008 10:40:22 -0400

On Aug 26, 2008, at 10:14 AM, kiran tummala wrote:

> Kenneth,
>
> thanks for the suggestion. If we set them, in the class file, can
> we expect the transaction to rollback upon any exception or do we
> need to explicitly call the rollback. We are currently having an
> issue when we explicitly call the rollback, it rollsback and the
> message never moves to the DMQ.

If you explicitly mark the transaction for rollback (e.g. via
EJBContext.setRollbackOnly()) the message will keep getting
redelivered. If the transaction is rolling back as a result of a
runtime exception thrown from onMessage() you can control the maximum
number of redelivery attempts by setting the
EndpointExceptionRedeliveryAttempts property in sun-ejb-jar.xml.
Details are here :

http://docs.sun.com/app/docs/doc/819-7755/6n9m8u5nc?a=view

There's an example here :

https://glassfish.dev.java.net/issues/show_bug.cgi?id=2630

>
>
> thanks,
>
>
> Kiran
>
> Container managed transactions and tx attribute REQUIRED are the
> defaults in EJB 3.0 so you shouldn't have to configure anything. If
> you do want to configure them explicitly the easiest way is to use
> annotations. Just add @TransactionManagement(CONTAINER) at the
> message driven bean class level and @TransactionAttribute(REQUIRED)
> to the onMessage method.
>
> Kenneth Saks wrote:
>>
>> On Aug 25, 2008, at 8:04 PM, kiran tummala wrote:
>>
>>> Hi,
>>>
>>> We have an Message Driven Bean, It subscribes to a message, and
>>> based on message needs to transcode a media file. If there is a
>>> failure in the process, we thrown exceptions and in the exception
>>> we are explicitly calling rollback of message. We would like the
>>> container to handle this process and found this material
>>>
>>> "Because JMS is a full-fledged transaction resource manager, JMS
>>> work, such as message consumption, and other transaction work can
>>> be grouped into one transaction. This means that you can choose to
>>> make a message-driven bean part of a transaction or not. The
>>> deployment descriptor transaction attribute, which for a message-
>>> driven bean can be either Required or NotSupported, determines
>>> whether or not the bean participates in a transaction. (If the
>>> message-driven bean participates in a transaction, you must also
>>> be using container-managed transaction demarcation.)"
>>>
>>> We would like to use the deployment descriptor transaction
>>> attribute and set it to Required, so that container manages the
>>> transaction. How do we configure this in glassfish.
>>
>> Hi Kiran,
>>
>> Container managed transactions and tx attribute REQUIRED are the
>> defaults in EJB 3.0 so you shouldn't have to configure anything.
>> If you do want to configure them explicitly the easiest way is to
>> use annotations. Just add @TransactionManagement(CONTAINER) at the
>> message driven bean class level and @TransactionAttribute(REQUIRED)
>> to the onMessage method.
>>
>>> Do we need to do anything special in Netbeans to achieve this.
>>>
>>> thanks,
>>>
>>>
>>> Kiran
>>>
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>