/** * Returns the correlation ID of the message. This is a convenience method for * getting the {@link Headers#CORRELATION_ID} value. * * @return the correlation ID of the message */ public String getCorrelationId() { return getHeaders().get(Headers.CORRELATION_ID); } /**
/** * Marshals the given properties as STOMP message headers. * * @param props * the properties to marshal * @param writer * the writer to write to * @throws IOException */ private void marshalHeaders(Headers headers, OutputStream outstream) throws IOException { for (String name : headers.getHeaderNames()) { write(outstream, name); outstream.write(':'); write(outstream, headers.get(name).replaceAll("\n", "\\n")); outstream.write('\n'); } }
@Override public Frame toFrame(HazelcastMQMessage msg) { FrameBuilder fb = FrameBuilder.command(Command.MESSAGE); fb.body(msg.getBody()); for (String name : msg.getHeaders().getHeaderNames()) { String value = msg.getHeaders().get(name); fb.header(name, value); } return fb.build(); } }
/** * Returns the reply to destination of the message. This is a convenience * method for getting the {@link Headers#REPLY_TO} value. * * @return the reply to destination */ public String getReplyTo() { return getHeaders().get(Headers.REPLY_TO); }
String headerValue = mqMsg.getHeaders().get(headerName);
/** * Returns the destination of the message. This is a convenience method for * getting the {@link Headers#DESTINATION} value. * * @return the destination */ public String getDestination() { return getHeaders().get(Headers.DESTINATION); }
/** * Returns the ID of the message. This is a convenience method for getting the * {@link Headers#MESSAGE_ID} value. * * @return the id of the message */ public String getId() { return getHeaders().get(Headers.MESSAGE_ID); }
/** * Returns the content type of the message. This is a convenience method for * getting the {@link Headers#CONTENT_TYPE} value. * * @return the content type of the message */ public String getContentType() { return getHeaders().get(Headers.CONTENT_TYPE); }
/** * Returns the body as a String using the character set encoding in the * content-type header or UTF-8 if no character set is specified in the * headers. If there is no body to the message, null is returned. This is just * a convenience method for {@link #getBody() }. * * @return the body as a string or null */ public String getBodyAsString() { Charset charset = UTF_8; String contentType = getHeaders().get(Headers.CONTENT_TYPE); if (contentType != null && contentType.contains(";")) { String[] parts = contentType.split(";"); for (String part : parts) { if (part.startsWith("charset=")) { charset = Charset.forName(part.substring("charset=".length())); } } } return getBodyAsString(charset); }