Search in sources :

Example 1 with TransactionLogResource

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

the class JDBCMessageStoreTest method mockTransactionLogResource.

private TransactionLogResource mockTransactionLogResource(final UUID transactionalLogId, final String transactionalLogName) {
    final TransactionLogResource transactionalLog = mock(TransactionLogResource.class);
    when(transactionalLog.getId()).thenReturn(transactionalLogId);
    when(transactionalLog.getName()).thenReturn(transactionalLogName);
    when(transactionalLog.getMessageDurability()).thenReturn(MessageDurability.ALWAYS);
    return transactionalLog;
}
Also used : TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 2 with TransactionLogResource

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

the class AbstractServerMessageTest method createQueue.

private TransactionLogResource createQueue(String name) {
    TransactionLogResource queue = mock(TransactionLogResource.class);
    when(queue.getId()).thenReturn(UUID.randomUUID());
    when(queue.getName()).thenReturn(name);
    return queue;
}
Also used : TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 3 with TransactionLogResource

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

the class AbstractConsumerTargetTest method testConversionExceptionPolicyWhenOwningResourceIsNotMessageSource.

public void testConversionExceptionPolicyWhenOwningResourceIsNotMessageSource() throws Exception {
    final TransactionLogResource owningResource = mock(TransactionLogResource.class);
    when(_messageInstance.getOwningResource()).thenReturn(owningResource);
    try {
        _consumerTarget.sendNextMessage();
        fail("exception not thrown");
    } catch (ConnectionScopedRuntimeException e) {
        assertTrue(String.format("ConnectionScopedRuntimeException has unexpected cause '%s'", e.getCause().getClass().getSimpleName()), e.getCause() instanceof MessageConversionException);
    }
    assertTrue("message credit was not restored", _consumerTarget.isCreditRestored());
    verify(_messageInstance, never()).routeToAlternate(any(Action.class), any(ServerTransaction.class));
}
Also used : Action(org.apache.qpid.server.util.Action) MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ServerTransaction(org.apache.qpid.server.txn.ServerTransaction) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 4 with TransactionLogResource

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

the class AutoCommitTransactionTest method createTestQueueEntries.

private Collection<MessageInstance> createTestQueueEntries(boolean[] queueDurableFlags, boolean[] messagePersistentFlags) {
    Collection<MessageInstance> queueEntries = new ArrayList<MessageInstance>();
    assertTrue("Boolean arrays must be the same length", queueDurableFlags.length == messagePersistentFlags.length);
    for (int i = 0; i < queueDurableFlags.length; i++) {
        final BaseQueue queue = createTestAMQQueue(queueDurableFlags[i]);
        final ServerMessage message = createTestMessage(messagePersistentFlags[i]);
        final boolean hasRecord = queueDurableFlags[i] && messagePersistentFlags[i];
        queueEntries.add(new MockMessageInstance() {

            @Override
            public ServerMessage getMessage() {
                return message;
            }

            @Override
            public TransactionLogResource getOwningResource() {
                return queue;
            }

            @Override
            public MessageEnqueueRecord getEnqueueRecord() {
                if (hasRecord) {
                    return mock(MessageEnqueueRecord.class);
                } else {
                    return null;
                }
            }
        });
    }
    return queueEntries;
}
Also used : MockMessageInstance(org.apache.qpid.server.queue.MockMessageInstance) MessageInstance(org.apache.qpid.server.message.MessageInstance) MockMessageInstance(org.apache.qpid.server.queue.MockMessageInstance) ArrayList(java.util.ArrayList) BaseQueue(org.apache.qpid.server.queue.BaseQueue) ServerMessage(org.apache.qpid.server.message.ServerMessage) MessageEnqueueRecord(org.apache.qpid.server.store.MessageEnqueueRecord) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 5 with TransactionLogResource

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

the class JDBCMessageStoreTest method testEnqueueTransactionCommitAsync.

public void testEnqueueTransactionCommitAsync() throws Exception {
    final String queueName = getTestName();
    final UUID transactionalLogId = UUID.randomUUID();
    final MessageStore store = getStore();
    final TransactionLogResource transactionalLog = mockTransactionLogResource(transactionalLogId, queueName);
    final InternalMessage message = addTestMessage(store, queueName, "test");
    final Transaction transaction = store.newTransaction();
    final MessageEnqueueRecord record = transaction.enqueueMessage(transactionalLog, message);
    assertNotNull("Message enqueue record should not be null", record);
    assertEquals("Unexpected queue id", transactionalLogId, record.getQueueId());
    assertEquals("Unexpected message number", message.getMessageNumber(), record.getMessageNumber());
    final ListenableFuture<Void> future = transaction.commitTranAsync(null);
    future.get(1000, TimeUnit.MILLISECONDS);
}
Also used : MessageStore(org.apache.qpid.server.store.MessageStore) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Transaction(org.apache.qpid.server.store.Transaction) UUID(java.util.UUID) MessageEnqueueRecord(org.apache.qpid.server.store.MessageEnqueueRecord) 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