Example usage for javax.jms MapMessage setObject

List of usage examples for javax.jms MapMessage setObject

Introduction

In this page you can find the example usage for javax.jms MapMessage setObject.

Prototype


void setObject(String name, Object value) throws JMSException;

Source Link

Document

Sets an object value with the specified name into the Map.

Usage

From source file:org.wso2.carbon.integration.test.client.JMSPublisherClient.java

/**
 * Each message will be divided into groups and create the map message
 *
 * @param producer      Used for sending messages to a destination
 * @param session       Used to produce the messages to be sent
 * @param messagesList  List of messages to be send. An individual message event data should be in
 *                      "attributeName(attributeType):attributeValue" format
 *
 */// w  ww  .  j  av a  2s. c  om
public static void publishMapMessages(MessageProducer producer, Session session, List<String> messagesList)
        throws JMSException {
    String regexPattern = "(.*)\\((.*)\\):(.*)";
    Pattern pattern = Pattern.compile(regexPattern);
    for (String message : messagesList) {
        MapMessage jmsMapMessage = session.createMapMessage();
        for (String line : message.split("\\n")) {
            if (line != null && !line.equalsIgnoreCase("")) {
                Matcher matcher = pattern.matcher(line);
                if (matcher.find()) {
                    jmsMapMessage.setObject(matcher.group(1),
                            parseAttributeValue(matcher.group(2), matcher.group(3)));
                }
            }
        }
        producer.send(jmsMapMessage);
    }
}

From source file:org.wso2.carbon.sample.jmsclient.JMSClient.java

public static void publishMapMessage(MessageProducer producer, Session session,
        List<Map<String, Object>> messagesList) throws IOException, JMSException {
    for (Map<String, Object> message : messagesList) {
        MapMessage mapMessage = session.createMapMessage();
        message.put("time", System.currentTimeMillis());
        for (Map.Entry<String, Object> entry : message.entrySet()) {
            mapMessage.setObject(entry.getKey(), entry.getValue());
        }//w w w  .  j  a  va 2  s.  com
        producer.send(mapMessage);
    }
    log.info("messages sent (per-thread):" + messagesList.size());
}

From source file:org.wso2.carbon.sample.jmsclient.JMSClientUtil.java

/**
 * Each message will be divided into groups and create the map message
 *
 * @param producer     Used for sending messages to a destination
 * @param session      Used to produce the messages to be sent
 * @param messagesList List of messages to be sent
 *                     individual message event data should be in
 *                     "attributeName(attributeType):attributeValue" format
 *///from   w w w. j  av a2  s  . co m
public static void publishMapMessage(MessageProducer producer, Session session, List<String> messagesList)
        throws IOException, JMSException {
    String regexPattern = "(.*)\\((.*)\\):(.*)";
    Pattern pattern = Pattern.compile(regexPattern);
    for (String message : messagesList) {
        MapMessage mapMessage = session.createMapMessage();
        for (String line : message.split("\\n")) {
            if (line != null && !line.equalsIgnoreCase("")) {
                Matcher matcher = pattern.matcher(line);
                if (matcher.find()) {
                    mapMessage.setObject(matcher.group(1),
                            parseAttributeValue(matcher.group(2), matcher.group(3)));
                }
            }
        }
        producer.send(mapMessage);
    }
}