use of org.apache.qpid.server.model.Exchange in project qpid-broker-j by apache.
the class DirectExchangeTest method testRouteToQueueViaTwoExchanges.
@Test
public void testRouteToQueueViaTwoExchanges() {
String boundKey = "key";
Map<String, Object> attributes = new HashMap<>();
attributes.put(Exchange.NAME, getTestName());
attributes.put(Exchange.TYPE, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
Exchange via = _vhost.createChild(Exchange.class, attributes);
Queue<?> queue = _vhost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, getTestName() + "_queue"));
boolean exchToViaBind = _exchange.bind(via.getName(), boundKey, Collections.emptyMap(), false);
assertTrue("Exchange to exchange bind operation should be successful", exchToViaBind);
boolean viaToQueueBind = via.bind(queue.getName(), boundKey, Collections.emptyMap(), false);
assertTrue("Exchange to queue bind operation should be successful", viaToQueueBind);
RoutingResult<ServerMessage<?>> result = _exchange.route(_messageWithNoHeaders, boundKey, _instanceProperties);
assertTrue("Message unexpectedly not routed to queue", result.hasRoutes());
}
use of org.apache.qpid.server.model.Exchange in project qpid-broker-j by apache.
the class FanoutExchangeTest method testRouteToQueueViaTwoExchangesWithReplacementRoutingKey.
@Test
public void testRouteToQueueViaTwoExchangesWithReplacementRoutingKey() {
Map<String, Object> attributes = new HashMap<>();
attributes.put(Exchange.NAME, getTestName());
attributes.put(Exchange.TYPE, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
Exchange via = _vhost.createChild(Exchange.class, attributes);
Queue<?> queue = _vhost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, getTestName() + "_queue"));
boolean exchToViaBind = _exchange.bind(via.getName(), "key", Collections.singletonMap(Binding.BINDING_ARGUMENT_REPLACEMENT_ROUTING_KEY, "key1"), false);
assertTrue("Exchange to exchange bind operation should be successful", exchToViaBind);
boolean viaToQueueBind = via.bind(queue.getName(), "key1", Collections.emptyMap(), false);
assertTrue("Exchange to queue bind operation should be successful", viaToQueueBind);
RoutingResult<ServerMessage<?>> result = _exchange.route(_messageWithNoHeaders, null, _instanceProperties);
assertTrue("Message unexpectedly not routed to queue", result.hasRoutes());
}
use of org.apache.qpid.server.model.Exchange in project qpid-broker-j by apache.
the class HeadersExchangeTest method testRouteToQueueViaTwoExchangesWithReplacementRoutingKey.
@Test
public void testRouteToQueueViaTwoExchangesWithReplacementRoutingKey() {
Map<String, Object> attributes = new HashMap<>();
attributes.put(Exchange.NAME, getTestName());
attributes.put(Exchange.TYPE, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
Exchange via = _virtualHost.createChild(Exchange.class, attributes);
Queue<?> queue = _virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, getTestName() + "_queue"));
String bindingKey = "key";
String replacementKey = "key1";
boolean exchToViaBind = _exchange.bind(via.getName(), bindingKey, Collections.singletonMap(Binding.BINDING_ARGUMENT_REPLACEMENT_ROUTING_KEY, replacementKey), false);
assertTrue("Exchange to exchange bind operation should be successful", exchToViaBind);
Map<String, Object> arguments = getArgsMapFromStrings("prop=true", "prop2=true", "X-match=any");
boolean viaToQueueBind = via.bind(queue.getName(), replacementKey, arguments, false);
assertTrue("Exchange to queue bind operation should be successful", viaToQueueBind);
ServerMessage<?> testMessage = createTestMessage(Collections.singletonMap("prop", true));
RoutingResult<ServerMessage<?>> result = _exchange.route(testMessage, bindingKey, _instanceProperties);
assertTrue("Message unexpectedly not routed to queue", result.hasRoutes());
}
use of org.apache.qpid.server.model.Exchange in project qpid-broker-j by apache.
the class HeadersExchangeTest method testRouteToQueueViaTwoExchanges.
@Test
public void testRouteToQueueViaTwoExchanges() {
String bindingKey = "key";
Map<String, Object> attributes = new HashMap<>();
attributes.put(Exchange.NAME, getTestName());
attributes.put(Exchange.TYPE, ExchangeDefaults.FANOUT_EXCHANGE_CLASS);
Exchange via = _virtualHost.createChild(Exchange.class, attributes);
Queue<?> queue = _virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, getTestName() + "_queue"));
boolean exchToViaBind = _exchange.bind(via.getName(), bindingKey, Collections.emptyMap(), false);
assertTrue("Exchange to exchange bind operation should be successful", exchToViaBind);
boolean viaToQueueBind = via.bind(queue.getName(), bindingKey, Collections.emptyMap(), false);
assertTrue("Exchange to queue bind operation should be successful", viaToQueueBind);
RoutingResult<ServerMessage<?>> result = _exchange.route(_messageWithNoHeaders, bindingKey, _instanceProperties);
assertTrue("Message unexpectedly not routed to queue", result.hasRoutes());
}
use of org.apache.qpid.server.model.Exchange in project qpid-broker-j by apache.
the class TopicExchangeTest method testHierachicalRouteToQueueViaTwoExchangesWithReplacementRoutingKey.
@Test
public void testHierachicalRouteToQueueViaTwoExchangesWithReplacementRoutingKey() {
Map<String, Object> attributes = new HashMap<>();
attributes.put(Exchange.NAME, getTestName());
attributes.put(Exchange.TYPE, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
Exchange via = _vhost.createChild(Exchange.class, attributes);
Queue<?> queue1 = _vhost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, getTestName() + "_queue1"));
Queue<?> queue2 = _vhost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, getTestName() + "_queue2"));
String bindingKey1 = "a.#";
String bindingKey2 = "a.*";
String replacementKey1 = "key1";
String replacementKey2 = "key2";
assertTrue("Exchange to exchange bind operation should be successful", _exchange.bind(via.getName(), bindingKey1, Collections.singletonMap(Binding.BINDING_ARGUMENT_REPLACEMENT_ROUTING_KEY, replacementKey1), false));
assertTrue("Exchange to exchange bind operation should be successful", _exchange.bind(via.getName(), bindingKey2, Collections.singletonMap(Binding.BINDING_ARGUMENT_REPLACEMENT_ROUTING_KEY, replacementKey2), false));
assertTrue("Exchange to queue1 bind operation should be successful", via.bind(queue1.getName(), replacementKey1, Collections.emptyMap(), false));
assertTrue("Exchange to queue2 bind operation should be successful", via.bind(queue2.getName(), replacementKey2, Collections.emptyMap(), false));
RoutingResult<ServerMessage<?>> result = _exchange.route(_messageWithNoHeaders, "a.b", _instanceProperties);
assertEquals("Unexpected number of routes", (long) 2, (long) result.getNumberOfRoutes());
result = _exchange.route(_messageWithNoHeaders, "a.b.c", _instanceProperties);
assertEquals("Unexpected number of routes", (long) 1, (long) result.getNumberOfRoutes());
assertTrue("Message is not routed into 'queue1'", result.getRoutes().contains(queue1));
}
Aggregations