Package org.apache.qpid.framing

Examples of org.apache.qpid.framing.BasicContentHeaderProperties


                }
            };
            AMQMessage msg = new AMQMessage(_messageStore.getNewMessageId(), publishBody, txnContext);
            if (persistent)
            {
                BasicContentHeaderProperties b = new BasicContentHeaderProperties();
                //This is DeliveryMode.PERSISTENT
                b.setDeliveryMode((byte) 2);
                ContentHeaderBody cb = new ContentHeaderBody();
                cb.properties = b;
                msg.setContentHeaderBody(cb);
            }
            else
View Full Code Here


    private static final int BASIC_CLASS_ID = 60;

    public static BasicContentHeaderProperties convertContentHeaderProperties(MessageTransferMessage messageTransferMessage,
                                                                              VirtualHost vhost)
    {
        BasicContentHeaderProperties props = new BasicContentHeaderProperties();

        Header header = messageTransferMessage.getHeader();
        DeliveryProperties deliveryProps = header.getDeliveryProperties();
        MessageProperties messageProps = header.getMessageProperties();

        if(deliveryProps != null)
        {
            if(deliveryProps.hasDeliveryMode())
            {
                props.setDeliveryMode((byte) (deliveryProps.getDeliveryMode() == MessageDeliveryMode.PERSISTENT
                                              ? BasicContentHeaderProperties.PERSISTENT
                                              : BasicContentHeaderProperties.NON_PERSISTENT));
            }
            if(deliveryProps.hasExpiration())
            {
                props.setExpiration(deliveryProps.getExpiration());
            }
            if(deliveryProps.hasPriority())
            {
                props.setPriority((byte) deliveryProps.getPriority().getValue());
            }
            if(deliveryProps.hasTimestamp())
            {
                props.setTimestamp(deliveryProps.getTimestamp());
            }
        }
        if(messageProps != null)
        {
            if(messageProps.hasAppId())
            {
                props.setAppId(new AMQShortString(messageProps.getAppId()));
            }
            if(messageProps.hasContentType())
            {
                props.setContentType(messageProps.getContentType());
            }
            if(messageProps.hasCorrelationId())
            {
                props.setCorrelationId(new AMQShortString(messageProps.getCorrelationId()));
            }
            if(messageProps.hasContentEncoding())
            {
                props.setEncoding(messageProps.getContentEncoding());
            }
            if(messageProps.hasMessageId())
            {
                props.setMessageId("ID:" + messageProps.getMessageId().toString());
            }
            if(messageProps.hasReplyTo())
            {
                ReplyTo replyTo = messageProps.getReplyTo();
                String exchangeName = replyTo.getExchange();
                String routingKey = replyTo.getRoutingKey();
                if(exchangeName == null)
                {
                    exchangeName = "";
                }

                Exchange exchange = vhost.getExchange(exchangeName);
                String exchangeClass = exchange == null
                                            ? ExchangeDefaults.DIRECT_EXCHANGE_CLASS.asString()
                                            : exchange.getType().getName().asString();
                props.setReplyTo(exchangeClass + "://" + exchangeName + "//?routingkey='" + (routingKey == null
                                                                                             ? ""
                                                                                             : routingKey + "'"));

            }
            if(messageProps.hasUserId())
            {
                props.setUserId(new AMQShortString(messageProps.getUserId()));
            }

            if(messageProps.hasApplicationHeaders())
            {
                Map<String, Object> appHeaders = new HashMap<String, Object>(messageProps.getApplicationHeaders());
                if(messageProps.getApplicationHeaders().containsKey("x-jms-type"))
                {
                    props.setType(String.valueOf(appHeaders.remove("x-jms-type")));
                }

                FieldTable ft = new FieldTable();
                for(Map.Entry<String, Object> entry : appHeaders.entrySet())
                {
                    try
                    {
                        ft.put(new AMQShortString(entry.getKey()), entry.getValue());
                    }
                    catch (AMQPInvalidClassException e)
                    {
                        // TODO
                        // log here, but ignore - just can;t convert
                    }
                }
                props.setHeaders(ft);

            }
        }

        return props;
View Full Code Here

                message.getArrivalTime());
    }

    private ContentHeaderBody convertContentHeaderBody(MessageTransferMessage message, VirtualHost vhost)
    {
        BasicContentHeaderProperties props = convertContentHeaderProperties(message, vhost);
        ContentHeaderBody chb = new ContentHeaderBody(props, BASIC_CLASS_ID);
        chb.setBodySize(message.getSize());
        return chb;
    }
View Full Code Here

    }

    private void sendMessageOnExchange(Exchange exchange, AMQShortString routingKey, boolean deliveryMode)
    {
        //Set MessagePersistence
        BasicContentHeaderProperties properties = new BasicContentHeaderProperties();
        properties.setDeliveryMode(deliveryMode ? Integer.valueOf(2).byteValue() : Integer.valueOf(1).byteValue());
        FieldTable headers = properties.getHeaders();
        headers.setString("Test", "MST");
        properties.setHeaders(headers);

        MessagePublishInfo messageInfo = new TestMessagePublishInfo(exchange, false, false, routingKey);

        final IncomingMessage currentMessage;
View Full Code Here

            // Set the body size
            ContentHeaderBody _headerBody = new ContentHeaderBody();
            _headerBody.setBodySize(0);

            // Set Minimum properties
            BasicContentHeaderProperties properties = new BasicContentHeaderProperties();

            properties.setExpiration(0L);
            properties.setTimestamp(System.currentTimeMillis());

            // Make Message Persistent
            properties.setDeliveryMode((byte) 2);

            _headerBody.setProperties(properties);

            channel.publishContentHeader(_headerBody);
        }
View Full Code Here

        channel.setLocalTransactional();

        MessagePublishInfo info = mock(MessagePublishInfo.class);
        ExchangeImpl e = mock(ExchangeImpl.class);
        ContentHeaderBody contentHeaderBody= mock(ContentHeaderBody.class);
        BasicContentHeaderProperties properties = mock(BasicContentHeaderProperties.class);

        when(contentHeaderBody.getProperties()).thenReturn(properties);
        when(info.getExchange()).thenReturn(new AMQShortString("test"));
        when(properties.getUserId()).thenReturn(new AMQShortString(_protocolSession.getAuthorizedPrincipal().getName() + "_incorrect"));

        channel.setPublishFrame(info, e);
        channel.publishContentHeader(contentHeaderBody);
        channel.commit();
View Full Code Here

        channel.setLocalTransactional();

        MessagePublishInfo info = mock(MessagePublishInfo.class);
        ExchangeImpl e = mock(ExchangeImpl.class);
        ContentHeaderBody contentHeaderBody= mock(ContentHeaderBody.class);
        BasicContentHeaderProperties properties = mock(BasicContentHeaderProperties.class);

        when(contentHeaderBody.getProperties()).thenReturn(properties);
        when(info.getExchange()).thenReturn(new AMQShortString("test"));
        when(properties.getUserId()).thenReturn(new AMQShortString(_protocolSession.getAuthorizedPrincipal().getName()));

        channel.setPublishFrame(info, e);
        channel.publishContentHeader(contentHeaderBody);
        channel.commit();
View Full Code Here

    }

    private ContentHeaderBody createPersistentContentHeader()
    {
        ContentHeaderBody chb = new ContentHeaderBody();
        BasicContentHeaderProperties bchp = new BasicContentHeaderProperties();
        bchp.setDeliveryMode((byte)2);
        chb.setProperties(bchp);
        return chb;
    }
View Full Code Here

        this(messageId, (String)null, null);
    }

    public MockStoredMessage(long messageId, String headerName, Object headerValue)
    {
        this(messageId, new MockMessagePublishInfo(), new ContentHeaderBody(new BasicContentHeaderProperties(), 60), headerName, headerValue);
    }
View Full Code Here

                public AMQShortString getRoutingKey()
                {
                    return new AMQShortString("rk");
                }
            };
            BasicContentHeaderProperties b = new BasicContentHeaderProperties();
            ContentHeaderBody cb = new ContentHeaderBody();
            cb.setProperties(b);

            if (persistent)
            {
                //This is DeliveryMode.PERSISTENT
                b.setDeliveryMode((byte) 2);
            }

            // we increment the reference here since we are not delivering the messaging to any queues, which is where
            // the reference is normally incremented. The test is easier to construct if we have direct access to the
            // subscription
View Full Code Here

TOP

Related Classes of org.apache.qpid.framing.BasicContentHeaderProperties

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.