Sanjesh

I hope you came across this answer through my email where I stated this.. hope you didn't miss it

asankha

Sanjesh Pathak wrote:

Hi,

 

I found the answer to my question. After looking at the source code I found out that properties are only copied from request message context to response message context if the property name starts with org.apache.synapse.Constants.CORRELATE (i.e. “correlate/") string.

 

Sanjesh

 


From: Sanjesh Pathak [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 15, 2006 7:38 PM
To: [email protected]
Subject: RE: getting property value

 

Hi Hadrian,

 

Thanks for your offer of help. I have followed the builtin log mediator and developed a mediator. In mediate method I am doing this:

 

    public boolean mediate(MessageContext synCtx) {

   

        // check if it is in request phase   

        if(!synCtx.isResponse()) {       

            // if request, set property value  

            synCtx.setProperty("Id", new Long(1));

        } else {

            // response phase, retrieve value

            Long i = (Long) synCtx.getProperty("Id");

            // I am getting i as  null here

            if(i != null) {

                  log.info("Id: " + i.longValue());

            } else {

                  log.info("i is null");

            }

        }

        return true;

    }

 

The value of i is null in response phase. I have gone through the debugger as well and I see i as null during response.

 

I am attaching synapse.xml file with this mail. The mediator tag is <myMediator/> which is below <log../> tag.

 

Sanjesh

 

 


From: Hadrian Zbarcea [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 15, 2006 3:07 PM
To: [email protected]
Subject: Re: getting property value

 

Hi Sanjesh,

If I guess correctly you have two different instances of your mediator, which would explain the behavior.  You have a few options from extending the sequence mediator to using a static map for properties, thread local storage etc.

Would it be possible to share more details of what you are trying to achieve?  The synapse.xml configuration you are using for your mediator would be great and any sample code you can share.

Regards,
Hadrian

On 8/15/06, Sanjesh Pathak <[EMAIL PROTECTED]> wrote:

Hi,

 

I have created a new mediator and it is working fine. Now I want to set a property value in the request phase of the mediate method and retrieve it in response phase. What is the right approach?

 

I tried using msgContext:setProperty() in request phase and when I retrieve it using msgContext :getPorperty() I am getting a null value.

 

Sanjesh

 

--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to