【发布时间】:2014-08-04 23:32:00
【问题描述】:
我想知道是否有人可以帮助我进行以下设置。
我想通过 JMS 从我的应用程序向 WSO2 ESB 发送一条消息,以便 ESB 可以将其作为电子邮件发送。我使用 ActiveMQ 作为队列。直到现在,当我通过 ActiveMQ 接口向队列发送消息时,wso2 esb 得到了它。然后,wso2 esb 将消息作为电子邮件发送到特定的电子邮件地址。
所以我可以配置 ActiveMQ 和 WSO2 esb 以将 JMS 消息发送到特定的电子邮件地址(例如,specificaddress@test.com)。
这是我的问题。如何修改电子邮件的收件人地址?在 ESB 序列配置中,我目前使用的是特定地址。但地址取决于使用我的应用程序的用户。所以我必须更改“收件人”属性,具体取决于必须接收电子邮件的用户。
那么如何通过 JMS 消息将属性“To”的值以及“Subject”的值传递给 WSO2 esb 序列?
这就是我的序列的配置:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="sendMail">
<property name="messageType" value="text/html" scope="axis2" type="STRING"></property>
<property name="ContentType" value="text/html" scope="axis2"></property>
<property name="Subject" value="This is the subject." scope="transport"></property>
<property name="To" value="specificaddress@test.com" scope="transport"></property>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"></property>
<log level="full"></log>
<send>
<endpoint>
<address uri="mailto:"></address>
</endpoint>
</send>
</sequence>
这是我的代理:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="sendToMailIn"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="sendMail"/>
<description/>
</proxy>
希望有人知道。
更新
我想我有办法!!!哇 :-) 也许一开始我很愚蠢,但它是……
您可以做的是通过 JMS 消息将 SOAP 信封发送到 WSO2 ESB。然后,使用 XPath 表达式,您可以获得传递的值。代理和顺序需要稍微改变一下。
这是新的序列:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="sendMail">
<property name="messageType" value="text/html" scope="axis2" type="STRING"></property>
<property name="ContentType" value="text/html" scope="axis2"></property>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Subject" expression="$body/subject" scope="transport"></property>
<property xmlns:ns="http://org.apache.synapse/xsd" name="To" expression="$body/to" scope="transport"></property>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"></property>
<log level="full"></log>
<send>
<endpoint>
<address uri="mailto:"></address>
</endpoint>
</send>
</sequence>
这是新的代理:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="sendToMailIn"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="sendMail"/>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>text/xml</default>
</rules>
</parameter>
<description/>
</proxy>
这是 WSO2 ESB 从我的 ActiMQ 队列作为 JMS 消息接收的 SOAP 信封:
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/">
<soapenv:Body>
<subject>Email subject comes here.</subject>
<to>address@test.com</to>
</soapenv:Body>
</soapenv:Envelope>
【问题讨论】: