diff --git a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsOutboundGateway.java b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsOutboundGateway.java
index cd2c40d287..2ff2773a80 100644
--- a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsOutboundGateway.java
+++ b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsOutboundGateway.java
@@ -46,7 +46,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageConsumer im
private volatile Queue jmsQueue;
- private volatile MessageConverter messageConverter;
+ private volatile MessageConverter messageConverter = new HeaderMappingMessageConverter(new SimpleMessageConverter());
private final JmsTemplate jmsTemplate = new JmsTemplate();
@@ -63,10 +63,14 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageConsumer im
this.setOutputChannel(replyChannel);
}
+ public void setMessageConverter(MessageConverter messageConverter) {
+ Assert.notNull(messageConverter, "'messageConverter' must not be null");
+ this.messageConverter = messageConverter;
+ }
+
public void afterPropertiesSet() {
this.jmsTemplate.afterPropertiesSet();
Assert.notNull(this.jmsQueue, "jmsQueue must not be null");
- this.messageConverter = new HeaderMappingMessageConverter(new SimpleMessageConverter());
}
@Override
diff --git a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/config/JmsOutboundGatewayParser.java b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/config/JmsOutboundGatewayParser.java
index 54cfb9f30c..5706087e89 100644
--- a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/config/JmsOutboundGatewayParser.java
+++ b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/config/JmsOutboundGatewayParser.java
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.AbstractConsumerEndpointParser;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.integration.jms.JmsOutboundGateway;
+import org.springframework.util.StringUtils;
/**
* Parser for the <outbound-gateway> element of the integration 'jms' namespace.
@@ -42,6 +43,7 @@ public class JmsOutboundGatewayParser extends AbstractConsumerEndpointParser {
builder.addPropertyReference("connectionFactory", element.getAttribute("connection-factory"));
builder.addPropertyReference("jmsQueue", element.getAttribute("jms-queue"));
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel");
+ IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-converter");
return builder;
}
diff --git a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/config/spring-integration-jms-1.0.xsd b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/config/spring-integration-jms-1.0.xsd
index 442d837e7f..e08d8aaf28 100644
--- a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/config/spring-integration-jms-1.0.xsd
+++ b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/config/spring-integration-jms-1.0.xsd
@@ -76,6 +76,7 @@
+
diff --git a/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/StubMessageConverter.java b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/StubMessageConverter.java
new file mode 100644
index 0000000000..f193b73ce9
--- /dev/null
+++ b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/StubMessageConverter.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.integration.jms;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+
+import org.springframework.jms.support.converter.MessageConversionException;
+import org.springframework.jms.support.converter.MessageConverter;
+
+public class StubMessageConverter implements MessageConverter {
+
+ @Override
+ public Object fromMessage(Message message) throws JMSException, MessageConversionException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Message toMessage(Object object, Session session) throws JMSException, MessageConversionException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/StubQueue.java b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/StubQueue.java
new file mode 100644
index 0000000000..dd197a70a1
--- /dev/null
+++ b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/StubQueue.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.integration.jms;
+
+import javax.jms.JMSException;
+import javax.jms.Queue;
+
+public class StubQueue implements Queue{
+
+ @Override
+ public String getQueueName() throws JMSException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/config/JmsOutboundGatewayParserTests.java b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/config/JmsOutboundGatewayParserTests.java
new file mode 100644
index 0000000000..2627caa720
--- /dev/null
+++ b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/config/JmsOutboundGatewayParserTests.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.integration.jms.config;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.springframework.beans.DirectFieldAccessor;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.integration.channel.QueueChannel;
+import org.springframework.integration.endpoint.PollingConsumerEndpoint;
+import org.springframework.integration.jms.JmsOutboundGateway;
+import org.springframework.integration.jms.StubMessageConverter;
+import org.springframework.jms.support.converter.MessageConverter;
+
+public class JmsOutboundGatewayParserTests {
+
+ @Test
+ public void testDefault(){
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
+ "jmsOutboundGatewayWithConverter.xml", this.getClass());
+ QueueChannel channel = new QueueChannel(1);
+ PollingConsumerEndpoint endpoint = (PollingConsumerEndpoint) context.getBean("jmsGateway");
+
+ DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
+ JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("consumer");
+ accessor = new DirectFieldAccessor(gateway);
+ MessageConverter converter = (MessageConverter)accessor.getPropertyValue("messageConverter");
+ assertTrue("Wrong mesage converter", converter instanceof StubMessageConverter);
+
+ }
+
+}
diff --git a/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/config/jmsOutboundGatewayWithConverter.xml b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/config/jmsOutboundGatewayWithConverter.xml
new file mode 100644
index 0000000000..40c13d5505
--- /dev/null
+++ b/org.springframework.integration.jms/src/test/java/org/springframework/integration/jms/config/jmsOutboundGatewayWithConverter.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+