多个Activemq远程代理的春季配置 [英] Spring configuration for multiple Activemq remote brokers

查看:78
本文介绍了多个Activemq远程代理的春季配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Spring上下文中配置多个远程activemq代理(不同的IP地址)?以下是1个远程代理的配置。我正在使用骆驼创建路由,这些路由在多个远程代理中的不同队列之间产生和使用消息。基于以下路由,系统如何知道每个队列属于哪个远程代理?

How to configure multiple remote activemq brokers (different IP address) in spring context? Below is the configuration for 1 remote broker. I am using camel to create routes that produce and consume messages from and to different queues in multiple remote brokers. Based on the following routes, how do the system knows which remote broker each queue belongs to?


  • 列表项

  • List item

from( direct:start) .to( activemq:queue:outgoingRequests)

from("direct:start").to("activemq:queue:outgoingRequests")

列表项

from( activemq :queue:incomingOrders)。to( log:Events?
showAll = true)。to( bean:jmsService)

from("activemq:queue:incomingOrders").to("log:Events? showAll=true").to("bean:jmsService")

1个经纪人的春季上下文

org.camel.routes

Spring context for 1 broker org.camel.routes

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://10.1.11.97:61616" />
</bean>

<bean id="pooledConnectionFactory"
    class="org.apache.activemq.pool.PooledConnectionFactory" init-
            method="start" destroy-method="stop">
    <property name="maxConnections" value="8" />
    <property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>

<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="connectionFactory" ref="pooledConnectionFactory"/>
    <property name="concurrentConsumers" value="10"/>
</bean>

<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="configuration" ref="jmsConfig"/>
</bean>


推荐答案

只需添加更多具有不同名称的组件

Just add more components with different names

<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
   <property name="configuration" ref="jmsConfig"/>
</bean>

<bean id="activemq2" class="org.apache.activemq.camel.component.ActiveMQComponent">
   <property name="configuration" ref="myOtherJmsConfig"/>
</bean>

然后只需使用名称:

<from uri="activemq:queue:MY.QUEUE"/><!-- get from "1st" ActiveMQ -->
<to uri="activemq2:queue:MY.QUEUE"/> <!-- put to same queue name on other ActiveMQ -->

实际上,您可以随意调用它们,例如 EuropeanMarketBroker或任何合适的容器。

Actually, you can call them whatever you want, like "EuropeanMarketBroker" or whatever fits in.

这篇关于多个Activemq远程代理的春季配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆