Package org.apache.qpid.server.queue

Examples of org.apache.qpid.server.queue.AMQMessageHandle


        }
    }

    private static AMQMessageHandle createMessageHandle(final long messageId, final MessagePublishInfo publishBody)
    {
        final AMQMessageHandle amqMessageHandle = (new MessageHandleFactory()).createMessageHandle(messageId,
                                                                                                   null,
                                                                                                   false);
        try
        {
            amqMessageHandle.setPublishAndContentHeaderBody(new StoreContext(),
                                                              publishBody,
                                                              new ContentHeaderBody()
            {
                public int getSize()
                {
View Full Code Here


    {
        ByteBuffer deliver = createEncodedDeliverFrame(message, channelId, deliveryTag, consumerTag);
        AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
                                                                      message.getContentHeaderBody());

        final AMQMessageHandle messageHandle = message.getMessageHandle();
        final StoreContext storeContext = message.getStoreContext();
        final Long messageId = message.getMessageId();

        final int bodyCount = messageHandle.getBodyCount(storeContext,messageId);

        if(bodyCount == 0)
        {
            SmallCompositeAMQDataBlock compositeBlock = new SmallCompositeAMQDataBlock(deliver,
                                                                             contentHeader);

            writeFrame(compositeBlock);
        }
        else
        {


            //
            // Optimise the case where we have a single content body. In that case we create a composite block
            // so that we can writeDeliver out the deliver, header and body with a single network writeDeliver.
            //
            ContentChunk cb = messageHandle.getContentChunk(storeContext,messageId, 0);

            AMQDataBlock firstContentBody = new AMQFrame(channelId, getProtocolSession().getRegistry().getProtocolVersionMethodConverter().convertToBody(cb));
            AMQDataBlock[] headerAndFirstContent = new AMQDataBlock[]{contentHeader, firstContentBody};
            CompositeAMQDataBlock compositeBlock = new CompositeAMQDataBlock(deliver, headerAndFirstContent);
            writeFrame(compositeBlock);

            //
            // Now start writing out the other content bodies
            //
            for(int i = 1; i < bodyCount; i++)
            {
                cb = messageHandle.getContentChunk(storeContext,messageId, i);
                writeFrame(new AMQFrame(channelId, getProtocolSession().getRegistry().getProtocolVersionMethodConverter().convertToBody(cb)));
            }


        }
View Full Code Here


    public void writeGetOk(AMQMessage message, int channelId, long deliveryTag, int queueSize) throws AMQException
    {

        final AMQMessageHandle messageHandle = message.getMessageHandle();
        final StoreContext storeContext = message.getStoreContext();
        final long messageId = message.getMessageId();

        ByteBuffer deliver = createEncodedGetOkFrame(message, channelId, deliveryTag, queueSize);


        AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
                                                                      message.getContentHeaderBody());

        final int bodyCount = messageHandle.getBodyCount(storeContext,messageId);
        if(bodyCount == 0)
        {
            SmallCompositeAMQDataBlock compositeBlock = new SmallCompositeAMQDataBlock(deliver,
                                                                             contentHeader);
            writeFrame(compositeBlock);
        }
        else
        {


            //
            // Optimise the case where we have a single content body. In that case we create a composite block
            // so that we can writeDeliver out the deliver, header and body with a single network writeDeliver.
            //
            ContentChunk cb = messageHandle.getContentChunk(storeContext,messageId, 0);

            AMQDataBlock firstContentBody = new AMQFrame(channelId, getProtocolSession().getRegistry().getProtocolVersionMethodConverter().convertToBody(cb));
            AMQDataBlock[] headerAndFirstContent = new AMQDataBlock[]{contentHeader, firstContentBody};
            CompositeAMQDataBlock compositeBlock = new CompositeAMQDataBlock(deliver, headerAndFirstContent);
            writeFrame(compositeBlock);

            //
            // Now start writing out the other content bodies
            //
            for(int i = 1; i < bodyCount; i++)
            {
                cb = messageHandle.getContentChunk(storeContext, messageId, i);
                writeFrame(new AMQFrame(channelId, getProtocolSession().getRegistry().getProtocolVersionMethodConverter().convertToBody(cb)));
            }


        }
View Full Code Here

    private ByteBuffer createEncodedDeliverFrame(AMQMessage message, int channelId, long deliveryTag, AMQShortString consumerTag)
            throws AMQException
    {
        final MessagePublishInfo pb = message.getMessagePublishInfo();
        final AMQMessageHandle messageHandle = message.getMessageHandle();

        AMQFrame deliverFrame = BasicDeliverBody.createAMQFrame(channelId, getProtocolMajorVersion(),
                                                                getProtocolMinorVersion(),
                                                                consumerTag,
                                                                deliveryTag, pb.getExchange(), messageHandle.isRedelivered(),
                                                                pb.getRoutingKey());


        return deliverFrame.toByteBuffer();
    }
View Full Code Here

    private ByteBuffer createEncodedGetOkFrame(AMQMessage message, int channelId, long deliveryTag, int queueSize)
            throws AMQException
    {
        final MessagePublishInfo pb = message.getMessagePublishInfo();
        final AMQMessageHandle messageHandle = message.getMessageHandle();

        AMQFrame getOkFrame = BasicGetOkBody.createAMQFrame(channelId,
                                                            getProtocolMajorVersion(),
                                                            getProtocolMinorVersion(),
                                                                deliveryTag, pb.getExchange(),
                                                                queueSize,
                                                                messageHandle.isRedelivered(),
                                                                pb.getRoutingKey());

        return getOkFrame.toByteBuffer();
    }
View Full Code Here

            }
        };


        final long messageId = _store.getNewMessageId();
        AMQMessageHandle messageHandle = (new MessageHandleFactory()).createMessageHandle(messageId, _store, true);
        messageHandle.setPublishAndContentHeaderBody(_storeContext,info, chb);
        AMQMessage message = new AMQMessage(messageHandle,
                                             _storeContext,info);

        message = message.takeReference();
View Full Code Here

            }
        };

        final Long messageId = _store.getNewMessageId();
        final ContentHeaderBody chb = createPersistentContentHeader();
        AMQMessageHandle messageHandle = (new MessageHandleFactory()).createMessageHandle(messageId, _store, true);
        messageHandle.setPublishAndContentHeaderBody(_storeContext,info,chb);
        AMQMessage message = new AMQMessage(messageHandle,
                                             _storeContext,
                                            info);
       
       
View Full Code Here

        }
    }

    private static AMQMessageHandle createMessageHandle(final long messageId, final MessagePublishInfo publishBody)
    {
        final AMQMessageHandle amqMessageHandle = (new MessageHandleFactory()).createMessageHandle(messageId,
                                                                                                   null,
                                                                                                   false);
        try
        {
            amqMessageHandle.setPublishAndContentHeaderBody(new StoreContext(),
                                                              publishBody,
                                                              new ContentHeaderBody()
            {
                public int getSize()
                {
View Full Code Here

    {
        AMQBody deliverBody = createEncodedDeliverFrame(message, channelId, deliveryTag, consumerTag);
        final ContentHeaderBody contentHeaderBody = message.getContentHeaderBody();


        final AMQMessageHandle messageHandle = message.getMessageHandle();
        final StoreContext storeContext = message.getStoreContext();


        final int bodyCount = messageHandle.getBodyCount(storeContext);

        if(bodyCount == 0)
        {
            SmallCompositeAMQBodyBlock compositeBlock = new SmallCompositeAMQBodyBlock(channelId, deliverBody,
                                                                             contentHeaderBody);

            writeFrame(compositeBlock);
        }
        else
        {


            //
            // Optimise the case where we have a single content body. In that case we create a composite block
            // so that we can writeDeliver out the deliver, header and body with a single network writeDeliver.
            //
            ContentChunk cb = messageHandle.getContentChunk(storeContext, 0);

            AMQBody firstContentBody = PROTOCOL_METHOD_CONVERTER.convertToBody(cb);

            CompositeAMQBodyBlock compositeBlock = new CompositeAMQBodyBlock(channelId, deliverBody, contentHeaderBody, firstContentBody);
            writeFrame(compositeBlock);

            //
            // Now start writing out the other content bodies
            //
            for(int i = 1; i < bodyCount; i++)
            {
                cb = messageHandle.getContentChunk(storeContext, i);
                writeFrame(new AMQFrame(channelId, PROTOCOL_METHOD_CONVERTER.convertToBody(cb)));
            }


        }
View Full Code Here


    public void writeGetOk(AMQMessage message, int channelId, long deliveryTag, int queueSize) throws AMQException
    {

        final AMQMessageHandle messageHandle = message.getMessageHandle();
        final StoreContext storeContext = message.getStoreContext();

        AMQFrame deliver = createEncodedGetOkFrame(message, channelId, deliveryTag, queueSize);


        AMQDataBlock contentHeader = createContentHeaderBlock(channelId, message.getContentHeaderBody());

        final int bodyCount = messageHandle.getBodyCount(storeContext);
        if(bodyCount == 0)
        {
            SmallCompositeAMQDataBlock compositeBlock = new SmallCompositeAMQDataBlock(deliver,
                                                                             contentHeader);
            writeFrame(compositeBlock);
        }
        else
        {


            //
            // Optimise the case where we have a single content body. In that case we create a composite block
            // so that we can writeDeliver out the deliver, header and body with a single network writeDeliver.
            //
            ContentChunk cb = messageHandle.getContentChunk(storeContext, 0);

            AMQDataBlock firstContentBody = new AMQFrame(channelId, PROTOCOL_METHOD_CONVERTER.convertToBody(cb));
            AMQDataBlock[] blocks = new AMQDataBlock[]{deliver, contentHeader, firstContentBody};
            CompositeAMQDataBlock compositeBlock = new CompositeAMQDataBlock(blocks);
            writeFrame(compositeBlock);

            //
            // Now start writing out the other content bodies
            //
            for(int i = 1; i < bodyCount; i++)
            {
                cb = messageHandle.getContentChunk(storeContext, i);
                writeFrame(new AMQFrame(channelId, PROTOCOL_METHOD_CONVERTER.convertToBody(cb)));
            }


        }
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.queue.AMQMessageHandle

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.