Search in sources :

Example 1 with DecoderImpl

use of org.apache.qpid.proton.codec.DecoderImpl in project activemq-artemis by apache.

the class AMQPMessage method partialDecode.

private synchronized void partialDecode(ByteBuffer buffer) {
    DecoderImpl decoder = TLSEncode.getDecoder();
    decoder.setByteBuffer(buffer);
    buffer.position(0);
    _header = null;
    _deliveryAnnotations = null;
    _messageAnnotations = null;
    _properties = null;
    applicationProperties = null;
    Section section = null;
    try {
        if (buffer.hasRemaining()) {
            section = (Section) decoder.readObject();
        }
        if (section instanceof Header) {
            _header = (Header) section;
            headerEnds = buffer.position();
            messagePaylodStart = headerEnds;
            if (_header.getTtl() != null) {
                this.expiration = System.currentTimeMillis() + _header.getTtl().intValue();
            }
            if (buffer.hasRemaining()) {
                section = (Section) decoder.readObject();
            } else {
                section = null;
            }
        } else {
            // meaning there is no header
            headerEnds = 0;
        }
        if (section instanceof DeliveryAnnotations) {
            _deliveryAnnotations = (DeliveryAnnotations) section;
            // Advance the start beyond the delivery annotations so they are not written
            // out on send of the message.
            messagePaylodStart = buffer.position();
            if (buffer.hasRemaining()) {
                section = (Section) decoder.readObject();
            } else {
                section = null;
            }
        }
        if (section instanceof MessageAnnotations) {
            _messageAnnotations = (MessageAnnotations) section;
            if (buffer.hasRemaining()) {
                section = (Section) decoder.readObject();
            } else {
                section = null;
            }
        }
        if (section instanceof Properties) {
            _properties = (Properties) section;
            if (_properties.getAbsoluteExpiryTime() != null && _properties.getAbsoluteExpiryTime().getTime() > 0) {
                this.expiration = _properties.getAbsoluteExpiryTime().getTime();
            }
            // We don't read the next section on purpose, as we will parse ApplicationProperties
            // lazily
            section = null;
        }
        if (section instanceof ApplicationProperties) {
            applicationProperties = (ApplicationProperties) section;
        } else {
            if (buffer.hasRemaining()) {
                this.appLocation = buffer.position();
            } else {
                this.appLocation = -1;
            }
        }
    } finally {
        decoder.setByteBuffer(null);
    }
}
Also used : DecoderImpl(org.apache.qpid.proton.codec.DecoderImpl) Header(org.apache.qpid.proton.amqp.messaging.Header) MessageAnnotations(org.apache.qpid.proton.amqp.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations) ApplicationProperties(org.apache.qpid.proton.amqp.messaging.ApplicationProperties) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Properties(org.apache.qpid.proton.amqp.messaging.Properties) ApplicationProperties(org.apache.qpid.proton.amqp.messaging.ApplicationProperties) Section(org.apache.qpid.proton.amqp.messaging.Section)

Aggregations

TypedProperties (org.apache.activemq.artemis.utils.collections.TypedProperties)1 ApplicationProperties (org.apache.qpid.proton.amqp.messaging.ApplicationProperties)1 DeliveryAnnotations (org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations)1 Header (org.apache.qpid.proton.amqp.messaging.Header)1 MessageAnnotations (org.apache.qpid.proton.amqp.messaging.MessageAnnotations)1 Properties (org.apache.qpid.proton.amqp.messaging.Properties)1 Section (org.apache.qpid.proton.amqp.messaging.Section)1 DecoderImpl (org.apache.qpid.proton.codec.DecoderImpl)1