0
我正在使用駱駝。請讓我知道以下方法是否正常。生產者和消費者的連接因子
CCF對生產者
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="hornetConnectionFactory" class="org.hornetq.jms.client.HornetQJMSConnectionFactory">
<constructor-arg name="ha" value="false"></constructor-arg>
<constructor-arg>
<bean id="transportConfiguration" class="org.hornetq.api.core.TransportConfiguration">
<constructor-arg
value="org.hornetq.core.remoting.impl.netty.NettyConnectorFactory" />
<constructor-arg>
<map key-type="java.lang.String" value-type="java.lang.Object">
<entry key="host" value="127.0.0.1" />
<entry key="port" value="5445" />
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<!-- ConnectionFactory Definition -->
<bean id="connectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<constructor-arg ref="hornetConnectionFactory" />
</bean>
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
<context:component-scan base-package="com.camlin.producer" />
<camel:camelContext id="camel-server">
<camel:package>com.camlin.producer</camel:package>
</camel:camelContext>
</beans>
對消費者普通CF,
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="hornetConnectionFactory" class="org.hornetq.jms.client.HornetQJMSConnectionFactory">
<constructor-arg name="ha" value="false"></constructor-arg>
<constructor-arg>
<bean id="transportConfiguration" class="org.hornetq.api.core.TransportConfiguration">
<constructor-arg
value="org.hornetq.core.remoting.impl.netty.NettyConnectorFactory" />
<constructor-arg>
<map key-type="java.lang.String" value-type="java.lang.Object">
<entry key="host" value="127.0.0.1" />
<entry key="port" value="5445" />
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="hornetConnectionFactory" />
</bean>
<context:component-scan base-package="com.camlin.consumer" />
<camel:camelContext id="camel-consumer">
<camel:package>com.camlin.consumer</camel:package>
<camel:route id="one">
<camel:from uri="jms:queue:request?selector=type='1'" />
<camel:to uri="bean:consumerBean?method=receive1" />
</camel:route>
<camel:route id="two">
<camel:from uri="jms:queue:request?selector=type='2'" />
<camel:to uri="bean:consumerBean?method=receive2" />
</camel:route>
</camel:camelContext>
</beans>
如何在駱駝配置?正如問題中提到的,這是配置駱駝消費者的正確方法嗎?無論我看到ActiveMQ示例,JMSComponent都會將代理URL作爲ctor arg。如何使用ConnectionFactory進行配置?因爲我使用HornetQ作爲JMS提供者 – jaks