简体   繁体   English

JBoss EAP 7.2.0 中的负载平衡 ActimeMQ Artemis

[英]Load Balancing ActimeMQ Artemis in JBoss EAP 7.2.0

We are developing an application using Spring Boot and Apache Camel that is reading a message from ActiveMQ Artemis, doing some transformation, and sending it to ActiveMQ Artemis.我们正在使用 Spring Boot 和 Apache Camel 开发一个应用程序,它正在从 ActiveMQ Artemis 读取消息,进行一些转换,然后将其发送到 ActiveMQ Artemis。 Our application is deployed as war file in on-premise JBoss EAP 7.2.0.我们的应用程序部署为本地 JBoss EAP 7.2.0 中的 war 文件。 Both the source and target applications are remote to our application and they are also deployed on JBoss EAP 7.2.0.源应用程序和目标应用程序都远离我们的应用程序,它们也部署在 JBoss EAP 7.2.0 上。 The remote queues to which Camel is connecting are ActiveMQ Artemis which were created in JBoss and connecting using http-remoting protocol. Camel 连接的远程队列是 ActiveMQ Artemis,它是在 JBoss 中创建的,并使用 http-remoting 协议进行连接。 These setup was working when there were only one node of each of the applications.这些设置在每个应用程序只有一个节点时有效。

Now we are making the source and target applications 3 nodes each (ie they will be deployed in multiple JBoss servers).现在我们使源应用程序和目标应用程序各有 3 个节点(即它们将部署在多个 JBoss 服务器中)。 For accessing the front-end of the source and target applications we are configuring and accessing them through a load balancer.为了访问源应用程序和目标应用程序的前端,我们通过负载均衡器配置和访问它们。

Can we configure the load balancer to access the source and target brokers from the Camel layer?我们可以将负载均衡器配置为从 Camel 层访问源代理和目标代理吗? There will be 3 source and 3 target brokers.将有 3 个源代理和 3 个目标代理。 Or is clustering the brokers the only option in this case?或者在这种情况下集群代理是唯一的选择吗?

We are thinking of load balancing between the queues and not clustering.我们正在考虑队列之间的负载平衡,而不是集群。 Suppose we have three queues q1 , q2 , and q3 with corresponding brokers b1 , b2 , and b3 .假设我们有三个队列q1q2q3以及相应的代理b1b2b3 I will configure the load balancer url in the Camel layer like http-remoting://<load-balancer-url>:<port> (much like we do while load balancing HTTP API requests).我将在 Camel 层中配置负载平衡器 url,例如http-remoting://<load-balancer-url>:<port> (就像我们在负载平衡 HTTP ZDB974238714CA38DE634A7CE10D 请求时所做的那样)。 Any message coming in will hit the load balancer, and the load balancer will decide which queue to route the message to.任何传入的消息都会到达负载均衡器,负载均衡器将决定将消息路由到哪个队列。

JMS connections are stateful . JMS 连接是有状态的。 When a client creates a connection there is no indication of the queues to which it will send messages.当客户端创建连接时,没有指示它将向哪个队列发送消息。 The load-balancer will have to direct that client's connection to either b1 , b2 , or b3 and it will have no way to determine where it should go.负载平衡器必须将该客户端的连接定向到b1b2b3 ,并且无法确定它应该在哪里 go。 A load-balancer working with messaging will almost certainly only be able to balance connections , not messages.使用消息传递的负载均衡器几乎可以肯定只能平衡连接,而不是消息。 It sounds like you want load-balancing at the message level instead.听起来您想要在消息级别进行负载平衡。 Perhaps you should look into something like Qpid Dispatch Router .也许您应该研究一下Qpid Dispatch Router 之类的东西。

Messaging doesn't use HTTP so using an HTTP load balancer like you do with your HTTP API(s) won't work.消息传递不使用 HTTP,因此像使用 HTTP API 一样使用 HTTP 负载均衡器将不起作用。 It's easy for a load-balancer to inspect HTTP headers and route requests, especially since HTTP is stateless.负载均衡器很容易检查 HTTP 标头和路由请求,特别是因为 HTTP 是无状态的。 However, messaging connections are stateful and the protocols are typically quite a bit more complex than HTTP.但是,消息连接是有状态的,并且协议通常比 HTTP 复杂得多。 I don't know of any load-balancers that will work the way you are wanting for messaging.我不知道有任何负载均衡器可以按照您想要的消息传递方式工作。

You need your client not to use the topology, you can do this by using "setUseTopologyForLoadBalancing" on your AMQConnectionFactory.您需要您的客户端不使用拓扑,您可以通过在 AMQConnectionFactory 上使用“setUseTopologyForLoadBalancing”来做到这一点。 If you get the connection factory from EAP I think this is configurable on the connection factory since EAP 7.3.如果您从 EAP 获得连接工厂,我认为这是自 EAP 7.3 起在连接工厂上可配置的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM