You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@synapse.apache.org by Michael Buchholz <m....@subnatural.de> on 2007/08/09 16:28:58 UTC

Retrieve information from synCtx

Hi,

I´m currently implementing a mediator which logs certain values of a 
mediation to a MySQL RDBMS.

How can I retrieve the following information in mediate() from the 
synapse messagecontext:
- Name or URL of the Synapse WS-Proxy the client used
- Timestamp, when the message arrived in Synapse
- Timestamp, when the reply from the backendservice arrived in synapse 
(when isResponse is true)

Also I´m looking for a way to store data in the messagecontext while in 
inSequence that I can retrieve again in the outSequence. Is this 
possible or will I have to store it somewhere outside of synapse?

Thanks for any hints.

Michael



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Retrieve information from synCtx

Posted by Ruwan Linton <ru...@gmail.com>.
Hi Michael,

On 8/10/07, Michael Buchholz <m....@subnatural.de> wrote:
>
> Hi Ruwan,
>
> comments in line.
>
> Ruwan Linton schrieb:
> > Hi Michael,
> >
> > Comments are inline;
> >
> > On 8/9/07, Michael Buchholz <m....@subnatural.de> wrote:
> >> Hi,
> >>
> >> I´m currently implementing a mediator which logs certain values of a
> >> mediation to a MySQL RDBMS.
> >
> >
> >
> > I guess you can use the newly introduced ManagedLifeCycle concept to get
> the
> > DB connection handling if you are using the svn head rather than the
> > released version..... (just a thought)
>
> I use the 1.0 version.
>
> >
> >
> > How can I retrieve the following information in mediate() from the
> >> synapse messagecontext:
> >> - Name or URL of the Synapse WS-Proxy the client used
> >
> >
> >
> > SynapseMessageContext.getTo().getAddress()
> Just FYI. One can also use:
> String proxy_name = (String) synCtx.getProperty("proxy.name");
>
> (for retrieving the proxy name directly)
>
> >
> >
> > - Timestamp, when the message arrived in Synapse
> >> - Timestamp, when the reply from the backendservice arrived in synapse
> >> (when isResponse is true)
> >
> >
> >
> > AFAIK, you can not retrieve the timestamp information for the received
> time
> > from the MessageContext. Sorry. If this is required we can add this
> > information to MC at the time we create it as a property in the MC so
> that
> > you can get it using the MessageContext.getProperty.
> It would be nice to know the time of a backend service invocation. A use
> case for this is to confirm a SLA for a backend service (e.g. "Backend
> service xy must answer any request in no more than 1 second).
> If you want to add this feature go ahead :)



I will add this as a MC property.


I´ve written my own mediator for this now that logs a timestamp before
> and after the backend invocation in the messagecontext properties.



Nice to here that.


Thanks,
Ruwan


>
> >
> > Also I´m looking for a way to store data in the messagecontext while in
> >> inSequence that I can retrieve again in the outSequence. Is this
> >> possible or will I have to store it somewhere outside of synapse?
> >
> >
> >
> > Yes. you can use MessageContext.setProperty(String key, Object value) to
> set
> > the information as a property in to the MC in the inSequence and
> retrieve
> > those information in the outSequence using the
> > MessageContext.getProperty(String
> > key) [note: you should use the same key (obviously :D)]
> Perfect.
>
> Thanks.
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-user-help@ws.apache.org
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

Re: Retrieve information from synCtx

Posted by Michael Buchholz <m....@subnatural.de>.
Hi Ruwan,

comments in line.

Ruwan Linton schrieb:
> Hi Michael,
> 
> Comments are inline;
> 
> On 8/9/07, Michael Buchholz <m....@subnatural.de> wrote:
>> Hi,
>>
>> I´m currently implementing a mediator which logs certain values of a
>> mediation to a MySQL RDBMS.
> 
> 
> 
> I guess you can use the newly introduced ManagedLifeCycle concept to get the
> DB connection handling if you are using the svn head rather than the
> released version..... (just a thought)

I use the 1.0 version.

> 
> 
> How can I retrieve the following information in mediate() from the
>> synapse messagecontext:
>> - Name or URL of the Synapse WS-Proxy the client used
> 
> 
> 
> SynapseMessageContext.getTo().getAddress()
Just FYI. One can also use:
String proxy_name = (String) synCtx.getProperty("proxy.name");

(for retrieving the proxy name directly)

> 
> 
> - Timestamp, when the message arrived in Synapse
>> - Timestamp, when the reply from the backendservice arrived in synapse
>> (when isResponse is true)
> 
> 
> 
> AFAIK, you can not retrieve the timestamp information for the received time
> from the MessageContext. Sorry. If this is required we can add this
> information to MC at the time we create it as a property in the MC so that
> you can get it using the MessageContext.getProperty.
It would be nice to know the time of a backend service invocation. A use 
case for this is to confirm a SLA for a backend service (e.g. "Backend 
service xy must answer any request in no more than 1 second).
If you want to add this feature go ahead :)

I´ve written my own mediator for this now that logs a timestamp before 
and after the backend invocation in the messagecontext properties.

> 
> 
> Also I´m looking for a way to store data in the messagecontext while in
>> inSequence that I can retrieve again in the outSequence. Is this
>> possible or will I have to store it somewhere outside of synapse?
> 
> 
> 
> Yes. you can use MessageContext.setProperty(String key, Object value) to set
> the information as a property in to the MC in the inSequence and retrieve
> those information in the outSequence using the
> MessageContext.getProperty(String
> key) [note: you should use the same key (obviously :D)]
Perfect.

Thanks.
Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Retrieve information from synCtx

Posted by Ruwan Linton <ru...@gmail.com>.
Hi Michael,

Comments are inline;

On 8/9/07, Michael Buchholz <m....@subnatural.de> wrote:
>
> Hi,
>
> I´m currently implementing a mediator which logs certain values of a
> mediation to a MySQL RDBMS.



I guess you can use the newly introduced ManagedLifeCycle concept to get the
DB connection handling if you are using the svn head rather than the
released version..... (just a thought)


How can I retrieve the following information in mediate() from the
> synapse messagecontext:
> - Name or URL of the Synapse WS-Proxy the client used



SynapseMessageContext.getTo().getAddress()


- Timestamp, when the message arrived in Synapse
> - Timestamp, when the reply from the backendservice arrived in synapse
> (when isResponse is true)



AFAIK, you can not retrieve the timestamp information for the received time
from the MessageContext. Sorry. If this is required we can add this
information to MC at the time we create it as a property in the MC so that
you can get it using the MessageContext.getProperty.


Also I´m looking for a way to store data in the messagecontext while in
> inSequence that I can retrieve again in the outSequence. Is this
> possible or will I have to store it somewhere outside of synapse?



Yes. you can use MessageContext.setProperty(String key, Object value) to set
the information as a property in to the MC in the inSequence and retrieve
those information in the outSequence using the
MessageContext.getProperty(String
key) [note: you should use the same key (obviously :D)]

Thanks,
Ruwan


Thanks for any hints.
>
> Michael
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-user-help@ws.apache.org
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"