Package org.apache.qpid.server.message

Examples of org.apache.qpid.server.message.MessageReference


        AMQMessageHeader messageHeader = mock(AMQMessageHeader.class);
        when(messageHeader.getHeader(CONFLATION_KEY)).thenReturn(conflationKeyValue);
        when(mockMessage.getMessageHeader()).thenReturn(messageHeader);

        MessageReference messageReference = mock(MessageReference.class);
        when(mockMessage.newReference()).thenReturn(messageReference);
        when(messageReference.getMessage()).thenReturn(mockMessage);

        return mockMessage;
    }
View Full Code Here


        AMQMessageHeader hdr = mock(AMQMessageHeader.class);
        when(message.getMessageHeader()).thenReturn(hdr);
        when(hdr.getHeader(eq("KEY"))).thenReturn(keyValue);
        when(hdr.containsHeader(eq("KEY"))).thenReturn(true);
        when(hdr.getHeaderNames()).thenReturn(Collections.singleton("KEY"));
        MessageReference ref = mock(MessageReference.class);
        when(ref.getMessage()).thenReturn(message);
        when(message.newReference()).thenReturn(ref);
        when(message.getMessageNumber()).thenReturn(id);

        return message;
    }
View Full Code Here

        StoredMessage storedMessage = _store.addMessage(mmd);


        AMQMessage message = new AMQMessage(storedMessage);

        MessageReference ref = message.newReference();

        assertEquals(1, _store.getMessageCount());

        ref.release();

        assertEquals(0, _store.getMessageCount());
    }
View Full Code Here

        StoredMessage storedMessage = _store.addMessage(mmd);

        AMQMessage message = new AMQMessage(storedMessage);


        MessageReference ref = message.newReference();
        // we call routing complete to set up the handle
     //   message.routingComplete(_store, _storeContext, new MessageHandleFactory());

        assertEquals(1, _store.getMessageCount());
        MessageReference ref2 = message.newReference();
        ref.release();
        assertEquals(1, _store.getMessageCount());
    }
View Full Code Here

            ServerMessage message = entry.getMessage();
            if(message != null)
            {
                if(_messageNumber == message.getMessageNumber())
                {
                    MessageReference reference = message.newReference();

                    _mimeType = message.getMessageHeader().getMimeType();
                    _size = message.getSize();
                    _content = new byte[(int)_size];
                    _found = true;
                    message.getContent(ByteBuffer.wrap(_content),0);
                    reference.release();
                    return true;
                }

            }
            return false;
View Full Code Here

    protected ServerMessage createMessage(Long id) throws AMQException
    {
        ServerMessage message = mock(ServerMessage.class);
        when(message.getMessageNumber()).thenReturn(id);

        MessageReference ref = mock(MessageReference.class);
        when(ref.getMessage()).thenReturn(message);

        AMQMessageHeader hdr = mock(AMQMessageHeader.class);
        when(message.getMessageHeader()).thenReturn(hdr);

        when(message.newReference()).thenReturn(ref);
View Full Code Here

    {
        InboundMessage inboundMessage = mock(InboundMessage.class);
        when(inboundMessage.getRoutingKey()).thenReturn(routingKey);
        List<? extends BaseQueue> queues = _exchange.route(inboundMessage);
        ServerMessage message = mock(ServerMessage.class);
        MessageReference ref = mock(MessageReference.class);
        when(ref.getMessage()).thenReturn(message);
        when(message.newReference()).thenReturn(ref);
        when(message.getMessageNumber()).thenReturn(messageNumber);
        for(BaseQueue q : queues)
        {
            q.enqueue(message);
View Full Code Here

                final ServerMessage message = _recoveredMessages.get(messageId);
                _unusedMessages.remove(messageId);

                if(message != null)
                {
                    final MessageReference ref = message.newReference();


                    branch.enqueue(queue,message);

                    branch.addPostTransactionAcion(new ServerTransaction.Action()
                    {

                        public void postCommit()
                        {
                            try
                            {

                                queue.enqueue(message, true, null);
                                ref.release();
                            }
                            catch (AMQException e)
                            {
                                _logger.error("Unable to enqueue message " + message.getMessageNumber() + " into " +
                                              "queue " + queue.getName() + " (from XA transaction)", e);
                                throw new RuntimeException(e);
                            }
                        }

                        public void onRollback()
                        {
                            ref.release();
                        }
                    });
                }
                else
                {
View Full Code Here

    private ServerMessage createServerMessage(long number)
    {
        final ServerMessage message = mock(ServerMessage.class);
        when(message.getMessageNumber()).thenReturn(number);
        MessageReference ref = mock(MessageReference.class);
        AMQMessageHeader hdr = mock(AMQMessageHeader.class);
        when(ref.getMessage()).thenReturn(message);
        when(message.newReference()).thenReturn(ref);
        when(message.getMessageHeader()).thenReturn(hdr);
        return message;
    }
View Full Code Here

        _sqel = new SimpleQueueEntryList(_testQueue);
        for(int i = 1; i <= 100; i++)
        {
            final ServerMessage message = mock(ServerMessage.class);
            when(message.getMessageNumber()).thenReturn((long) i);
            MessageReference ref = mock(MessageReference.class);
            when(ref.getMessage()).thenReturn(message);
            when(message.newReference()).thenReturn(ref);

            final QueueEntry bleh = _sqel.add(message);
            assertNotNull("QE should not have been null", bleh);
        }
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.message.MessageReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.