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

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

问题描述

如何在spring上下文中配置多个远程activemq brokers(不同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?

  • 列表项

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 个代理的 Spring 上下文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 远程代理的 Spring 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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