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());
}
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());
}
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());
}
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);
}
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());
}
Aggregations