我有一个入站端点配置,我想在java.naming.provider.url
内指定jndi.properties
值,这将使我根据所拥有的不同环境的提供者URL动态配置入站端点。
这是我的ActiveMq的axis2.xml配置
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="myTopicConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">failover:tcp://localhost:6092</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
</parameter>
<parameter name="myQueueConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">failover:tcp://localhost:6092</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>
<parameter name="default" locked="false">
<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">failover:tcp://localhost:6092</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>
</transportReceiver>
这是我的入站端点配置:
<?xml version="1.0" encoding="UTF-8"?>
<inboundEndpoint name="inboundEP" onError="conf:sequences/om.esb/om.esb-faultSQ.xml" protocol="jms" sequence="inbEPSQ" suspend="false" xmlns="http://ws.apache.org/ns/synapse">
<parameters>
<parameter name="interval">1000</parameter>
<parameter name="sequential">true</parameter>
<parameter name="coordination">true</parameter>
<parameter name="transport.jms.Destination">example_request</parameter>
<parameter name="transport.jms.CacheLevel">3</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter>
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">conf/jndi.properties</parameter>
<parameter name="transport.jms.SessionAcknowledgement">AUTO_ACKNOWLEDGE</parameter>
<parameter name="transport.jms.SessionTransacted">false</parameter>
<parameter name="transport.jms.ConnectionFactoryType">queue</parameter>
<parameter name="transport.jms.ContentType">application/json</parameter>
<parameter name="transport.jms.SharedSubscription">false</parameter>
</parameters>
</inboundEndpoint>
在jndi.properties文件中,我尝试以这种方式指定java.naming.provider.url
:
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5675'
connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5675'
java.naming.provider.url=failover:tcp://localhost:6092
# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.MyQueue = example.MyQueue
# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.MyTopic = example.MyTopic
但是在WSO2控制台中,出现以下错误:
Could not create Transport. Reason: java.io.IOException: Transport not scheme specified: [conf/jndi.properties]
感谢任何想法!
答案 0 :(得分:0)
顾名思义,“ java.naming.provider.url”应该是一个URL,所以以“(protocol)://”开头的内容
由于tcp:// localhost:6092在您的其他配置中为您工作,因此请尝试以下操作:
<parameter name="java.naming.provider.url" locked="false">tcp://localhost:6092</parameter>
JNDI中发生的事情是,首先创建“ java.naming.factory.initial”类(在您的情况下为org.apache.activemq.jndi.ActiveMQInitialContextFactory),然后可以使用任何支持的提供者URL由这个班。根据您的提供程序,它可能支持不同的URL类型(tcp:,file:,ssl:,...)。 ActiveMQ支持vm:和tcp:-指定tcp时:它将使用来自该代理的TCP加载此JNDI配置。