开发者

ActiveMQ: Configure per-destination policy in Java (total ordering)

开发者 https://www.devze.com 2023-03-13 23:19 出处:网络
I have an ActiveMQ embedded broker, along with a number of Topic clients.Everything is currently configured in Java (rather than XML).I want to configure total ordering of the topic\'s messages across

I have an ActiveMQ embedded broker, along with a number of Topic clients. Everything is currently configured in Java (rather than XML). I want to configure total ordering of the topic's messages across clients.

ActiveMQ specifies total ordering as a per-destination policy. Is there a way to configure this in Java directly?

The vanillaish startup code I've been using:

// broker code (single broker)
BrokerService broker = new BrokerService();
br开发者_如何学JAVAoker.addConnector(address);
broker.setPersistent(false);
broker.setUseJmx(false);
broker.start();

// client code (multiple clients)
ActiveMQConnectionFactory connectionFactory 
           = new ActiveMQConnectionFactory(address);
connection = connectionFactory.createConnection();
connection.start();

session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
topic = session.createTopic(topicName);    
producer = session.createProducer(topic);
consumer = session.createConsumer(topic);


The code would look something like this:

    PolicyEntry policy = new PolicyEntry();
    policy.setDispatchPolicy(new StrictOrderDispatchPolicy());

    PolicyMap pMap = new PolicyMap();
    pMap.setDefaultEntry(policy);

    broker.setDestinationPolicy(pMap);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号