Search in sources :

Example 11 with TransactionLogResource

use of org.apache.qpid.server.store.TransactionLogResource in project qpid-broker-j by apache.

the class ConsumerTarget_0_10 method sendToDLQOrDiscard.

private void sendToDLQOrDiscard(final MessageInstanceConsumer consumer, MessageInstance entry) {
    final ServerMessage msg = entry.getMessage();
    int requeues = 0;
    if (entry.makeAcquisitionUnstealable(consumer)) {
        requeues = entry.routeToAlternate(new Action<MessageInstance>() {

            @Override
            public void performAction(final MessageInstance requeueEntry) {
                getEventLogger().message(ChannelMessages.DEADLETTERMSG(msg.getMessageNumber(), requeueEntry.getOwningResource().getName()));
            }
        }, null);
    }
    if (requeues == 0) {
        TransactionLogResource owningResource = entry.getOwningResource();
        if (owningResource instanceof Queue) {
            final Queue<?> queue = (Queue<?>) owningResource;
            final MessageDestination alternateBindingDestination = queue.getAlternateBindingDestination();
            if (alternateBindingDestination != null) {
                getEventLogger().message(ChannelMessages.DISCARDMSG_NOROUTE(msg.getMessageNumber(), alternateBindingDestination.getName()));
            } else {
                getEventLogger().message(ChannelMessages.DISCARDMSG_NOALTEXCH(msg.getMessageNumber(), queue.getName(), msg.getInitialRoutingAddress()));
            }
        }
    }
}
Also used : MessageInstance(org.apache.qpid.server.message.MessageInstance) Action(org.apache.qpid.server.util.Action) MessageDestination(org.apache.qpid.server.message.MessageDestination) ServerMessage(org.apache.qpid.server.message.ServerMessage) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource) Queue(org.apache.qpid.server.model.Queue)

Example 12 with TransactionLogResource

use of org.apache.qpid.server.store.TransactionLogResource in project qpid-broker-j by apache.

the class MessageStoreSerializer_v1 method deserializeMessageInstances.

private Record deserializeMessageInstances(final MessageStore store, final Map<UUID, UUID> queueIdMap, final Map<Long, StoredMessage<?>> messageMap, final Deserializer deserializer, Record nextRecord) throws IOException {
    while (nextRecord.getType() == RecordType.MESSAGE_INSTANCE) {
        MessageInstanceRecord messageInstanceRecord = (MessageInstanceRecord) nextRecord;
        final StoredMessage<?> storedMessage = messageMap.get(messageInstanceRecord.getMessageNumber());
        final UUID queueId = queueIdMap.get(messageInstanceRecord.getQueueId());
        if (storedMessage != null && queueId != null) {
            final Transaction txn = store.newTransaction();
            EnqueueableMessage msg = new EnqueueableMessage() {

                @Override
                public long getMessageNumber() {
                    return storedMessage.getMessageNumber();
                }

                @Override
                public boolean isPersistent() {
                    return true;
                }

                @Override
                public StoredMessage getStoredMessage() {
                    return storedMessage;
                }
            };
            txn.enqueueMessage(new TransactionLogResource() {

                @Override
                public String getName() {
                    return queueId.toString();
                }

                @Override
                public UUID getId() {
                    return queueId;
                }

                @Override
                public MessageDurability getMessageDurability() {
                    return MessageDurability.DEFAULT;
                }
            }, msg);
            txn.commitTranAsync(null);
        }
        nextRecord = deserializer.readRecord();
    }
    return nextRecord;
}
Also used : MessageDurability(org.apache.qpid.server.store.MessageDurability) Transaction(org.apache.qpid.server.store.Transaction) EnqueueableMessage(org.apache.qpid.server.message.EnqueueableMessage) UUID(java.util.UUID) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Aggregations

TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)12 MessageInstance (org.apache.qpid.server.message.MessageInstance)5 ServerMessage (org.apache.qpid.server.message.ServerMessage)4 MessageEnqueueRecord (org.apache.qpid.server.store.MessageEnqueueRecord)4 UUID (java.util.UUID)3 Transaction (org.apache.qpid.server.store.Transaction)3 Action (org.apache.qpid.server.util.Action)3 ArrayList (java.util.ArrayList)2 MessageDestination (org.apache.qpid.server.message.MessageDestination)2 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)2 Queue (org.apache.qpid.server.model.Queue)2 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)2 MockMessageInstance (org.apache.qpid.server.queue.MockMessageInstance)2 MessageStore (org.apache.qpid.server.store.MessageStore)2 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)2 PrivilegedAction (java.security.PrivilegedAction)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 EnqueueableMessage (org.apache.qpid.server.message.EnqueueableMessage)1 MessageContainer (org.apache.qpid.server.message.MessageContainer)1 MessageInstanceConsumer (org.apache.qpid.server.message.MessageInstanceConsumer)1