Search in sources :

Example 11 with ServerMessage

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());
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) HashMap(java.util.HashMap) ServerMessage(org.apache.qpid.server.message.ServerMessage)

Example 12 with ServerMessage

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;
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 13 with ServerMessage

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;
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage)

Example 14 with ServerMessage

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;
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage)

Example 15 with ServerMessage

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);
        }
    }
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage)

Aggregations

ServerMessage (org.apache.qpid.server.message.ServerMessage)103 HashMap (java.util.HashMap)26 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)16 TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)16 Exchange (org.apache.qpid.server.model.Exchange)14 MessageReference (org.apache.qpid.server.message.MessageReference)13 ArrayList (java.util.ArrayList)9 MessageInstance (org.apache.qpid.server.message.MessageInstance)8 InstanceProperties (org.apache.qpid.server.message.InstanceProperties)7 Queue (org.apache.qpid.server.model.Queue)7 StoredMessage (org.apache.qpid.server.store.StoredMessage)6 MessageEnqueueRecord (org.apache.qpid.server.store.MessageEnqueueRecord)4 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)3 TestConsumerTarget (org.apache.qpid.server.consumer.TestConsumerTarget)3 MessageDeletedException (org.apache.qpid.server.message.MessageDeletedException)3 PrivilegedAction (java.security.PrivilegedAction)2 UUID (java.util.UUID)2 MessageDestination (org.apache.qpid.server.message.MessageDestination)2 MessageInstanceConsumer (org.apache.qpid.server.message.MessageInstanceConsumer)2 RoutingResult (org.apache.qpid.server.message.RoutingResult)2