You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Martin Landua <ma...@union-investment.de> on 2006/09/20 22:30:06 UTC

Answering synchronous transactional InOut MEP

Hi,

I have written a polling component which generates messages that it is
sending to its delivery channel synchronously. It operates on a InOut 
Message Exchange.
Also, I have created an OutBinding component, which is supposed to create an
answer to the message that it receives. The answer is being sent through the
answer method of the OutBinding component.
Now it appears to me that everything works fine as long as the polling
component does not create a transaction. If it does, the answer() method
actually throws an exception, because it cannot find an appropriate flow
that can handle this message exchange.
>From what I can tell from the sources, the SedaFlow checks whether it can
handle a ME. And it does it like this:

    public boolean canHandle(MessageExchange me) {
        if (isPersistent(me)) {
            return false;
        }
        if (isClustered(me)) {
            return false;
        }
        if (isTransacted(me)) {
            if (!isSynchronous(me)) {
                // we have the mirror, so the role is the one for the target
component
                if (me.getStatus() == ExchangeStatus.ACTIVE) {
                    return false;
                }
            }
        }
        return true;
    }


The problem here is that the answer() method actually clears the SEND_SYNC
property, therefore the ME appears to be async although it is not. And why
does this test only happen when transactions are enabled?

Am I using the wrong flow?
Please note that I'm running ServiceMix in JBoss using the JBoss deployer
(all built from SVN-Head).

Any advice?

Cheers
Martin
-- 
View this message in context: http://www.nabble.com/Answering-synchronous-transactional-InOut-MEP-tf2307890.html#a6416047
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Answering synchronous transactional InOut MEP

Posted by Guillaume Nodet <gn...@gmail.com>.
You're right, because sendSync is not allowed on DONE exchanges.
I just fixed the doc, thx.

On 9/20/06, Martin Landua <ma...@union-investment.de> wrote:
>
> Again. Well, it appears to me that I have to set DONE on the me on the
> polling side and send the me again to the delivery channel (actually as an
> answer and to release the sendSync-answer from waiting.
>
> Now, if that were true, it'll work just like described on the page
> http://goopen.org/confluence/display/SM/Transactions
> http://goopen.org/confluence/display/SM/Transactions  except that the second
> send is a send() rather than a sendSync() - I mean the one that follows
> setting DONE to the me.
>
> Guillaume, would you kindly confirm if this is true?
>
> Cheers again.
> Martin
>
>
>
> gnodet wrote:
> >
> > If you receive a synchronous transactional exchange, you
> > need to answer using sendSync, so that the transaction
> > is also conveyed synchronously back to the consumer
> > component.
> > You can check if the jbi exchange is synchronous and transacted
> > with the following code:
> >           boolean txSync = exchange.isTransacted() &&
> > Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC));
> >
> > If txSync is true, you MUST use sendSync to send the answer.
> >
> > On 9/20/06, Martin Landua <ma...@union-investment.de> wrote:
> >>
> >> Hi,
> >>
> >> I have written a polling component which generates messages that it is
> >> sending to its delivery channel synchronously. It operates on a InOut
> >> Message Exchange.
> >> Also, I have created an OutBinding component, which is supposed to create
> >> an
> >> answer to the message that it receives. The answer is being sent through
> >> the
> >> answer method of the OutBinding component.
> >> Now it appears to me that everything works fine as long as the polling
> >> component does not create a transaction. If it does, the answer() method
> >> actually throws an exception, because it cannot find an appropriate flow
> >> that can handle this message exchange.
> >> From what I can tell from the sources, the SedaFlow checks whether it can
> >> handle a ME. And it does it like this:
> >>
> >>     public boolean canHandle(MessageExchange me) {
> >>         if (isPersistent(me)) {
> >>             return false;
> >>         }
> >>         if (isClustered(me)) {
> >>             return false;
> >>         }
> >>         if (isTransacted(me)) {
> >>             if (!isSynchronous(me)) {
> >>                 // we have the mirror, so the role is the one for the
> >> target
> >> component
> >>                 if (me.getStatus() == ExchangeStatus.ACTIVE) {
> >>                     return false;
> >>                 }
> >>             }
> >>         }
> >>         return true;
> >>     }
> >>
> >>
> >> The problem here is that the answer() method actually clears the
> >> SEND_SYNC
> >> property, therefore the ME appears to be async although it is not. And
> >> why
> >> does this test only happen when transactions are enabled?
> >>
> >> Am I using the wrong flow?
> >> Please note that I'm running ServiceMix in JBoss using the JBoss deployer
> >> (all built from SVN-Head).
> >>
> >> Any advice?
> >>
> >> Cheers
> >> Martin
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Answering-synchronous-transactional-InOut-MEP-tf2307890.html#a6416047
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Answering-synchronous-transactional-InOut-MEP-tf2307890.html#a6416815
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet

Re: Answering synchronous transactional InOut MEP

Posted by Martin Landua <ma...@union-investment.de>.
Again. Well, it appears to me that I have to set DONE on the me on the
polling side and send the me again to the delivery channel (actually as an
answer and to release the sendSync-answer from waiting.

Now, if that were true, it'll work just like described on the page 
http://goopen.org/confluence/display/SM/Transactions
http://goopen.org/confluence/display/SM/Transactions  except that the second
send is a send() rather than a sendSync() - I mean the one that follows
setting DONE to the me.

Guillaume, would you kindly confirm if this is true?

Cheers again.
Martin



gnodet wrote:
> 
> If you receive a synchronous transactional exchange, you
> need to answer using sendSync, so that the transaction
> is also conveyed synchronously back to the consumer
> component.
> You can check if the jbi exchange is synchronous and transacted
> with the following code:
>           boolean txSync = exchange.isTransacted() &&
> Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC));
> 
> If txSync is true, you MUST use sendSync to send the answer.
> 
> On 9/20/06, Martin Landua <ma...@union-investment.de> wrote:
>>
>> Hi,
>>
>> I have written a polling component which generates messages that it is
>> sending to its delivery channel synchronously. It operates on a InOut
>> Message Exchange.
>> Also, I have created an OutBinding component, which is supposed to create
>> an
>> answer to the message that it receives. The answer is being sent through
>> the
>> answer method of the OutBinding component.
>> Now it appears to me that everything works fine as long as the polling
>> component does not create a transaction. If it does, the answer() method
>> actually throws an exception, because it cannot find an appropriate flow
>> that can handle this message exchange.
>> From what I can tell from the sources, the SedaFlow checks whether it can
>> handle a ME. And it does it like this:
>>
>>     public boolean canHandle(MessageExchange me) {
>>         if (isPersistent(me)) {
>>             return false;
>>         }
>>         if (isClustered(me)) {
>>             return false;
>>         }
>>         if (isTransacted(me)) {
>>             if (!isSynchronous(me)) {
>>                 // we have the mirror, so the role is the one for the
>> target
>> component
>>                 if (me.getStatus() == ExchangeStatus.ACTIVE) {
>>                     return false;
>>                 }
>>             }
>>         }
>>         return true;
>>     }
>>
>>
>> The problem here is that the answer() method actually clears the
>> SEND_SYNC
>> property, therefore the ME appears to be async although it is not. And
>> why
>> does this test only happen when transactions are enabled?
>>
>> Am I using the wrong flow?
>> Please note that I'm running ServiceMix in JBoss using the JBoss deployer
>> (all built from SVN-Head).
>>
>> Any advice?
>>
>> Cheers
>> Martin
>> --
>> View this message in context:
>> http://www.nabble.com/Answering-synchronous-transactional-InOut-MEP-tf2307890.html#a6416047
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> 
> 

-- 
View this message in context: http://www.nabble.com/Answering-synchronous-transactional-InOut-MEP-tf2307890.html#a6416815
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Answering synchronous transactional InOut MEP

Posted by Martin Landua <ma...@union-investment.de>.
Thanks a lot.

You mean like this?

me.setOutMessage(answer);
getDeliveryChannel().sendSync(me);


I tried this but actually, I had the impression that within sendSync, the
call to "waitForExchange" is waiting for ever.

Anything else that I'm missing?




gnodet wrote:
> 
> If you receive a synchronous transactional exchange, you
> need to answer using sendSync, so that the transaction
> is also conveyed synchronously back to the consumer
> component.
> You can check if the jbi exchange is synchronous and transacted
> with the following code:
>           boolean txSync = exchange.isTransacted() &&
> Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC));
> 
> If txSync is true, you MUST use sendSync to send the answer.
> 
> On 9/20/06, Martin Landua <ma...@union-investment.de> wrote:
>>
>> Hi,
>>
>> I have written a polling component which generates messages that it is
>> sending to its delivery channel synchronously. It operates on a InOut
>> Message Exchange.
>> Also, I have created an OutBinding component, which is supposed to create
>> an
>> answer to the message that it receives. The answer is being sent through
>> the
>> answer method of the OutBinding component.
>> Now it appears to me that everything works fine as long as the polling
>> component does not create a transaction. If it does, the answer() method
>> actually throws an exception, because it cannot find an appropriate flow
>> that can handle this message exchange.
>> From what I can tell from the sources, the SedaFlow checks whether it can
>> handle a ME. And it does it like this:
>>
>>     public boolean canHandle(MessageExchange me) {
>>         if (isPersistent(me)) {
>>             return false;
>>         }
>>         if (isClustered(me)) {
>>             return false;
>>         }
>>         if (isTransacted(me)) {
>>             if (!isSynchronous(me)) {
>>                 // we have the mirror, so the role is the one for the
>> target
>> component
>>                 if (me.getStatus() == ExchangeStatus.ACTIVE) {
>>                     return false;
>>                 }
>>             }
>>         }
>>         return true;
>>     }
>>
>>
>> The problem here is that the answer() method actually clears the
>> SEND_SYNC
>> property, therefore the ME appears to be async although it is not. And
>> why
>> does this test only happen when transactions are enabled?
>>
>> Am I using the wrong flow?
>> Please note that I'm running ServiceMix in JBoss using the JBoss deployer
>> (all built from SVN-Head).
>>
>> Any advice?
>>
>> Cheers
>> Martin
>> --
>> View this message in context:
>> http://www.nabble.com/Answering-synchronous-transactional-InOut-MEP-tf2307890.html#a6416047
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> 
> 

-- 
View this message in context: http://www.nabble.com/Answering-synchronous-transactional-InOut-MEP-tf2307890.html#a6416569
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Answering synchronous transactional InOut MEP

Posted by Guillaume Nodet <gn...@gmail.com>.
If you receive a synchronous transactional exchange, you
need to answer using sendSync, so that the transaction
is also conveyed synchronously back to the consumer
component.
You can check if the jbi exchange is synchronous and transacted
with the following code:
          boolean txSync = exchange.isTransacted() &&
Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC));

If txSync is true, you MUST use sendSync to send the answer.

On 9/20/06, Martin Landua <ma...@union-investment.de> wrote:
>
> Hi,
>
> I have written a polling component which generates messages that it is
> sending to its delivery channel synchronously. It operates on a InOut
> Message Exchange.
> Also, I have created an OutBinding component, which is supposed to create an
> answer to the message that it receives. The answer is being sent through the
> answer method of the OutBinding component.
> Now it appears to me that everything works fine as long as the polling
> component does not create a transaction. If it does, the answer() method
> actually throws an exception, because it cannot find an appropriate flow
> that can handle this message exchange.
> From what I can tell from the sources, the SedaFlow checks whether it can
> handle a ME. And it does it like this:
>
>     public boolean canHandle(MessageExchange me) {
>         if (isPersistent(me)) {
>             return false;
>         }
>         if (isClustered(me)) {
>             return false;
>         }
>         if (isTransacted(me)) {
>             if (!isSynchronous(me)) {
>                 // we have the mirror, so the role is the one for the target
> component
>                 if (me.getStatus() == ExchangeStatus.ACTIVE) {
>                     return false;
>                 }
>             }
>         }
>         return true;
>     }
>
>
> The problem here is that the answer() method actually clears the SEND_SYNC
> property, therefore the ME appears to be async although it is not. And why
> does this test only happen when transactions are enabled?
>
> Am I using the wrong flow?
> Please note that I'm running ServiceMix in JBoss using the JBoss deployer
> (all built from SVN-Head).
>
> Any advice?
>
> Cheers
> Martin
> --
> View this message in context: http://www.nabble.com/Answering-synchronous-transactional-InOut-MEP-tf2307890.html#a6416047
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet