Search in sources :

Example 86 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class ManagementNodeConsumer method enqueue.

@Override
public void enqueue(final ServerMessage message, final Action<? super MessageInstance> action, final MessageEnqueueRecord record) {
    final InternalMessage internalMessage = (InternalMessage) message;
    final ManagementResponse responseEntry = new ManagementResponse(this, internalMessage);
    send(responseEntry);
    if (action != null) {
        action.performAction(responseEntry);
    }
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage)

Example 87 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage 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)

Example 88 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class JDBCMessageStoreTest method testDequeueTransactionCommitAsync.

public void testDequeueTransactionCommitAsync() 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, "test2");
    final Transaction enqueueTransaction = store.newTransaction();
    MessageEnqueueRecord record = enqueueTransaction.enqueueMessage(transactionalLog, message);
    enqueueTransaction.commitTran();
    final Transaction dequeueTransaction = store.newTransaction();
    dequeueTransaction.dequeueMessage(record);
    final ListenableFuture<Void> future = dequeueTransaction.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)

Example 89 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class MessageConverter_v1_0_to_InternalTest method testNoBodyWithUnknownMessageAnnotation.

public void testNoBodyWithUnknownMessageAnnotation() throws Exception {
    Message_1_0 sourceMessage = createTestMessage(new MessageAnnotations(Collections.singletonMap(Symbol.valueOf("x-opt-jms-msg-type"), (byte) 11)), null);
    final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
    assertEquals("Unexpected content", null, convertedMessage.getMessageBody());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace)

Example 90 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithAmqpType.

public void testAmqpValueWithAmqpType() throws Exception {
    final Date originalValue = new Date();
    final AmqpValue amqpValue = new AmqpValue(originalValue);
    Properties properties = new Properties();
    final String mimeType = "foo/bar";
    properties.setContentType(Symbol.valueOf(mimeType));
    Message_1_0 sourceMessage = createTestMessage(properties, amqpValue.createEncodingRetainingSection());
    final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", mimeType, convertedMessage.getMessageHeader().getMimeType());
    assertEquals("Unexpected content", originalValue, convertedMessage.getMessageBody());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) Date(java.util.Date) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Aggregations

InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)185 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)60 Matchers.anyString (org.mockito.Matchers.anyString)45 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)36 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)25 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)24 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)23 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)18 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)18 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)17 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)15 HashMap (java.util.HashMap)13 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)12 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)9 UUID (java.util.UUID)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)8 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)7 Map (java.util.Map)6 Exchange (org.apache.qpid.server.model.Exchange)6 ArrayList (java.util.ArrayList)5