Queue consumer cluster和Broker cluster

import org.apache.activemq.ActiveMQConnectionFactory;
import javax.jms.*;
public class QueueSender1 {
public static void main(String[] args) throws JMSException, InterruptedException {
// ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://192.168.25.128:61616");
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
"failover:(tcp://192.168.25.128:61616,tcp://192.168.25.128:61716)?randomize=true");
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("my-queue");
MessageProducer producer = session.createProducer

本文介绍了ActiveMQ的集群设置,包括Queue consumer cluster和Broker cluster。在集群环境中,消费者c1和c2能均衡地从由brokerA和brokerB组成的集群中消费消息。通过修改activmq.xml配置文件并重启服务,确保了消息消费的均衡性。
最低0.47元/天 解锁文章
1178

被折叠的 条评论
为什么被折叠?



