无法从 wso2 esb 5.0.0 中的 属性 获取端点

unable to get endpoint from a property in wso2 esb 5.0.0

我正在尝试向 JMS queue 发送消息,queue 名称是动态的,它将从数据库中获取。

连同 queue 名称、连接工厂详细信息、初始上下文工厂、提供程序 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 header 中定义的端点。当我在代理服务的序列中的发送中介中定义一个 endpt 时,同样有效,但是当我从代理服务调用上述序列(使用序列中介)时,空消息被发送到 JMS queue.

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

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

您实际需要的是一个默认端点和一个 header "To",端点值:

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