public static Message decodeMessage()

in protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientMessageSupport.java [159:205]


    public static Message<?> decodeMessage(Decoder decoder, DecoderState decoderState,
                                           ProtonBuffer buffer, Consumer<DeliveryAnnotations> daConsumer) throws ClientException {

        final ClientMessage<?> message = new ClientMessage<>();

        Section<?> section = null;

        while (buffer.isReadable()) {
            try {
                section = (Section<?>) decoder.readObject(buffer, decoderState);
            } catch (Exception e) {
                throw ClientExceptionSupport.createNonFatalOrPassthrough(e);
            }

            switch (section.getType()) {
                case Header:
                    message.header((Header) section);
                    break;
                case DeliveryAnnotations:
                    if (daConsumer != null) {
                        daConsumer.accept((DeliveryAnnotations) section);
                    }
                    break;
                case MessageAnnotations:
                    message.annotations((MessageAnnotations) section);
                    break;
                case Properties:
                    message.properties((Properties) section);
                    break;
                case ApplicationProperties:
                    message.applicationProperties((ApplicationProperties) section);
                    break;
                case Data:
                case AmqpSequence:
                case AmqpValue:
                    message.addBodySection(section);
                    break;
                case Footer:
                    message.footer((Footer) section);
                    break;
                default:
                    throw new ClientException("Unknown Message Section forced decode abort.");
            }
        }

        return message;
    }