Question

I'm trying to send a message through WSO2 ESB 4.6.0 using MessageProcessor:
Proxy->Proxy(Store)->Processor->Sequence->Proxy
I set a property ('transport' scope) in Proxy #1, send it to Proxy #2 where I can successfully log it, but then I pass the message to Proxy #3 through Sampling Processor and the property is getting lost.
Is this a bug? How can I send 'transport' property via Processor?

I expect value_1 to appear instead of null in Proxy_3.


<messageProcessor name="Processor_1" class="org.apache.synapse.message.processors.sampler.SamplingProcessor" messageStore="Store_1" xmlns="http://ws.apache.org/ns/synapse">
   <parameter name="interval">1000</parameter>
   <parameter name="sequence">Sequence_1</parameter>
</messageProcessor>

MessageStore

Store_1 is InMemoryMessageStore

Proxy_1

<proxy xmlns="http://ws.apache.org/ns/synapse" name="Proxy_1" transports="jms" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="my_property_1" value="value_1" scope="transport"/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
      <faultSequence/>
      <endpoint>
         <address uri="http://localhost:8280/services/Proxy_2" format="soap11" />
      </endpoint>
   </target>
   <parameter name="transport.jms.Destination">Queue</parameter>
</proxy>

Proxy_2

<proxy xmlns="http://ws.apache.org/ns/synapse" name="Proxy_2" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="preserveProcessedHeaders" value="true"/>
         <log level="custom" separator=",">
            <property name="my_property_1" expression="get-property('transport', 'my_property_1')"/>
         </log>
         <store messageStore="Store_1"/>
      </inSequence>
   </target>
</proxy>

Sequence_1

<sequence xmlns="http://ws.apache.org/ns/synapse" name="Sequence_1">
   <send>
      <endpoint>
         <address uri="http://localhost:8280/services/Proxy_3" format="soap11"/>
      </endpoint>
   </send>
</sequence>

Proxy_3

<proxy xmlns="http://ws.apache.org/ns/synapse" name="Proxy_3" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <log level="custom">            
            <property name="my_property_1" expression="get-property('transport', 'my_property_1')"/>
         </log>
         <send/>
      </inSequence>
   </target>
</proxy>
Was it helpful?

Solution

Transport properties are passed as HTTP headers. But when you store a message in a queue, it only stores what's available in the message payload, with a content type set to XML. There's no standard way to persist all the custom HTTP header information when saving the message to a queue. You have to enhance the existing message store/processor implementation take account of this additional headers. However, an easier solution would be before storing the message to the queue use enrich mediator to set the header value as a payload element in the message. Then from your proxy, before sending, extract it and create a custom header and send.

OTHER TIPS

As chintana said you have to add it to the payload if you use ESB 4.6.0 or 4.7.0. But we have already fix this to keep the header values when we store the message in the store. It will come with next release.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top