Search in sources :

Example 21 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_8Test method testToConversionWhenGlobalAddressIsKnown.

public void testToConversionWhenGlobalAddressIsKnown() {
    final String globalPrefix = "/testPrefix";
    final String queueName = "testQueue";
    final String globalAddress = globalPrefix + "/" + queueName;
    Properties properties = new Properties();
    properties.setTo(globalAddress);
    Message_1_0 message = createTestMessage(properties);
    Queue<?> queue = mock(Queue.class);
    when(queue.getName()).thenReturn(queueName);
    when(_namedAddressSpace.getAttainedMessageDestination(queueName)).thenReturn(queue);
    when(_namedAddressSpace.getLocalAddress(globalAddress)).thenReturn(queueName);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", queueName, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 22 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class ReferenceCountingTest method testMessageGetsRemoved.

/**
 * Check that when the reference count is decremented the message removes itself from the store
 */
public void testMessageGetsRemoved() throws QpidException {
    ContentHeaderBody chb = createPersistentContentHeader();
    MessagePublishInfo info = new MessagePublishInfo(null, false, false, null);
    final MessageMetaData mmd = new MessageMetaData(info, chb);
    StoredMessage storedMessage = _store.addMessage(mmd).allContentAdded();
    Transaction txn = _store.newTransaction();
    txn.enqueueMessage(createTransactionLogResource("dummyQ"), createEnqueueableMessage(storedMessage));
    txn.commitTran();
    AMQMessage message = new AMQMessage(storedMessage);
    MessageReference ref = message.newReference();
    assertEquals(1, getStoreMessageCount());
    ref.release();
    assertEquals(0, getStoreMessageCount());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) StoredMessage(org.apache.qpid.server.store.StoredMessage) Transaction(org.apache.qpid.server.store.Transaction) MessageReference(org.apache.qpid.server.message.MessageReference)

Example 23 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class ReferenceCountingTest method testMessageRemains.

public void testMessageRemains() throws QpidException {
    MessagePublishInfo info = new MessagePublishInfo(null, false, false, null);
    final ContentHeaderBody chb = createPersistentContentHeader();
    final MessageMetaData mmd = new MessageMetaData(info, chb);
    StoredMessage storedMessage = _store.addMessage(mmd).allContentAdded();
    Transaction txn = _store.newTransaction();
    txn.enqueueMessage(createTransactionLogResource("dummyQ"), createEnqueueableMessage(storedMessage));
    txn.commitTran();
    AMQMessage message = new AMQMessage(storedMessage);
    MessageReference ref = message.newReference();
    assertEquals(1, getStoreMessageCount());
    MessageReference ref2 = message.newReference();
    ref.release();
    assertEquals(1, getStoreMessageCount());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) StoredMessage(org.apache.qpid.server.store.StoredMessage) Transaction(org.apache.qpid.server.store.Transaction) MessageReference(org.apache.qpid.server.message.MessageReference)

Example 24 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class MessageConverter_0_10_to_0_8 method convertPublishBody.

private MessagePublishInfo convertPublishBody(MessageTransferMessage message) {
    DeliveryProperties delvProps = message.getHeader().getDeliveryProperties();
    final AMQShortString exchangeName = (delvProps == null || delvProps.getExchange() == null) ? null : new AMQShortString(delvProps.getExchange());
    final AMQShortString routingKey = (delvProps == null || delvProps.getRoutingKey() == null) ? null : new AMQShortString(delvProps.getRoutingKey());
    final boolean immediate = delvProps != null && delvProps.getImmediate();
    final boolean mandatory = delvProps != null && !delvProps.getDiscardUnroutable();
    return new MessagePublishInfo(exchangeName, immediate, mandatory, routingKey);
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 25 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_0_8Test method testRoutingKeyConversion.

public void testRoutingKeyConversion() {
    final String testRoutingKey = "testRoutingKey";
    final DeliveryProperties deliveryProperties = new DeliveryProperties();
    deliveryProperties.setRoutingKey(testRoutingKey);
    MessageTransferMessage message = createTestMessage(deliveryProperties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected routing key", testRoutingKey, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Aggregations

MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)40 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)16 Matchers.anyString (org.mockito.Matchers.anyString)15 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)14 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)13 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)11 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)9 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)9 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)8 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)7 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)7 Exchange (org.apache.qpid.server.model.Exchange)6 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)6 Queue (org.apache.qpid.server.model.Queue)4 MessageMetaData (org.apache.qpid.server.protocol.v0_8.MessageMetaData)4 LinkedHashMap (java.util.LinkedHashMap)3 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)3 Date (java.util.Date)2 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)2 MessageDestination (org.apache.qpid.server.message.MessageDestination)2