2013-06-04 25 views
0

我試圖用通過的MessageProcessor WSO2 ESB 4.6.0發送消息:
的Proxy->代理(商店) - >處理器 - >序列 - >代理
我在代理#1中設置了一個屬性('transport'作用域),將它發送到代理#2,在那裏我可以成功記錄它,但隨後我通過採樣處理器將消息傳遞給代理#3,並且屬性正在丟失
這是一個錯誤?我如何通過處理器發送'transport'屬性?

我希望value_1在代理_3中出現而不是nullWSO2 ESB:頭損失(SamplingProcessor)


<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> 

回答

3

傳輸屬性作爲HTTP頭傳遞。但是,當您將消息存儲在隊列中時,它僅存儲消息有效內容中可用的內容,並將內容類型設置爲XML。將消息保存到隊列時,沒有標準的方法來保存所有自定義HTTP頭信息。考慮到這些額外的頭文件,你必須增強現有的消息存儲/處理器實現。然而,在將消息存儲到隊列之前,使用增強中介器將消息頭中的消息頭值設置爲有效內容元素之前,一個更簡單的解決方案是。然後從您的代理髮送之前,提取它並創建一個自定義標題併發送。

+0

謝謝@Chintana!我是否正確解決了在保存到MessageStore之前需要將傳輸屬性放在_SOAP Envelope Header_中的問題? – surlac

+0

是的,您可以將它作爲SOAP Header元素或有效負載中的特殊元素。 –

2

正如辛塔納說,如果您使用ESB 4.6.0或4.7.0,您必須將其添加到有效負載。但是,我們已經解決了這個問題,以便在我們將消息存儲在商店中時保留標題值。它將在下一個版本發佈。