예제 #1
0
 /**
  * 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
  */
 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);
   }
 }