You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Andrea Zoppello <zo...@libero.it> on 2006/12/19 14:22:32 UTC

Correlation Id in Groovy component

Hi all,
this question is related to the change with id SM-751 on Jira.
I tried a simple process composed in this way: HTTP BC->GROOVY 
COMPONENT->Screen BC.
The problem is related to the propagation of correlation id, generated
by the first HTTP BC.
The correlation id is propagated in the right way until the message sent
by GROOVY to Screen BC: in this case a new correlation id is
generated, and this is not the right behaviour.

The problem is in the method onMessageExchange of the class 
TransformComponentSupport (that GroovyComponent extends): in this method
if the MEP is InOnly a new Exchange is created.
In this new Exchange the correlation id is not copied from the original 
exchange. Also the senderEndpoint property is not setted by the method.

I added some code to the onMessageExchange method to fix these 2 problems.
Here is the modified code:

            if (isInAndOut(exchange)) {
                out = exchange.createMessage();
            } else {
                outExchange = getExchangeFactory().createInOnlyExchange();


//----------------------------------------------------------------------------------- 

                outExchange.setProperty(JbiConstants.SENDER_ENDPOINT, 
getService() + ":" + getEndpoint());

                String processCorrelationId = 
(String)exchange.getProperty(JbiConstants.CORRELATION_ID);
                if (processCorrelationId != null) {
                    outExchange.setProperty(JbiConstants.CORRELATION_ID, 
processCorrelationId);
                }

//----------------------------------------------------------------------------------- 


                out = outExchange.createMessage();
            }


With this patch all seems work properly.

Is this the right way to solve the problem ?
Should I raise a Jira about this ?

Thanks
Andrea Zoppello
Engineering Ing. Informatica

Re: Correlation Id in Groovy component

Posted by Guillaume Nodet <gn...@gmail.com>.
Have you tried with the new servicemix-script component ?
This one is based on servicemix-common, so the correlationId
should be handled (at least wrt to the other thread problem).

On 12/19/06, Andrea Zoppello <zo...@libero.it> wrote:
> Hi all,
> this question is related to the change with id SM-751 on Jira.
> I tried a simple process composed in this way: HTTP BC->GROOVY
> COMPONENT->Screen BC.
> The problem is related to the propagation of correlation id, generated
> by the first HTTP BC.
> The correlation id is propagated in the right way until the message sent
> by GROOVY to Screen BC: in this case a new correlation id is
> generated, and this is not the right behaviour.
>
> The problem is in the method onMessageExchange of the class
> TransformComponentSupport (that GroovyComponent extends): in this method
> if the MEP is InOnly a new Exchange is created.
> In this new Exchange the correlation id is not copied from the original
> exchange. Also the senderEndpoint property is not setted by the method.
>
> I added some code to the onMessageExchange method to fix these 2 problems.
> Here is the modified code:
>
>             if (isInAndOut(exchange)) {
>                 out = exchange.createMessage();
>             } else {
>                 outExchange = getExchangeFactory().createInOnlyExchange();
>
>
> //-----------------------------------------------------------------------------------
>
>                 outExchange.setProperty(JbiConstants.SENDER_ENDPOINT,
> getService() + ":" + getEndpoint());
>
>                 String processCorrelationId =
> (String)exchange.getProperty(JbiConstants.CORRELATION_ID);
>                 if (processCorrelationId != null) {
>                     outExchange.setProperty(JbiConstants.CORRELATION_ID,
> processCorrelationId);
>                 }
>
> //-----------------------------------------------------------------------------------
>
>
>                 out = outExchange.createMessage();
>             }
>
>
> With this patch all seems work properly.
>
> Is this the right way to solve the problem ?
> Should I raise a Jira about this ?
>
> Thanks
> Andrea Zoppello
> Engineering Ing. Informatica
>


-- 
Cheers,
Guillaume Nodet