Glailton Costa
Glailton Costa

Reputation: 45

Recovery a property value from a proxy in another proxy in wso2 6.1

I had to create a property in a proxy, and its working properly, but I have to use this value in another proxy inside the same project.

I've tried to use this:

<property expression="$ctx:property-name" name="property-name"/>

But didn't work. Someone knows if is possible to get this value? If possible, how to do?

Upvotes: 1

Views: 267

Answers (2)

Muralidharan.rade
Muralidharan.rade

Reputation: 2336

One way would be to use the class mediator option available in WSO2 ESB.

The property that needs to be referred from another proxy or service, can be passed to this custom mediator.

<class name="samples.mediators.SimpleClassMediator">
    <property name="variable1" value="10"/>
    <property name="variable2" value="5"/>
</class>

When we implement this custom class mediator by implementing the Mediator or the AbstractMediator interface, through mediate(MessageContext synCtx) method, we get the access to Synapse Message context (the properties in this object will be available to all mediators in the same service).

With MessageContext object, you can access other global context objects like SynapseConfiguration, SynapseEnvironment etc.,

So in the mediate method, you can access the SynapseConfiguration object and use the setProperty(String key, String value) method on it and pass your property that needs to be accessed by other services or APIs. Access this property by calling getProperty() on SynapseConfiguration object by writing a similar class mediator.

References:

https://docs.wso2.com/display/ESB490/Class+Mediator http://synapse.apache.org/apidocs/org/apache/synapse/config/SynapseConfiguration.html

Upvotes: 0

Martin Hald
Martin Hald

Reputation: 676

Maybe one of this workarounds will help you.

  • pass the value as parameter (e.g. set a http header, soap property) from one proxy to another if possible

  • store you're value in a database (e.g. internal H2 database) and access it from the second proxy

Upvotes: 1

Related Questions