About Question enthuware.oce-ejbd.v6.2.578 :
Moderator: admin
About Question enthuware.oce-ejbd.v6.2.578 :
Hi!
This is another example of a question related to MDB and transactions that is quite unclear.
As far as I know, transactions does not propagate over JMS:
The sending of a JMS message takes place in one transaction, the receiving of the same message in another transaction.
Thus there is no correct answer alternative in this question.
This is another example of a question related to MDB and transactions that is quite unclear.
As far as I know, transactions does not propagate over JMS:
The sending of a JMS message takes place in one transaction, the receiving of the same message in another transaction.
Thus there is no correct answer alternative in this question.
Re: About Question enthuware.oce-ejbd.v6.2.578 :
Exactly, so the sending side is not affected at all.As far as I know, transactions does not propagate over JMS:
The sending of a JMS message takes place in one transaction, the receiving of the same message in another transaction.
-
- Site Admin
- Posts: 10385
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
The correct answer is option 1, "Changes made by the bean code at line 23 will be committed.". This is explained in detail in the given explanation as well.
Re: About Question enthuware.oce-ejbd.v6.2.578 :
what is the difference between this question and enthuware.oce-ejbd.v6.2.511. I am confused
-
- Site Admin
- Posts: 10385
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
In 2.578, it is given that the MDB associated with the queue is a BMT bean, while in 2.511, this information is not given, so it could be either BMT or CMT. The options are different as well.
HTH,
Paul.
HTH,
Paul.
Re: About Question enthuware.oce-ejbd.v6.2.578 :
I some questions regarding the explanation given in this question:
1 CMT MDB: In case of a rollback (without system exception), is the msg redelivered or not?
2 CMT MDB: In case of a rollback, with system error, the msg is redelivered, right?
3 BMT MDB: In case of a rollback (without system exception), no msg redelived, right?
4 BMT MDB: In case of a rollback, with system error, what happens?
I´m a bit confused because of this:
1 CMT MDB: In case of a rollback (without system exception), is the msg redelivered or not?
2 CMT MDB: In case of a rollback, with system error, the msg is redelivered, right?
3 BMT MDB: In case of a rollback (without system exception), no msg redelived, right?
4 BMT MDB: In case of a rollback, with system error, what happens?
I´m a bit confused because of this:
and...and the message will be redelivered later because as per Section 5.4.18, If a message-driven bean uses bean-managed transaction demarcation and throws a RuntimeException, the container should not acknowledge the message.
Thanks in advance!Note that, in case of a CMT MDB (with transaction attribute of REQUIRED), the container starts a transaction before dequeuing the message. So, if the bean throws a system exception, or calls setRollbackOnly(), the message will be redelivered to another instance of the MDB but in case of BMT, the message is not redelivered because message dequeuing is not a part of the transaction
Re: About Question enthuware.oce-ejbd.v6.2.578 :
I'm having my exam in 2 days and this is the only questions that I'm still a bit confused, so can you please help? Thanks!
-
- Site Admin
- Posts: 10385
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
>1. CMT MDB: In case of a rollback (without system exception), is the msg redelivered or not?
>2 CMT MDB: In case of a rollback, with system error, the msg is redelivered, right?
As per section 13.6.3.2, "If the onMessage method does not successfully complete or the transaction is rolled back, message redelivery semantics apply."
So, in both of the above cases the message is redelivered.
>3 BMT MDB: In case of a rollback (without system exception), no msg redelived, right?
>4 BMT MDB: In case of a rollback, with system error, what happens?
In case of a BMT, as per section 5.4.15:
P1: MDB calls rollback but no system exception + AUTO_ACKNOWLEDGE :
Message should NOT be redelivered.
P2: MDB throws system exception + AUTO_ACKNOWLEDGE :
Message should be redelivered.
P3: MDB calls rollback but no system exception + DUPS_OK_ACKNOWLEDGE :
Message may be redelivered.
P4: MDB throws system exception + DUPS_OK_ACKNOWLEDGE :
Message should be redelivered.
HTH,
Paul.
>2 CMT MDB: In case of a rollback, with system error, the msg is redelivered, right?
As per section 13.6.3.2, "If the onMessage method does not successfully complete or the transaction is rolled back, message redelivery semantics apply."
So, in both of the above cases the message is redelivered.
>3 BMT MDB: In case of a rollback (without system exception), no msg redelived, right?
>4 BMT MDB: In case of a rollback, with system error, what happens?
In case of a BMT, as per section 5.4.15:
and as per Section 5.4.18If bean-managed transaction demarcation is used, the message receipt cannot be part of the bean-managed transaction, and, in this case, the receipt is acknowledged by the container. If bean-managed transaction demarcation is used, the Bean Provider can indicate whether JMS AUTO_ACKNOWLEDGE semantics or DUPS_OK_ACKNOWLEDGE semantics should apply by using the activationConfig element of the MessageDriven annotation or by using the activation-config-property deployment descriptor element. The property name used to specify the acknowledgment mode is acknowledgeMode. If the acknowledgeMode property is not specified, JMS AUTO_ACKNOWLEDGE semantics are assumed.
This means, there are a total of four possibilities:If a message-driven bean uses bean-managed transaction demarcation and throws a RuntimeException, the container should not acknowledge the message.
P1: MDB calls rollback but no system exception + AUTO_ACKNOWLEDGE :
Message should NOT be redelivered.
P2: MDB throws system exception + AUTO_ACKNOWLEDGE :
Message should be redelivered.
P3: MDB calls rollback but no system exception + DUPS_OK_ACKNOWLEDGE :
Message may be redelivered.
P4: MDB throws system exception + DUPS_OK_ACKNOWLEDGE :
Message should be redelivered.
HTH,
Paul.
Re: About Question enthuware.oce-ejbd.v6.2.578 :
Hi Paul,
Thanks for the answer. Now I understand! =)
Thanks for the answer. Now I understand! =)
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
For option 3, I think the message has already been sent to the queue on line 24.
But what I believe is that the MDB receives the message from the queue and executes onMessage in a transaction. But the transaction is rolled back.
I think it is still right to say the message is sent to the queue.
Correct me if I am wrong.
But what I believe is that the MDB receives the message from the queue and executes onMessage in a transaction. But the transaction is rolled back.
I think it is still right to say the message is sent to the queue.
Correct me if I am wrong.
-
- Site Admin
- Posts: 10385
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
That is why the option is wrong.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
Hi, for option 3
Should it be clearer to change this phrase into:
Based on the explanation using the term "redeliver",,
Changes made by the bean code at line 23 will be committed, but the message sent at line 24 will not be sent.
Should it be clearer to change this phrase into:
?.... the message sent at line 24 will not be re-sent
-
- Site Admin
- Posts: 10385
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
No, it is fine as it is because it is a wrong option.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
Hi, admin,
Maybe I have been misunderstanding the question.
What I am interpreting from the scenario is:
1. the message at line 24 is put in the queue.
2. the MDB receives it.
3. the MDB's onMessage rollback the transaction after it receives the message from line 24.
4. the container won't redeliver the message.
Correct me if my interpretation of the question is wrong.
Maybe I have been misunderstanding the question.
What I am interpreting from the scenario is:
1. the message at line 24 is put in the queue.
2. the MDB receives it.
3. the MDB's onMessage rollback the transaction after it receives the message from line 24.
4. the container won't redeliver the message.
Correct me if my interpretation of the question is wrong.
-
- Site Admin
- Posts: 10385
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
What you said above is correct.himaiMinh wrote:Hi, admin,
Maybe I have been misunderstanding the question.
What I am interpreting from the scenario is:
1. the message at line 24 is put in the queue.
2. the MDB receives it.
3. the MDB's onMessage rollback the transaction after it receives the message from line 24.
4. the container won't redeliver the message.
Correct me if my interpretation of the question is wrong.
Paul.
-
- Posts: 3
- Joined: Tue Jul 21, 2015 7:44 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
Sorry for my English I only Spanish
In the Explanation to te question you say
As per Section 5.4.15, if bean-managed transaction demarcation is used, the message receipt cannot be part of the bean-managed transaction, and, in this case, the receipt is acknowledged by the container. If a MDB does not throw any exception while processing the message (Note: It can only throw RuntimeExceptions such as EJBException from onMessage()), ....
But in point 5.4.18 of the specification says
....
Message-driven beans should not, in general, throw RuntimeExceptions.
....
The message listener methods of some messaging types may throw application exceptions. An applica-
tion exception is propagated by the container to the resource adapter.
who is right
In the Explanation to te question you say
As per Section 5.4.15, if bean-managed transaction demarcation is used, the message receipt cannot be part of the bean-managed transaction, and, in this case, the receipt is acknowledged by the container. If a MDB does not throw any exception while processing the message (Note: It can only throw RuntimeExceptions such as EJBException from onMessage()), ....
But in point 5.4.18 of the specification says
....
Message-driven beans should not, in general, throw RuntimeExceptions.
....
The message listener methods of some messaging types may throw application exceptions. An applica-
tion exception is propagated by the container to the resource adapter.
who is right
-
- Site Admin
- Posts: 10385
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.578 :
Both are correct. It should not. But it can (it is possible to throw it). You can also annotate a runtime exception with @ApplicationException.
Who is online
Users browsing this forum: No registered users and 4 guests