Search in sources :

Example 16 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class MessageFormat_1_0 method createMessageMetaData.

private MessageMetaData_1_0 createMessageMetaData(final List<EncodingRetainingSection<?>> allSections, final List<EncodingRetainingSection<?>> dataSections) {
    long contentSize = 0L;
    HeaderSection headerSection = null;
    PropertiesSection propertiesSection = null;
    DeliveryAnnotationsSection deliveryAnnotationsSection = null;
    MessageAnnotationsSection messageAnnotationsSection = null;
    ApplicationPropertiesSection applicationPropertiesSection = null;
    FooterSection footerSection = null;
    Iterator<EncodingRetainingSection<?>> iter = allSections.iterator();
    EncodingRetainingSection<?> s = iter.hasNext() ? iter.next() : null;
    if (s instanceof HeaderSection) {
        headerSection = (HeaderSection) s;
        s = iter.hasNext() ? iter.next() : null;
    }
    if (s instanceof DeliveryAnnotationsSection) {
        deliveryAnnotationsSection = (DeliveryAnnotationsSection) s;
        s = iter.hasNext() ? iter.next() : null;
    }
    if (s instanceof MessageAnnotationsSection) {
        messageAnnotationsSection = (MessageAnnotationsSection) s;
        s = iter.hasNext() ? iter.next() : null;
    }
    if (s instanceof PropertiesSection) {
        propertiesSection = (PropertiesSection) s;
        s = iter.hasNext() ? iter.next() : null;
    }
    if (s instanceof ApplicationPropertiesSection) {
        applicationPropertiesSection = (ApplicationPropertiesSection) s;
        s = iter.hasNext() ? iter.next() : null;
    }
    if (s instanceof AmqpValueSection) {
        contentSize = s.getEncodedSize();
        dataSections.add(s);
        s = iter.hasNext() ? iter.next() : null;
    } else if (s instanceof DataSection) {
        do {
            contentSize += s.getEncodedSize();
            dataSections.add(s);
            s = iter.hasNext() ? iter.next() : null;
        } while (s instanceof DataSection);
    } else if (s instanceof AmqpSequenceSection) {
        do {
            contentSize += s.getEncodedSize();
            dataSections.add(s);
            s = iter.hasNext() ? iter.next() : null;
        } while (s instanceof AmqpSequenceSection);
    }
    if (s instanceof FooterSection) {
        footerSection = (FooterSection) s;
        s = iter.hasNext() ? iter.next() : null;
    }
    if (s != null) {
        throw new ConnectionScopedRuntimeException(String.format("Encountered unexpected section '%s'", s.getClass().getSimpleName()));
    }
    return new MessageMetaData_1_0(headerSection, deliveryAnnotationsSection, messageAnnotationsSection, propertiesSection, applicationPropertiesSection, footerSection, System.currentTimeMillis(), contentSize);
}
Also used : PropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection) ApplicationPropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection) DeliveryAnnotationsSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection) EncodingRetainingSection(org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection) MessageAnnotationsSection(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotationsSection) ApplicationPropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection) AmqpSequenceSection(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequenceSection) HeaderSection(org.apache.qpid.server.protocol.v1_0.type.messaging.HeaderSection) FooterSection(org.apache.qpid.server.protocol.v1_0.type.messaging.FooterSection) DataSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) AmqpValueSection(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection)

Example 17 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class Message_1_0 method getContent.

@Override
public QpidByteBuffer getContent(final int offset, final int length) {
    if (getMessageMetaData().getVersion() == 0) {
        SectionDecoder sectionDecoder = new SectionDecoderImpl(DESCRIBED_TYPE_REGISTRY.getSectionDecoderRegistry());
        try {
            List<EncodingRetainingSection<?>> sections;
            // not just #getSize()
            try (QpidByteBuffer allSectionsContent = super.getContent(0, Integer.MAX_VALUE)) {
                sections = sectionDecoder.parseAll(allSectionsContent);
            }
            List<QpidByteBuffer> bodySectionContent = new ArrayList<>();
            for (final EncodingRetainingSection<?> section : sections) {
                if (section instanceof DataSection || section instanceof AmqpValueSection || section instanceof AmqpSequenceSection) {
                    bodySectionContent.add(section.getEncodedForm());
                }
                section.dispose();
            }
            try (QpidByteBuffer bodyContent = QpidByteBuffer.concatenate(bodySectionContent)) {
                bodySectionContent.forEach(QpidByteBuffer::dispose);
                return bodyContent.view(offset, length);
            }
        } catch (AmqpErrorException e) {
            throw new ConnectionScopedRuntimeException(e);
        }
    } else {
        return super.getContent(offset, length);
    }
}
Also used : EncodingRetainingSection(org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection) ArrayList(java.util.ArrayList) AmqpErrorException(org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException) AmqpSequenceSection(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequenceSection) DataSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) SectionDecoderImpl(org.apache.qpid.server.protocol.v1_0.messaging.SectionDecoderImpl) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) AmqpValueSection(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection) SectionDecoder(org.apache.qpid.server.protocol.v1_0.messaging.SectionDecoder)

Example 18 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class AMQPConnection_0_8Impl method closed.

@Override
public void closed() {
    try {
        try {
            if (!_orderlyClose.get()) {
                completeAndCloseAllChannels();
            }
        } finally {
            performDeleteTasks();
            final NamedAddressSpace virtualHost = getAddressSpace();
            if (virtualHost != null) {
                virtualHost.deregisterConnection(this);
            }
        }
    } catch (ConnectionScopedRuntimeException | TransportException e) {
        LOGGER.error("Could not close protocol engine", e);
    } finally {
        markTransportClosed();
    }
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) TransportException(org.apache.qpid.server.transport.TransportException)

Example 19 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class Session_1_0 method receiveAttach.

public void receiveAttach(final Attach attach) {
    receivedComplete();
    if (_sessionState == SessionState.ACTIVE) {
        UnsignedInteger inputHandle = attach.getHandle();
        if (_inputHandleToEndpoint.containsKey(inputHandle)) {
            String errorMessage = String.format("Input Handle '%d' already in use", inputHandle.intValue());
            getConnection().close(new Error(SessionError.HANDLE_IN_USE, errorMessage));
            throw new ConnectionScopedRuntimeException(errorMessage);
        } else {
            final Link_1_0<? extends BaseSource, ? extends BaseTarget> link;
            if (attach.getRole() == Role.RECEIVER) {
                link = getAddressSpace().getSendingLink(getConnection().getRemoteContainerId(), attach.getName());
            } else {
                link = getAddressSpace().getReceivingLink(getConnection().getRemoteContainerId(), attach.getName());
            }
            final ListenableFuture<? extends LinkEndpoint<?, ?>> future = link.attach(this, attach);
            addFutureCallback(future, new EndpointCreationCallback(attach), MoreExecutors.directExecutor());
        }
    }
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) SessionError(org.apache.qpid.server.protocol.v1_0.type.transport.SessionError) LinkError(org.apache.qpid.server.protocol.v1_0.type.transport.LinkError) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)

Example 20 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class Session_1_0 method updateDisposition.

void updateDisposition(final Role role, final Binary deliveryTag, final DeliveryState state, final boolean settled) {
    final DeliveryRegistry deliveryRegistry = role == Role.RECEIVER ? _incomingDeliveryRegistry : _outgoingDeliveryRegistry;
    UnsignedInteger deliveryId = deliveryRegistry.getDeliveryIdByTag(deliveryTag);
    if (deliveryId == null) {
        throw new ConnectionScopedRuntimeException(String.format("Delivery with tag '%s' is not found in unsettled deliveries", deliveryTag));
    }
    updateDisposition(role, deliveryId, deliveryId, state, settled);
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) DeliveryRegistry(org.apache.qpid.server.protocol.v1_0.delivery.DeliveryRegistry)

Aggregations

ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)32 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)9 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)7 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)6 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)5 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)4 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)4 AmqpValueSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection)4 EncodingRetainingSection (org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)3 AmqpSequenceSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequenceSection)3 DataSection (org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection)3 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)3 Futures.allAsList (com.google.common.util.concurrent.Futures.allAsList)2 ObjectOutputStream (java.io.ObjectOutputStream)2 BufferUnderflowException (java.nio.BufferUnderflowException)2