2017-06-16 57 views
0

我想向JMS队列发送消息,队列名称是动态的,它将从数据库中获取。无法从wso2中的属性获取端点esb 5.0.0

随着队列名称,连接工厂详细信息,初始上下文工厂,提供者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,'&amp;java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory&amp;java.naming.provider.url=', 't3://localhost:7003,localhost:7004', '&amp;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:下面的代码是从代理服务调用的完整序列,

我需要$主体发送到定义在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,'&amp;java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory&amp;java.naming.provider.url=', 't3://localhost:7003,localhost:7004', '&amp;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> 
+0

您能不能告诉你设置QUEUENAME财产,在您使用的endpt物业代理的部分? – ophychius

+0

尝试记录属性endpt并查看它是否有效。在这么长的路线上混乱真的很容易。 – simar

回答

0

Xpath端点是一个键表达式 - 即指向资源 - 在注册表中或在本地端点中。

你真正需要的是一个默认的端点和头“到”端点值:

<header name="To" expression="get-property('endpt')"/> 
<send> 
    <endpoint> 
     <default/> 
    </endpoint> 
</send> 
+0

它正在工作,但$ body没有发送到定义的端点,我们是否应该添加一些其他属性? 我的理解是发送中介默认发送$ body到定义的端点。 \t <属性表达式= “$ CTX:endpt” 名称= “sendvalue” 的xmlns:ns的= “HTTP://org.apache.synapse/xsd”/> \t \t \t \t <头表达=“GET-属性( 'endpt')”名称= “要” 的xmlns:ns的= “HTTP://org.apache.synapse/xsd”/> \t \t \t \t \t \t \t \t \t \t

+0

也许你可以添加你的配置到你的问题? –

+0

张贴在问题中,你能帮我解决吗? –