/** * Returns a string that encodes the given object as a JSON message but then * prefixes that JSON with additional information that a Hawkular client will * need to be able to deserialize the JSON. * * This string can be used to deserialize the object via {@link #deserialize(String)}. * * @param msg the message object that will be serialized into JSON * @return a string that includes the JSON that can be used by other Hawkular endpoints to deserialize the message. */ public static String toHawkularFormat(BasicMessage msg) { return String.format("%s=%s", msg.getClass().getSimpleName(), msg.toJSON()); }
if (basicMessage.getCorrelationId() != null) { msg.setJMSCorrelationID(basicMessage.getCorrelationId().toString()); if (basicMessage.getMessageId() != null) { log.debugf("Non-null message ID [%s] will be ignored and a new one generated", basicMessage.getMessageId()); basicMessage.setMessageId(null); basicMessage.setMessageId(messageId);
Map<String, String> basicMessageHeaders = basicMessage.getHeaders(); if (basicMessageHeaders != null) { for (Map.Entry<String, String> entry : basicMessageHeaders.entrySet()) {
retVal.getBasicMessage().setMessageId(new MessageId(message.getJMSMessageID())); if (message.getJMSCorrelationID() != null) { MessageId correlationId = new MessageId(message.getJMSCorrelationID()); retVal.getBasicMessage().setCorrelationId(correlationId); retVal.getBasicMessage().setHeaders(rawHeaders);
retVal.getBasicMessage().setMessageId(new MessageId(message.getJMSMessageID())); if (message.getJMSCorrelationID() != null) { MessageId correlationId = new MessageId(message.getJMSCorrelationID()); retVal.getBasicMessage().setCorrelationId(correlationId); retVal.getBasicMessage().setHeaders(rawHeaders);
if (basicMessage.getCorrelationId() != null) { msg.setJMSCorrelationID(basicMessage.getCorrelationId().toString()); if (basicMessage.getMessageId() != null) { log.debugf("Non-null message ID [%s] will be ignored and a new one generated", basicMessage.getMessageId()); basicMessage.setMessageId(null); basicMessage.setMessageId(messageId);
/** * Creates a text message that can be send via a producer that contains the given BasicMessage's JSON encoded data. * * @param context the context whose session is used to create the message * @param basicMessage contains the data that will be JSON-encoded and encapsulated in the created message, with * optional headers included * @param headers headers for the Message that will override same-named headers in the basic message * @return the message that can be produced * @throws JMSException any error * @throws NullPointerException if the context is null or the context's session is null */ protected Message createMessage(ConnectionContext context, BasicMessage basicMessage, Map<String, String> headers) throws JMSException { if (context == null) { throw new IllegalArgumentException("The context is null"); } if (basicMessage == null) { throw new IllegalArgumentException("The message is null"); } Session session = context.getSession(); if (session == null) { throw new IllegalArgumentException("The context had a null session"); } TextMessage msg = session.createTextMessage(basicMessage.toJSON()); setHeaders(basicMessage, headers, msg); log.debugf("Created text message [%s] with text [%s]", msg, msg.getText()); return msg; }
Map<String, String> basicMessageHeaders = basicMessage.getHeaders(); if (basicMessageHeaders != null) { for (Map.Entry<String, String> entry : basicMessageHeaders.entrySet()) {
if (basicMessage.getCorrelationId() != null) { msg.setJMSCorrelationID(basicMessage.getCorrelationId().toString()); if (basicMessage.getMessageId() != null) { log.debugf("Non-null message ID [%s] will be ignored and a new one generated", basicMessage.getMessageId()); basicMessage.setMessageId(null); basicMessage.setMessageId(messageId);
/** * Creates a text message that can be send via a producer that contains the given BasicMessage's JSON encoded data. * * @param context the context whose session is used to create the message * @param basicMessage contains the data that will be JSON-encoded and encapsulated in the created message, with * optional headers included * @param headers headers for the Message that will override same-named headers in the basic message * @return the message that can be produced * @throws JMSException any error * @throws NullPointerException if the context is null or the context's session is null */ protected Message createMessage(ConnectionContext context, BasicMessage basicMessage, Map<String, String> headers) throws JMSException { if (context == null) { throw new IllegalArgumentException("The context is null"); } if (basicMessage == null) { throw new IllegalArgumentException("The message is null"); } Session session = context.getSession(); if (session == null) { throw new IllegalArgumentException("The context had a null session"); } TextMessage msg = session.createTextMessage(basicMessage.toJSON()); setHeaders(basicMessage, headers, msg); log.infof("Created text message [%s] with text [%s]", msg, msg.getText()); return msg; }
if (basicMessage.getCorrelationId() != null) { msg.setJMSCorrelationID(basicMessage.getCorrelationId().toString()); if (basicMessage.getMessageId() != null) { log.debugf("Non-null message ID [%s] will be ignored and a new one generated", basicMessage.getMessageId()); basicMessage.setMessageId(null); basicMessage.setMessageId(messageId);
BinaryData messagePlusBinaryData = new BinaryData(basicMessage.toJSON().getBytes(), inputStream);
if (basicMessage.getCorrelationId() != null) { msg.setJMSCorrelationID(basicMessage.getCorrelationId().toString()); if (basicMessage.getMessageId() != null) { log.debugf("Non-null message ID [%s] will be ignored and a new one generated", basicMessage.getMessageId()); basicMessage.setMessageId(null); basicMessage.setMessageId(messageId);
BinaryData messagePlusBinaryData = new BinaryData(basicMessage.toJSON().getBytes(), inputStream);
if (basicMessage.getCorrelationId() != null) { msg.setJMSCorrelationID(basicMessage.getCorrelationId().toString()); if (basicMessage.getMessageId() != null) { log.debugf("Non-null message ID [%s] will be ignored and a new one generated", basicMessage.getMessageId()); basicMessage.setMessageId(null); basicMessage.setMessageId(messageId);