Java Code Examples for javax.jms.Message.getPropertyNames()

The following are Jave code examples for showing how to use getPropertyNames() of the javax.jms.Message class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: java-jms   File: JmsTextMapExtractAdapter.java   Source Code and License Vote up 8 votes
public JmsTextMapExtractAdapter(Message message) {
  try {
    Enumeration enumeration = message.getPropertyNames();
    if (enumeration != null) {
      while (enumeration.hasMoreElements()) {
        String key = (String) enumeration.nextElement();
        Object value = message.getObjectProperty(key);
        if (value instanceof String) {
          map.put(decodeDash(key), (String) value);
        }
      }
    }
  } catch (JMSException e) {
    throw new RuntimeException(e);
  }
}
 
Example 2
Project: oneops   File: JMSConsumer.java   Source Code and License Vote up 7 votes
private void addData(Message message, String text) throws JMSException {
    MessageData data = new MessageData();
    data.setPayload(text);
    Map<String, String> headers = new HashMap<>();
    Enumeration<String> names = message.getPropertyNames();
    while (names.hasMoreElements()) {
        String name = names.nextElement();
        String value = message.getStringProperty(name);
        headers.put(name, value);
    }
    data.setHeaders(headers);
    messages.add(data);
}
 
Example 3
Project: nifi-jms-jndi   File: JMSConsumer.java   Source Code and License Vote up 5 votes
/**
 *
 */
@SuppressWarnings("unchecked")
private Map<String, String> extractMessageProperties(Message message) {
    Map<String, String> properties = new HashMap<>();
    try {
        Enumeration<String> propertyNames = message.getPropertyNames();
        while (propertyNames.hasMoreElements()) {
            String propertyName = propertyNames.nextElement();
            properties.put(propertyName, String.valueOf(message.getObjectProperty(propertyName)));
        }
    } catch (JMSException e) {
        this.processLog.warn("Failed to extract message properties", e);
    }
    return properties;
}
 
Example 4
Project: solace-integration-guides   File: JMSConsumer.java   Source Code and License Vote up 5 votes
/**
 *
 */
@SuppressWarnings("unchecked")
private Map<String, String> extractMessageProperties(Message message) {
    Map<String, String> properties = new HashMap<>();
    try {
        Enumeration<String> propertyNames = message.getPropertyNames();
        while (propertyNames.hasMoreElements()) {
            String propertyName = propertyNames.nextElement();
            properties.put(propertyName, String.valueOf(message.getObjectProperty(propertyName)));
        }
    } catch (JMSException e) {
        this.processLog.warn("Failed to extract message properties", e);
    }
    return properties;
}
 
Example 5
Project: oneops   File: JMSConsumer.java   Source Code and License Vote up 5 votes
private void addData(Message message, String text) throws JMSException {
	MessageData data = new MessageData();
	data.setPayload(text);
	Map<String, String> headers = new HashMap<String, String>();
	Enumeration<String> names = message.getPropertyNames();
	while (names.hasMoreElements()) {
		String name = names.nextElement();
		String value = message.getStringProperty(name);
		headers.put(name, value);
	}
	data.setHeaders(headers);
	messages.add(data);
}
 
Example 6
Project: DWSurvey   File: NotifyMessageListener.java   Source Code and License Vote up 5 votes
/**
	 * MessageListener回调函数.
	 */
	@Override
	public void onMessage(Message message) {
		try {
			message.getPropertyNames();
			/*MapMessage mapMessage = (MapMessage) message;
			// 打印消息详情
			String subject=mapMessage.getObject("subject").toString();
			String to=mapMessage.getObject("to").toString();
			String date=mapMessage.getObject("date").toString();
			String username=mapMessage.getObject("username").toString();
			String content=mapMessage.getObject("content").toString();*/
			
			String subject= "柯远";
			String to="xx";
			String date="2013-03-20";
			String username="keyuan";
			String content="activmq测试邮件";
			//mapMessage.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, 15*1000);
			System.out.println("收到了消息");
			logger.info("subject:" + subject+";to:"+to+";date:"+date+";username:"+username+";content:"+content+";");
			Email email=new Email();
			email.setContent(content);
			email.setDate(date);
			email.setSubject(subject);
			email.setTo(to);
			email.setUsername(username);
			// 发送邮件
//			if (simpleMailService != null) {
//				simpleMailService.sendNotificationMail("柯远。。。");
//			}
		} catch (JMSException e) {
			logger.error(e.getMessage(), e);
		}
	}