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);
精彩评论