Search in sources :

Example 6 with MessageContainer

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

the class AbstractConsumerTargetTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    when(_connection.getContextValue(eq(Long.class), eq(Consumer.SUSPEND_NOTIFICATION_PERIOD))).thenReturn(1000000L);
    _consumer = mock(Consumer.class);
    _messageSource = mock(MessageSource.class);
    when(_messageSource.getMessageConversionExceptionHandlingPolicy()).thenReturn(MessageSource.MessageConversionExceptionHandlingPolicy.CLOSE);
    _messageInstance = mock(MessageInstance.class);
    when(_messageInstance.getOwningResource()).thenReturn(_messageSource);
    final MessageContainer messageContainer = new MessageContainer(_messageInstance, mock(MessageReference.class));
    when(_consumer.pullMessage()).thenReturn(messageContainer);
    _consumerTarget = new TestAbstractConsumerTarget();
    _consumerTarget.consumerAdded(_consumer);
}
Also used : MessageInstance(org.apache.qpid.server.message.MessageInstance) Consumer(org.apache.qpid.server.model.Consumer) MessageInstanceConsumer(org.apache.qpid.server.message.MessageInstanceConsumer) MessageContainer(org.apache.qpid.server.message.MessageContainer) MessageSource(org.apache.qpid.server.message.MessageSource) MessageReference(org.apache.qpid.server.message.MessageReference)

Example 7 with MessageContainer

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

the class TestConsumerTarget method processPending.

@Override
public boolean processPending() {
    MessageContainer messageContainer = _consumer.pullMessage();
    if (messageContainer == null) {
        return false;
    }
    send(_consumer, messageContainer.getMessageInstance(), false);
    return true;
}
Also used : MessageContainer(org.apache.qpid.server.message.MessageContainer)

Example 8 with MessageContainer

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

the class VirtualHostPropertiesNodeTest method testAddConsumer.

public void testAddConsumer() throws Exception {
    final EnumSet<ConsumerOption> options = EnumSet.noneOf(ConsumerOption.class);
    final ConsumerTarget target = mock(ConsumerTarget.class);
    when(target.allocateCredit(any(ServerMessage.class))).thenReturn(true);
    MessageInstanceConsumer consumer = _virtualHostPropertiesNode.addConsumer(target, null, ServerMessage.class, getTestName(), options, 0);
    final MessageContainer messageContainer = consumer.pullMessage();
    assertNotNull("Could not pull message from VirtualHostPropertyNode", messageContainer);
    if (messageContainer.getMessageReference() != null) {
        messageContainer.getMessageReference().release();
    }
}
Also used : MessageContainer(org.apache.qpid.server.message.MessageContainer) ConsumerOption(org.apache.qpid.server.consumer.ConsumerOption) ConsumerTarget(org.apache.qpid.server.consumer.ConsumerTarget) ServerMessage(org.apache.qpid.server.message.ServerMessage) MessageInstanceConsumer(org.apache.qpid.server.message.MessageInstanceConsumer)

Aggregations

MessageContainer (org.apache.qpid.server.message.MessageContainer)8 MessageInstanceConsumer (org.apache.qpid.server.message.MessageInstanceConsumer)4 ConsumerOption (org.apache.qpid.server.consumer.ConsumerOption)2 ConsumerTarget (org.apache.qpid.server.consumer.ConsumerTarget)2 MessageInstance (org.apache.qpid.server.message.MessageInstance)2 MessageReference (org.apache.qpid.server.message.MessageReference)2 MessageSource (org.apache.qpid.server.message.MessageSource)2 ServerMessage (org.apache.qpid.server.message.ServerMessage)2 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)2 Consumer (org.apache.qpid.server.model.Consumer)1 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)1 TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)1 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)1