-
1. Re: rolled back messages delivered twice.
timfox Feb 27, 2009 4:30 AM (in response to ataylor)Are you sure all the tx operations from JCA are being performed on the bean in a single threaded fashion?
Can you outline them here? -
2. Re: rolled back messages delivered twice.
ataylor Feb 27, 2009 4:38 AM (in response to ataylor)basically:
tm.begin();
trans = tm.getTransaction();
trans.enlistResource(res)//res is xasession.getresource
onmessage()
tm.rollback();
all in the same thread -
3. Re: rolled back messages delivered twice.
timfox Feb 27, 2009 4:40 AM (in response to ataylor)But that onMessage is not the onMessage that JBM itself calls right. This is another delegate onmessage.
The tx needs to be enlisted before the "real" onMessage is called. -
4. Re: rolled back messages delivered twice.
timfox Feb 27, 2009 4:46 AM (in response to ataylor)So.. I'm interested in the following events:
1) The real onmessage where the jca layer receives the message from JBM
2) The transaction enlistment, delistment and rollback
3) The point where the JCA layer forwards the message to the delegate onmessage (the one that represents the endpoint).
And the order in which they occur -
5. Re: rolled back messages delivered twice.
ataylor Feb 27, 2009 4:50 AM (in response to ataylor)that is the real onmessage see JBMMessageHandler:onMessage()
-
6. Re: rolled back messages delivered twice.
timfox Feb 27, 2009 4:53 AM (in response to ataylor)If it's the real onmessage then the order you specified is impossible.
It's JBM that calls the real onMessage so how can you call rollback on the same thread that jbm called onmessage after onmessage is complete? You don't have control of that thread.... -
7. Re: rolled back messages delivered twice.
ataylor Feb 27, 2009 4:56 AM (in response to ataylor)By the real onMessage i assumed you meant the onMessage implementation?
public void onMessage(Message message) //JBM onmessage { tm.begin(); trans = tm.getTransaction(); trans.enlistResource(res)//res is xasession.getresource onmessage()//endpoint onmessage tm.rollback(); }
-
8. Re: rolled back messages delivered twice.
gaohoward Feb 27, 2009 5:17 AM (in response to ataylor)is it possible that the second message (you omitted) happens to be in the same TX with the one in question? If they are in the same TX, they will be rolled back together.
-
9. Re: rolled back messages delivered twice.
ataylor Feb 27, 2009 5:21 AM (in response to ataylor)I think the question is, do we handle rollback properly when a message is in flight from server to client. The server thinks its delivered so its cancelled. The client receives it after rollback so consumes then acks it.
-
10. Re: rolled back messages delivered twice.
gaohoward Feb 27, 2009 5:25 AM (in response to ataylor)If the message is with a Tx, the ack of it should be controlled by the TX, consumer shouldn't do the ack, right?
-
11. Re: rolled back messages delivered twice.
ataylor Feb 27, 2009 5:28 AM (in response to ataylor)"gaohoward" wrote:
If the message is with a Tx, the ack of it should be controlled by the TX, consumer shouldn't do the ack, right?
The consumer will still ack, even if within a tx. They are just handled differently. -
12. Re: rolled back messages delivered twice.
gaohoward Feb 27, 2009 5:30 AM (in response to ataylor)ok.
-
13. Re: rolled back messages delivered twice.
timfox Feb 27, 2009 5:32 AM (in response to ataylor)What I meant is, you said that you enlist the transaction *before* onMessage is called.
Here is the code in JBM that calls onMessage in JMSMessageListenerWrapper:try { listener.onMessage(jbm); } catch (RuntimeException e) { //See JMS 1.1 spec, section 4.5.2 log.warn("Unhandled exception thrown from onMessage", e); if (!transactedOrClientAck) { try { session.getCoreSession().rollback(true); session.setRecoverCalled(true); } catch (Exception e2) { log.error("Failed to recover session", e2); } } }
So in order to do enlistment before and after onMessage is called, you'd have to change that code, which you don't have access to in JCA.
So I don't understand how you can do the order that you specified. -
14. Re: rolled back messages delivered twice.
ataylor Feb 27, 2009 5:40 AM (in response to ataylor)Ok, I meant before onMessage on the endpoint not the message listener.
Ok, so i guess the problem is that we need to enlist the resouce before JBM calls its onmessage. The only way i can see of doing this is to add some special kind of message listener with before and after callbacks that the JMSMessageListenerWrapper calls.