JMSMessageID is now copied to the Spring Integration Message's headers with a key whose value is defined in the constant: JmsHeaders.MESSAGE_ID (INT-543).
This commit is contained in:
@@ -91,6 +91,10 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
|
|||||||
public Map<String, Object> toHeaders(javax.jms.Message jmsMessage) {
|
public Map<String, Object> toHeaders(javax.jms.Message jmsMessage) {
|
||||||
Map<String, Object> headers = new HashMap<String, Object>();
|
Map<String, Object> headers = new HashMap<String, Object>();
|
||||||
try {
|
try {
|
||||||
|
String messageId = jmsMessage.getJMSMessageID();
|
||||||
|
if (messageId != null) {
|
||||||
|
headers.put(JmsHeaders.MESSAGE_ID, messageId);
|
||||||
|
}
|
||||||
String correlationId = jmsMessage.getJMSCorrelationID();
|
String correlationId = jmsMessage.getJMSCorrelationID();
|
||||||
if (correlationId != null) {
|
if (correlationId != null) {
|
||||||
headers.put(JmsHeaders.CORRELATION_ID, correlationId);
|
headers.put(JmsHeaders.CORRELATION_ID, correlationId);
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ public abstract class JmsHeaders {
|
|||||||
*/
|
*/
|
||||||
public static final String PREFIX = MessageHeaders.PREFIX + "jms_";
|
public static final String PREFIX = MessageHeaders.PREFIX + "jms_";
|
||||||
|
|
||||||
|
public static final String MESSAGE_ID = PREFIX + "messageId";
|
||||||
|
|
||||||
public static final String CORRELATION_ID = PREFIX + "correlationId";
|
public static final String CORRELATION_ID = PREFIX + "correlationId";
|
||||||
|
|
||||||
public static final String REPLY_TO = PREFIX + "replyTo";
|
public static final String REPLY_TO = PREFIX + "replyTo";
|
||||||
|
|||||||
@@ -143,6 +143,18 @@ public class DefaultJmsHeaderMapperTests {
|
|||||||
assertSame(replyTo, attrib);
|
assertSame(replyTo, attrib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJmsMessageIdMappedToHeader() throws JMSException {
|
||||||
|
String messageId = "ID:ABC-123";
|
||||||
|
javax.jms.Message jmsMessage = new StubTextMessage();
|
||||||
|
jmsMessage.setJMSMessageID(messageId);
|
||||||
|
DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
|
||||||
|
Map<String, Object> headers = mapper.toHeaders(jmsMessage);
|
||||||
|
Object attrib = headers.get(JmsHeaders.MESSAGE_ID);
|
||||||
|
assertNotNull(attrib);
|
||||||
|
assertSame(messageId, attrib);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJmsCorrelationIdMappedToHeader() throws JMSException {
|
public void testJmsCorrelationIdMappedToHeader() throws JMSException {
|
||||||
String correlationId = "ABC-123";
|
String correlationId = "ABC-123";
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ public class StubTextMessage implements TextMessage {
|
|||||||
|
|
||||||
private Destination replyTo;
|
private Destination replyTo;
|
||||||
|
|
||||||
private String correlationID;
|
private String messageId;
|
||||||
|
|
||||||
|
private String correlationId;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ public class StubTextMessage implements TextMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getJMSCorrelationID() throws JMSException {
|
public String getJMSCorrelationID() throws JMSException {
|
||||||
return this.correlationID;
|
return this.correlationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
|
public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
|
||||||
@@ -94,7 +96,7 @@ public class StubTextMessage implements TextMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getJMSMessageID() throws JMSException {
|
public String getJMSMessageID() throws JMSException {
|
||||||
return null;
|
return this.messageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getJMSPriority() throws JMSException {
|
public int getJMSPriority() throws JMSException {
|
||||||
@@ -125,7 +127,7 @@ public class StubTextMessage implements TextMessage {
|
|||||||
return this.properties.get(name);
|
return this.properties.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enumeration getPropertyNames() throws JMSException {
|
public Enumeration<?> getPropertyNames() throws JMSException {
|
||||||
return this.properties.keys();
|
return this.properties.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +163,8 @@ public class StubTextMessage implements TextMessage {
|
|||||||
this.properties.put(name, value);
|
this.properties.put(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJMSCorrelationID(String correlationID) throws JMSException {
|
public void setJMSCorrelationID(String correlationId) throws JMSException {
|
||||||
this.correlationID = correlationID;
|
this.correlationId = correlationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException {
|
public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException {
|
||||||
@@ -178,6 +180,7 @@ public class StubTextMessage implements TextMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setJMSMessageID(String id) throws JMSException {
|
public void setJMSMessageID(String id) throws JMSException {
|
||||||
|
this.messageId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJMSPriority(int priority) throws JMSException {
|
public void setJMSPriority(int priority) throws JMSException {
|
||||||
|
|||||||
Reference in New Issue
Block a user