private void extractPayloadFromMessage(final JmsMessage message, final ExternalMessageBuilder builder) throws JMSException { if (message instanceof TextMessage) { final String payload = ((TextMessage) message).getText(); builder.withText(payload); } else if (message instanceof BytesMessage) { final BytesMessage bytesMessage = (BytesMessage) message; final long bodyLength = bytesMessage.getBodyLength(); if (bodyLength >= Integer.MIN_VALUE && bodyLength <= Integer.MAX_VALUE) { final int length = (int) bodyLength; final ByteBuffer byteBuffer = ByteBuffer.allocate(length); bytesMessage.readBytes(byteBuffer.array()); builder.withBytes(byteBuffer); } else { throw new IllegalArgumentException("Message too large..."); } } else { final Destination destination = message.getJMSDestination(); final Map<String, String> headersMapFromJmsMessage = extractHeadersMapFromJmsMessage(message); log.debug("Received message at '{}' of unsupported type ({}) with headers: {}", destination, message.getClass().getName(), headersMapFromJmsMessage); } }
private void extractPayloadFromMessage(final JmsMessage message, final ExternalMessageBuilder builder) throws JMSException { if (message instanceof TextMessage) { final String payload = ((TextMessage) message).getText(); builder.withText(payload); } else if (message instanceof BytesMessage) { final BytesMessage bytesMessage = (BytesMessage) message; final long bodyLength = bytesMessage.getBodyLength(); if (bodyLength >= Integer.MIN_VALUE && bodyLength <= Integer.MAX_VALUE) { final int length = (int) bodyLength; final ByteBuffer byteBuffer = ByteBuffer.allocate(length); bytesMessage.readBytes(byteBuffer.array()); builder.withBytes(byteBuffer); } else { throw new IllegalArgumentException("Message too large..."); } } else { final Destination destination = message.getJMSDestination(); final Map<String, String> headersMapFromJmsMessage = extractHeadersMapFromJmsMessage(message); log.debug("Received message at '{}' of unsupported type ({}) with headers: {}", destination, message.getClass().getName(), headersMapFromJmsMessage); } }
messageBuilder.withBytes(byteBuffer.get()); } else if (!(textPayload instanceof Undefined)) { messageBuilder.withText(((CharSequence) textPayload).toString());
messageBuilder.withBytes(byteBuffer.get()); } else if (!(textPayload instanceof Undefined)) { messageBuilder.withText(((CharSequence) textPayload).toString());
externalMessageBuilder.withText(text); } else { externalMessageBuilder.withBytes(body);
externalMessageBuilder.withText(text); } else { externalMessageBuilder.withBytes(body);
.withBytes(message.payload().toByteBuffer()) .withAuthorizationContext(sourceAuthorizationContext) .withEnforcement(getEnforcementFilter(message.topic()))
.withBytes(message.payload().toByteBuffer()) .withAuthorizationContext(sourceAuthorizationContext) .withEnforcement(getEnforcementFilter(message.topic()))