use of org.apache.activemq.artemis.core.postoffice.impl.BindingsImpl in project activemq-artemis by apache.
the class TopicCleanupTest method testWildcardSubscriber.
@Test
public void testWildcardSubscriber() throws Exception {
ActiveMQTopic topic = (ActiveMQTopic) createTopic("topic.A");
Connection conn = cf.createConnection();
conn.start();
try {
Session consumerStarSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumerStar = consumerStarSession.createConsumer(ActiveMQJMSClient.createTopic("topic.*"));
Session consumerASession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumerA = consumerASession.createConsumer(topic);
Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producerA = producerSession.createProducer(topic);
TextMessage msg1 = producerSession.createTextMessage("text");
producerA.send(msg1);
consumerStar.close();
consumerA.close();
producerA.send(msg1);
conn.close();
boolean foundStrayRoutingBinding = false;
Bindings bindings = server.getPostOffice().getBindingsForAddress(new SimpleString(topic.getAddress()));
Map<SimpleString, List<Binding>> routingNames = ((BindingsImpl) bindings).getRoutingNameBindingMap();
for (SimpleString key : routingNames.keySet()) {
if (!key.toString().equals(topic.getAddress())) {
foundStrayRoutingBinding = true;
assertEquals(0, ((LocalQueueBinding) routingNames.get(key).get(0)).getQueue().getMessageCount());
}
}
assertFalse(foundStrayRoutingBinding);
} finally {
jmsServer.stop();
jmsServer.start();
try {
conn.close();
} catch (Throwable igonred) {
}
}
}
use of org.apache.activemq.artemis.core.postoffice.impl.BindingsImpl in project activemq-artemis by apache.
the class BindingsImplTest method internalTest.
private void internalTest(final boolean route) throws Exception {
final FakeBinding fake = new FakeBinding(new SimpleString("a"));
final Bindings bind = new BindingsImpl(null, null, null);
bind.addBinding(fake);
bind.addBinding(new FakeBinding(new SimpleString("a")));
bind.addBinding(new FakeBinding(new SimpleString("a")));
Thread t = new Thread() {
@Override
public void run() {
try {
bind.removeBinding(fake);
} catch (Exception e) {
e.printStackTrace();
}
}
};
Queue queue = new FakeQueue(new SimpleString("a"));
t.start();
for (int i = 0; i < 100; i++) {
if (route) {
bind.route(new CoreMessage(i, 100), new RoutingContextImpl(new FakeTransaction()));
} else {
bind.redistribute(new CoreMessage(i, 100), queue, new RoutingContextImpl(new FakeTransaction()));
}
}
}
Aggregations