use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class FanoutExchangeTest method testRouteToQueueViaTwoExchanges.
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 = _vhost.createChild(Exchange.class, attributes);
Queue<?> queue = _vhost.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, null, _instanceProperties);
assertTrue("Message unexpectedly not routed to queue", result.hasRoutes());
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class DefinedGroupMessageGroupManager method getKey.
private Object getKey(QueueEntry entry) {
ServerMessage message = entry.getMessage();
AMQMessageHeader messageHeader = message == null ? null : message.getMessageHeader();
Object groupVal = messageHeader == null ? _defaultGroup : _groupId == null ? messageHeader.getGroupId() : messageHeader.getHeader(_groupId);
if (groupVal == null) {
groupVal = _defaultGroup;
}
return groupVal;
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class QueueSizeLimitRespectingTransaction method updateEntry.
@Override
protected boolean updateEntry(QueueEntry entry, QueueManagingVirtualHost.Transaction txn) {
ServerMessage message = entry.getMessage();
_pendingQueueDepthMessages++;
_pendingQueueDepthBytes += message == null ? 0 : message.getSizeIncludingHeader();
boolean underfull = isUnderfull();
if (message != null && !message.isReferenced(_destinationQueue) && underfull) {
performOperation(entry, txn, _destinationQueue);
}
return !underfull;
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class SortedQueueEntryList method getOldestEntry.
@Override
public QueueEntry getOldestEntry() {
QueueEntry oldestEntry = null;
QueueEntryIterator iter = iterator();
while (iter.advance()) {
QueueEntry node = iter.getNode();
if (node != null && !node.isDeleted()) {
ServerMessage msg = node.getMessage();
if (msg != null && (oldestEntry == null || oldestEntry.getMessage().getMessageNumber() > msg.getMessageNumber())) {
oldestEntry = node;
}
}
}
return oldestEntry;
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class ConsumerTarget_0_8 method doSend.
@Override
protected final void doSend(final MessageInstanceConsumer consumer, final MessageInstance entry, final boolean batch) {
ServerMessage serverMessage = entry.getMessage();
MessageConverter<ServerMessage<?>, AMQMessage> messageConverter = null;
final AMQMessage msg;
if (serverMessage instanceof AMQMessage) {
msg = (AMQMessage) serverMessage;
} else {
messageConverter = MessageConverterRegistry.getConverter((Class<ServerMessage<?>>) serverMessage.getClass(), AMQMessage.class);
msg = messageConverter.convert(serverMessage, getConnection().getAddressSpace());
}
try {
doSendInternal(consumer, entry, msg, batch);
} finally {
if (messageConverter != null) {
messageConverter.dispose(msg);
}
}
}
Aggregations