【问题标题】:unable to get endpoint from a property in wso2 esb 5.0.0无法从 wso2 esb 5.0.0 中的属性获取端点
【发布时间】: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,'&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:下面的代码是从代理服务调用的完整序列,

我需要将 $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,'&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>

【问题讨论】:

  • 您能否显示代理中设置 queueName 属性和使用 endpt 属性的部分?
  • 尝试记录属性 endpt 并查看它是否有效。排这么长的队真的很容易搞砸。

标签: xpath wso2esb endpoint synapse


【解决方案1】:

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

你真正需要的是一个默认端点和一个带有端点值的标头“To”:

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

【讨论】:

  • 它正在工作,但是 $body 没有发送到定义的端点,我们是否应该为此添加一些其他属性?我的理解是默认发送调解器将 $body 发送到定义的端点。 org.apache.synapse/xsd">
    org.apache.synapse/xsd">
  • 也许您可以将配置添加到您的问题中?
  • 发帖有问题,你能帮帮我吗?
猜你喜欢
  • 1970-01-01
  • 2019-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-15
相关资源
最近更新 更多