【发布时间】:2017-11-19 00:31:13
【问题描述】:
我正在尝试向 JMS 队列发送消息,队列名称是动态的,将从 DB 中获取。
与队列名称、连接工厂详细信息、初始上下文工厂、提供程序 url 一起连接并保存在 wso2 esb 中的属性 (endpt) 中。
我想在发送调解器中使用最终连接字符串 (endpt) 作为端点,我已将端点类型指定为 XPATH 并使用 $ctx:endpt 调用变量(endpt 是我最终形成 URL 的属性),并且它不工作。
<?xml version="1.0" encoding="UTF-8"?>
<property
expression="fn:concat('jms://', $ctx:queueName, '?
transport.jms.ConnectionFactoryJNDIName=', $ctx:connectionFactory,'&java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory&java.naming.provider.url=', 't3://localhost:7003,localhost:7004', '&transport.jms.DestinationType=queue')"
name="endpt" scope="default" type="STRING"
xmlns="http://ws.apache.org/ns/synapse"
xmlns:ns="http://org.apache.synapse/xsd"/>
编辑 1:下面的代码是从代理服务调用的完整序列,
我需要将 $body 发送到 To 标头中定义的端点。当我在代理服务的序列中的发送中介中定义一个 endpt 时,同样的工作,但是当我从代理服务调用上述序列(使用序列中介)时,空消息被发送到 JMS 队列。
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="sendtoconsumer" xmlns="http://ws.apache.org/ns/synapse">
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property expression="//*[name() = 'CONSUMER_REFERENCE']/text()"
name="topic" scope="default" type="STRING"
xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="fn:substring-before($ctx:topic,'//')"
name="topicval" scope="default" type="STRING"
xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:ns="http://org.apache.synapse/xsd"/>
<property
expression="fn:substring-before(fn:substring-after($ctx:topic,'//'),'@')"
name="queueName" scope="default" type="STRING"
xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="fn:substring-after($ctx:topic,'@')"
name="connectionFactory" scope="default" type="STRING"
xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:ns="http://org.apache.synapse/xsd"/>
<log level="custom">
<property expression="$ctx:pubRequest" name="body" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="$ctx:topic" name="topic" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="$ctx:topicval" name="topicval" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<switch source="get-property('topicval')" xmlns:ns="http://org.apache.synapse/xsd">
<case regex="mq:"/>
<case regex="java:">
<property
expression="fn:concat('jms://', $ctx:queueName, '?transport.jms.ConnectionFactoryJNDIName=', $ctx:connectionFactory,'&java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory&java.naming.provider.url=', 't3://localhost:7003,localhost:7004', '&transport.jms.DestinationType=queue')"
name="endpt" scope="default" type="STRING"/>
<log level="custom">
<property expression="$ctx:endpt" name="sendvalue"/>
</log>
<header expression="get-property('endpt')" name="To"/>
<send>
<endpoint>
<default/>
</endpoint>
</send>
</case>
<case regex="http:"/>
<default>
<log level="custom">
<property expression="$ctx:topic" name="poda"/>
</log>
</default>
</switch>
</sequence>
【问题讨论】:
-
您能否显示代理中设置 queueName 属性和使用 endpt 属性的部分?
-
尝试记录属性 endpt 并查看它是否有效。排这么长的队真的很容易搞砸。
标签: xpath wso2esb endpoint synapse