MuleMessage properties during all journey through synchronous endpoints

View: New views
8 Messages — Rating Filter:   Alert me  

MuleMessage properties during all journey through synchronous endpoints

by Anatoli Kuzmin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

Can my message save custom properties if I use synchronous endpoints during all journey?
I want to set custom properties in the first transformer T1 (using message.setStringProperty("SessionID",ctSession);)
and get it in responseTransformer T2.

Unfortunately message had have the same unique id but my custom properties was lost.
Also I tried to set correlationId - the same. 


  <http:endpoint name="clientEndpoint" address="http://localhost:4019
" synchronous="true"/>
    <http:endpoint name="serverEndpoint" address="http://localhost:4020" synchronous="true"/>

    <custom-transformer class="Trans1" name="T1"/>
    <custom-transformer class="Trans2" name="T2"/>

    <model name="main">
        <service name="HttpProxyService">
            <inbound>
                <inbound-endpoint ref="clientEndpoint" />
            </inbound>
            <outbound>
                <pass-through-router>
                    <outbound-endpoint ref="serverEndpoint" transformer-refs="T1"
                                       responseTransformer-refs="T2">
                    </outbound-endpoint>
                </pass-through-router>
            </outbound>
        </service>


--
Best regards,
Anatoli Kuzmin

RE: MuleMessage properties during all journey through synchronous endpoints

by neilwh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

I think it depends on what the transport is doing. Many transports and components will strip properties from the MuleMessage during transactions. For what you are trying to do, I suggest you use the MuleRegistry. That’s what I do to track properties that I want to use between multiple endpoints (and that’s what its intention is). You usually need  to use your own component to get to the MuleRegistry as it can only be obtained through the MuleContext. Take a look at

http://www.mulesource.org/display/MULE2USER/Storing+Objects+in+the+Registry

 

Neil

 


From: Anatoli Kuzmin [mailto:anatoli.kuzmin@...]
Sent: Tuesday, June 30, 2009 12:13 PM
To: user@...
Subject: [mule-user] MuleMessage properties during all journey through synchronous endpoints

 

Hi

Can my message save custom properties if I use synchronous endpoints during all journey?
I want to set custom properties in the first transformer T1 (using message.setStringProperty("SessionID",ctSession);)
and get it in responseTransformer T2.

Unfortunately message had have the same unique id but my custom properties was lost.
Also I tried to set correlationId - the same. 


  <http:endpoint name="clientEndpoint" address="http://localhost:4019

" synchronous="true"/>
    <http:endpoint name="serverEndpoint" address="http://localhost:4020" synchronous="true"/>

    <custom-transformer class="Trans1" name="T1"/>
    <custom-transformer class="Trans2" name="T2"/>

    <model name="main">
        <service name="HttpProxyService">
            <inbound>
                <inbound-endpoint ref="clientEndpoint" />
            </inbound>
            <outbound>
                <pass-through-router>
                    <outbound-endpoint ref="serverEndpoint" transformer-refs="T1"
                                       responseTransformer-refs="T2">
                    </outbound-endpoint>
                </pass-through-router>
            </outbound>
        </service>



--
Best regards,
Anatoli Kuzmin


Re: MuleMessage properties during all journey through synchronous endpoints

by Andrew Perepelytsya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Anatoli,

I assume you're using recent Mule release (2.2.1?). Message properties are actually scoped, thus inbound properties will not end up in response scope. From your description it looks like you need a correlation to be preserved. So, granted the remote system doesn't drop your custom properties, take a look at <expression-message-info-mapping/>, it let's you customize what properties are used for correlation, how to extract them from a message, and where to get a match from the response message.

HTH,
Andrew

On Tue, Jun 30, 2009 at 12:12 PM, Anatoli Kuzmin <anatoli.kuzmin@...> wrote:
Hi

Can my message save custom properties if I use synchronous endpoints during all journey?
I want to set custom properties in the first transformer T1 (using message.setStringProperty("SessionID",ctSession);)
and get it in responseTransformer T2.

Unfortunately message had have the same unique id but my custom properties was lost.
Also I tried to set correlationId - the same. 


  <http:endpoint name="clientEndpoint" address="http://localhost:4019
" synchronous="true"/>
    <http:endpoint name="serverEndpoint" address="http://localhost:4020" synchronous="true"/>

    <custom-transformer class="Trans1" name="T1"/>
    <custom-transformer class="Trans2" name="T2"/>

    <model name="main">
        <service name="HttpProxyService">
            <inbound>
                <inbound-endpoint ref="clientEndpoint" />
            </inbound>
            <outbound>
                <pass-through-router>
                    <outbound-endpoint ref="serverEndpoint" transformer-refs="T1"
                                       responseTransformer-refs="T2">
                    </outbound-endpoint>
                </pass-through-router>
            </outbound>
        </service>


--
Best regards,
Anatoli Kuzmin


Re: MuleMessage properties during all journey through synchronous endpoints

by Andrew Perepelytsya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Also, you can use Mule session to store props for multiple endpoints sync flow.

Andrew

Re: MuleMessage properties during all journey through synchronous endpoints

by Anatoli Kuzmin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks. I will try to save setting to session.


On Tue, Jun 30, 2009 at 8:39 PM, Andrew Perepelytsya <aperepel@...> wrote:
Also, you can use Mule session to store props for multiple endpoints sync flow.

Andrew



--
Best regards,
Anatoli Kuzmin

Re: MuleMessage properties during all journey through synchron

by Gerwin Postma :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrew,

This only works with synchronous endpoints, right? I'm using an asynchronous model and was wondering how to pass properties from service to service (or endpoint to endpoint ;-) ). For example in the first step I indicate certain messages as test messages. When a test message arrives at my LogComponent, I don't want it to be logged (because it is a test message). I'm using the MuleMessage properties to store this information, but with some routers the properties are lost (for example the chaining-router). I fixed this by extending the chaining-router. In the processIntermediaryResult method the properties of the intermediary MuleMessage are copied to the local MuleMessage. But to extend routers for this functionality is not desirable. Is there another way to achieve this (besides altering the payload and storing it there?)

I tried the MuleSession but the Session object in my first step is different than the Session object at my LogComponent.

Regards,
Mario

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: MuleMessage properties during all journey through synchron

by Andrew Perepelytsya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mario, it sounds like those properties are really part of the logic. Why not keep it next to the data then? Wrap your payload in some envelope with business properties stored in it.

HTH,
Andrew

On Jul 2, 2009 8:50 AM, "Mario Klaver" <mule.user.relay@...> wrote:

Andrew,

This only works with synchronous endpoints, right? I'm using an asynchronous model and was wondering how to pass properties from service to service (or endpoint to endpoint ;-) ). For example in the first step I indicate certain messages as test messages. When a test message arrives at my LogComponent, I don't want it to be logged (because it is a test message). I'm using the MuleMessage properties to store this information, but with some routers the properties are lost (for example the chaining-router). I fixed this by extending the chaining-router. In the processIntermediaryResult method the properties of the intermediary MuleMessage are copied to the local MuleMessage. But to extend routers for this functionality is not desirable. Is there another way to achieve this (besides altering the payload and storing it there?)

I tried the MuleSession but the Session object in my first step is different than the Session object at my LogComponent.

Regards,
Mario

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Re: MuleMessage properties during all journey through synchron

by Gerwin Postma :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrew, You are probably right. I didn't wanna smudge my payload. But why not? One translation to remove them from the payload again, is still easier than extending a couple of routers...

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email