0

I create an integration message with concurrenthashmap payload as following

return MessageBuilder.createMessage(emvMessage.getResponse(), headers);

where emvMessage.getResponse() method returns

public ConcurrentHashMap<String, Object> getResponse() {
 ...
}

so far so good. But when i try to receive message from api the object is becoming a HashMap

Object response = jmsTemplate.receiveAndConvert(REQUEST_QUEUE_NAME);

This is because SimpleMessageConverter class converts all MapMessages to HashMap in the following method.

 protected Map<String, Object> extractMapFromMessage(MapMessage message) 
throws JMSException {
    Map<String, Object> map = new HashMap();
    Enumeration en = message.getMapNames();

    while(en.hasMoreElements()) {
        String key = (String)en.nextElement();
        map.put(key, message.getObject(key));
    }

    return map;
}

Can a new feature be added or this situation can be considered as a bug? Or should i convert this hashmap to concurrenthashmap manually?

1 Answers1

0

Just subclass the simple converter and override extractMapFromMessage().

Gary Russell
  • 166,535
  • 14
  • 146
  • 179