use of org.apache.qpid.server.model.Exchange in project qpid by apache.
the class Queue method mapEncode.
/**
* This method maps the org.apache.qpid.server.model.Queue to QMF2 broker properties where possible then
* serialises into the underlying Map for transmission via AMQP. This method is called by handleQueryRequest()
* in the org.apache.qpid.qmf2.agent.Agent class implementing the main QMF2 Agent behaviour.
*
* @return the underlying map.
*/
@Override
public Map<String, Object> mapEncode() {
// too late to populate the "altEx" property of the queueDeclareEvent.
if (_alternateExchange == null) {
Exchange altEx = _queue.getAlternateExchange();
if (altEx != null) {
_alternateExchangeName = _vhostName + altEx.getName();
_alternateExchange = new ObjectId("", "org.apache.qpid.broker:exchange:" + _alternateExchangeName, 0);
setRefValue("altExchange", _alternateExchange);
}
}
// Statistics
setValue("msgTotalEnqueues", _queue.getTotalEnqueuedMessages());
setValue("msgTotalDequeues", _queue.getTotalDequeuedMessages());
// msgTxnEnqueues not implemented in Java Broker
// msgTxnDequeues not implemented in Java Broker
setValue("msgPersistEnqueues", _queue.getPersistentEnqueuedMessages());
setValue("msgPersistDequeues", _queue.getPersistentDequeuedMessages());
setValue("msgDepth", _queue.getQueueDepthMessages());
setValue("byteDepth", _queue.getQueueDepthBytes());
setValue("byteTotalEnqueues", _queue.getTotalEnqueuedBytes());
setValue("byteTotalDequeues", _queue.getTotalDequeuedBytes());
// byteTxnEnqueues not implemented in Java Broker
// byteTxnDequeues not implemented in Java Broker
setValue("bytePersistEnqueues", _queue.getPersistentEnqueuedBytes());
setValue("bytePersistDequeues", _queue.getPersistentDequeuedBytes());
// Flow-to-disk Statistics not implemented in Java Broker
// releases & acquires not implemented in Java Broker
// discardsTtl (discardsTtlMessages) not implemented in Java Broker
// discardsRing not implemented in Java Broker
// discardsLvq not implemented in Java Broker
// discardsOverflow not implemented in Java Broker
// discardsSubscriber not implemented in Java Broker
// discardsPurge not implemented in Java Broker
// reroutes not implemented in Java Broker
setValue("consumerCount", _queue.getConsumerCount());
setValue("bindingCount", _queue.getBindingCount());
setValue("unackedMessages", _queue.getUnacknowledgedMessages());
setValue("messageLatency", "Not yet implemented");
// flowStopped not implemented in Java Broker
// flowStoppedCount not implemented in Java Broker
// TODO only update if statistics have actually changed.
update();
return super.mapEncode();
}
use of org.apache.qpid.server.model.Exchange in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenExchangeIsSpecified.
@Test
public void testToConversionWhenExchangeIsSpecified() {
final String testExchange = "testExchange";
Properties properties = new Properties();
properties.setTo(testExchange);
Message_1_0 message = createTestMessage(properties);
final Exchange exchange = mock(Exchange.class);
when(exchange.getName()).thenReturn(testExchange);
doReturn(exchange).when(_namedAddressSpace).getAttainedMessageDestination(eq(testExchange), anyBoolean());
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
assertEquals("Unexpected exchange", testExchange, messagePublishInfo.getExchange().toString());
assertEquals("Unexpected routing key", "", messagePublishInfo.getRoutingKey().toString());
}
use of org.apache.qpid.server.model.Exchange in project qpid-broker-j by apache.
the class EmbeddedBrokerPerClassAdminImpl method createQueue.
@Override
public void createQueue(final String queueName) {
final Map<String, Object> attributes = new HashMap<>();
attributes.put(Queue.NAME, queueName);
attributes.put(Queue.TYPE, "standard");
final Queue queue = _currentVirtualHostNode.getVirtualHost().createChild(Queue.class, attributes);
final Exchange exchange = _currentVirtualHostNode.getVirtualHost().getChildByName(Exchange.class, "amq.direct");
exchange.bind(queueName, queueName, Collections.emptyMap(), false);
}
use of org.apache.qpid.server.model.Exchange in project qpid-broker-j by apache.
the class DirectExchangeTest method testRouteToQueueViaTwoExchangesWithReplacementRoutingKeyAndFiltering.
@Test
public void testRouteToQueueViaTwoExchangesWithReplacementRoutingKeyAndFiltering() {
Map<String, Object> viaExchangeArguments = new HashMap<>();
viaExchangeArguments.put(Exchange.NAME, getTestName() + "_via_exch");
viaExchangeArguments.put(Exchange.TYPE, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
Exchange via = _vhost.createChild(Exchange.class, viaExchangeArguments);
Queue<?> queue = _vhost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, getTestName() + "_queue"));
Map<String, Object> exchToViaBindArguments = new HashMap<>();
exchToViaBindArguments.put(Binding.BINDING_ARGUMENT_REPLACEMENT_ROUTING_KEY, "key2");
exchToViaBindArguments.put(JMS_SELECTOR.toString(), "prop = True");
boolean exchToViaBind = _exchange.bind(via.getName(), "key1", exchToViaBindArguments, false);
assertTrue("Exchange to exchange bind operation should be successful", exchToViaBind);
boolean viaToQueueBind = via.bind(queue.getName(), "key2", Collections.emptyMap(), false);
assertTrue("Exchange to queue bind operation should be successful", viaToQueueBind);
RoutingResult<ServerMessage<?>> result = _exchange.route(createTestMessage(Collections.singletonMap("prop", true)), "key1", _instanceProperties);
assertTrue("Message unexpectedly not routed to queue", result.hasRoutes());
result = _exchange.route(createTestMessage(Collections.singletonMap("prop", false)), "key1", _instanceProperties);
assertFalse("Message unexpectedly routed to queue", result.hasRoutes());
}
use of org.apache.qpid.server.model.Exchange in project qpid-broker-j by apache.
the class DirectExchangeTest method testRouteToQueueViaTwoExchangesWithReplacementRoutingKey.
@Test
public void testRouteToQueueViaTwoExchangesWithReplacementRoutingKey() {
Map<String, Object> viaExchangeArguments = new HashMap<>();
viaExchangeArguments.put(Exchange.NAME, "via_exchange");
viaExchangeArguments.put(Exchange.TYPE, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
Exchange via = _vhost.createChild(Exchange.class, viaExchangeArguments);
Queue<?> queue = _vhost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, getTestName() + "_queue"));
boolean exchToViaBind = _exchange.bind(via.getName(), "key1", Collections.singletonMap(Binding.BINDING_ARGUMENT_REPLACEMENT_ROUTING_KEY, "key2"), false);
assertTrue("Exchange to exchange bind operation should be successful", exchToViaBind);
boolean viaToQueueBind = via.bind(queue.getName(), "key2", Collections.emptyMap(), false);
assertTrue("Exchange to queue bind operation should be successful", viaToQueueBind);
RoutingResult<ServerMessage<?>> result = _exchange.route(_messageWithNoHeaders, "key1", _instanceProperties);
assertTrue("Message unexpectedly not routed to queue", result.hasRoutes());
}
Aggregations