Example usage for javax.jms Message setStringProperty

List of usage examples for javax.jms Message setStringProperty

Introduction

In this page you can find the example usage for javax.jms Message setStringProperty.

Prototype


void setStringProperty(String name, String value) throws JMSException;

Source Link

Document

Sets a String property value with the specified name into the message.

Usage

From source file:org.carewebframework.jms.JMSUtil.java

/**
 * Given a Message, supplement the message with additional properties/attributes (JMSType,
 * recipients, sender).//from w w  w . ja  v a 2  s  .c o  m
 * 
 * @param message The message
 * @param jmsType JMSType
 * @param sender Sender client ID.
 * @param recipients Comma-delimited list of recipient client IDs
 * @return The decorated Message
 * @throws JMSException if error thrown setting properties
 */
public static Message decorateMessage(final Message message, final String jmsType, final String sender,
        final String recipients) throws JMSException {
    message.setJMSType(jmsType);
    message.setStringProperty(EVENT_SENDER_PROPERTY, sender);
    message.setStringProperty(EVENT_RECIPIENTS_PROPERTY,
            StringUtils.isEmpty(recipients) ? null : "," + recipients + ",");
    return message;
}

From source file:com.adaptris.core.jms.MessageTypeTranslatorCase.java

public static void addProperties(Message jmsMsg) throws JMSException {
    jmsMsg.setStringProperty(STRING_METADATA, STRING_VALUE);
    jmsMsg.setBooleanProperty(BOOLEAN_METADATA, Boolean.valueOf(BOOLEAN_VALUE).booleanValue());
    jmsMsg.setIntProperty(INTEGER_METADATA, Integer.valueOf(INTEGER_VALUE).intValue());
}

From source file:com.amalto.core.server.routing.DefaultRoutingEngine.java

private static void setRulesList(Message message, String[] rules) throws JMSException {
    message.setStringProperty(JMS_RULES_PROPERTY, StringUtils.join(rules, JMS_RULES_PROPERTY_SEPARATOR));
}

From source file:com.mirth.connect.connectors.jms.transformers.MessageObjectToJMSMessage.java

public Object doTransform(Object src) throws TransformerException {

    if (src instanceof MessageObject) {
        MessageObject messageObject = (MessageObject) src;
        if (messageObject.getStatus().equals(MessageObject.Status.FILTERED)) {
            return null;
        }//from w  w  w.j  av  a2  s  . c om
        String template = replacer.replaceValues(connector.getTemplate(), messageObject);
        Message message = transformToMessage(template);
        try {
            message.setStringProperty("MIRTH_MESSAGE_ID", messageObject.getId());
        } catch (JMSException e) {
            //Various Jms servers have slightly different rules to what can be set as an object property on the message
            //As such we have to take a hit n' hope approach
            if (logger.isDebugEnabled())
                logger.debug(
                        "Unable to set property '" + encodeHeader("MIRTH_MESSAGE_ID") + "': " + e.getMessage());
        }
        return message;
    }
    return null;
}

From source file:com.jim.im.broker.handler.PublishInterceptHandler.java

@Override
public void onPublish(InterceptPublishMessage msg) {
    BigInteger messageId = new BigInteger(msg.getPayload().array());
    final ImMessage imMessage = messageRepo.findOne(messageId);
    final ActiveMQTopic mqTopicName = new ActiveMQTopic(IMConstant.MQ_FORWARD_TOPIC_NAME);
    MessageConverter messageConverter = jmsTemplate.getMessageConverter();
    jmsTemplate.send(mqTopicName, new MessageCreator() {
        @Override//from w  ww .  j a  v  a 2  s  .c  o m
        public Message createMessage(Session session) throws JMSException {
            Message message = messageConverter.toMessage(imMessage, session);
            message.setStringProperty(IMConstant.BROKER_NAME, brokerName);
            return message;
        }
    });
}

From source file:com.example.BookListener.java

/**
 * Scenario for "should generate tests triggered by a message": client side: if sends
 * a message to input.messageFrom then message will be sent to output.messageFrom
 * server side: will send a message to input, verify the message contents and await
 * upon receiving message on the output messageFrom
 *//* ww w  .ja  v a 2 s  .c om*/
@JmsListener(destination = "input")
public void returnBook(String messageAsString) throws Exception {
    final BookReturned bookReturned = this.objectMapper.readerFor(BookReturned.class)
            .readValue(messageAsString);
    log.info("Returning book [$bookReturned]");
    MessageCreator messageCreator = new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            Message message = session.createObjectMessage(bookReturned);
            message.setStringProperty("BOOK-NAME", bookReturned.bookName);
            return message;
        }
    };
    this.jmsTemplate.send("output", messageCreator);
}

From source file:com.appdynamicspilot.jms.MessageProducer.java

public void sendTextMessageWithOrderId() {
    getJmsTemplate().send(new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            Message msg = session.createTextMessage("You Sent a order message");
            msg.setStringProperty("testString", "test123");

            /*MapMessage msg = session.createMapMessage();
            msg.setString(COMMAND, CMD_MAIL);
            msg.setString(EMAIL_ID, emailId);
            msg.setString(ORDER_ID, orderId);
            msg.setIntProperty("testproperty", 21);
            *///w w  w  . j  a v  a  2 s.  co  m
            return msg;
        }
    });
}

From source file:com.atlantbh.jmeter.plugins.jmstools.BinaryMessagepostProcessor.java

@Override
public Message postProcessMessage(Message message) throws JMSException {
    if (message != null) {
        for (String key : messageProperties.keySet()) {
            message.setStringProperty(key, messageProperties.get(key));
        }/*ww w.ja  v a  2  s .  c  o m*/
        return message;
    }
    return null;
}

From source file:fr.ortolang.diffusion.notification.NotificationServiceBean.java

@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void throwEvent(String fromObject, String throwedBy, String objectType, String eventType,
        Map<String, String> arguments) throws NotificationServiceException {
    try {//from   www .j av  a  2 s . com
        Message message = context.createMessage();
        message.setStringProperty(OrtolangEvent.DATE, OrtolangEvent.getEventDateFormatter().format(new Date()));
        message.setStringProperty(OrtolangEvent.THROWED_BY, throwedBy);
        message.setStringProperty(OrtolangEvent.FROM_OBJECT, fromObject);
        message.setStringProperty(OrtolangEvent.OBJECT_TYPE, objectType);
        message.setStringProperty(OrtolangEvent.TYPE, eventType);
        if (arguments != null && arguments instanceof Serializable) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(arguments);
            oos.close();
            message.setStringProperty(OrtolangEvent.ARGUMENTS, Base64.encodeBase64String(baos.toByteArray()));
        }
        context.createProducer().send(notificationTopic, message);

    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "unable to throw event", e);
        throw new NotificationServiceException("unable to throw event", e);
    }
}

From source file:nl.knaw.huygens.timbuctoo.messages.Action.java

public Message createMessage(Session session) throws JMSException {
    Message message = session.createMessage();

    message.setStringProperty(PROP_ACTION, actionType.getStringRepresentation());

    message.setStringProperty(PROP_ENTITY_TYPE, TypeNames.getInternalName(type));
    message.setBooleanProperty(PROP_FOR_MULTI_ENTITIES, forMultiEntities);
    if (!forMultiEntities) {
        message.setStringProperty(PROP_ENTITY_ID, id);
    }/*from w w w  .j  a  v a2 s . c  o m*/

    return message;
}