You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by Sanjesh Pathak <sa...@soapknox.com> on 2006/08/15 16:02:01 UTC

getting property value

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

RE: getting property value

Posted by Sanjesh Pathak <sa...@soapknox.com>.
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:sanjesh@soapknox.com] 
Sent: Tuesday, August 15, 2006 7:38 PM
To: synapse-dev@ws.apache.org
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:hzbarcea@gmail.com] 
Sent: Tuesday, August 15, 2006 3:07 PM
To: synapse-dev@ws.apache.org
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 <sa...@soapknox.com> 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
 

RE: getting property value

Posted by Sanjesh Pathak <sa...@soapknox.com>.
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:hzbarcea@gmail.com] 
Sent: Tuesday, August 15, 2006 3:07 PM
To: synapse-dev@ws.apache.org
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 <sa...@soapknox.com> 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
 

Re: getting property value

Posted by Hadrian Zbarcea <hz...@gmail.com>.
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 <sa...@soapknox.com> 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
>