INT-704 added support for 'order' on 'outbound-channel-adapter' and 'outbound-gateway' in the JMS namespace
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jms;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
@@ -27,10 +28,12 @@ import org.springframework.jms.support.converter.MessageConverter;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsSendingMessageHandler extends AbstractJmsTemplateBasedAdapter implements MessageHandler {
|
||||
public class JmsSendingMessageHandler extends AbstractJmsTemplateBasedAdapter implements MessageHandler, Ordered {
|
||||
|
||||
private volatile boolean extractPayload = true;
|
||||
|
||||
private volatile int order = Ordered.LOWEST_PRECEDENCE;
|
||||
|
||||
|
||||
/**
|
||||
* Specify whether the payload should be extracted from each Spring
|
||||
@@ -44,6 +47,14 @@ public class JmsSendingMessageHandler extends AbstractJmsTemplateBasedAdapter im
|
||||
this.extractPayload = extractPayload;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
public final void handleMessage(final Message<?> message) {
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException("message must not be null");
|
||||
|
||||
@@ -314,6 +314,14 @@
|
||||
<xsd:attribute name="delivery-mode" type="xsd:string"/>
|
||||
<xsd:attribute name="time-to-live" type="xsd:string"/>
|
||||
<xsd:attribute name="priority" type="xsd:string"/>
|
||||
<xsd:attribute name="order" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specifies the order for invocation when this gateway is connected as a
|
||||
subscriber to a SubscribableChannel.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
@@ -367,6 +375,14 @@
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="order" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specifies the order for invocation when this adapter is connected as a
|
||||
subscriber to a SubscribableChannel.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 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.
|
||||
@@ -63,6 +63,17 @@ public class JmsOutboundChannelAdapterParserTests {
|
||||
assertNotNull(accessor.getPropertyValue("jmsTemplate"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithOrder() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsOutboundWithOrder.xml", this.getClass());
|
||||
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("adapter");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
|
||||
Object order = accessor.getPropertyValue("order");
|
||||
assertEquals(123, order);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithHeaderMapper() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 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.
|
||||
@@ -15,11 +15,13 @@
|
||||
*/
|
||||
package org.springframework.integration.jms.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.endpoint.PollingConsumer;
|
||||
import org.springframework.integration.jms.JmsOutboundGateway;
|
||||
import org.springframework.integration.jms.StubMessageConverter;
|
||||
@@ -42,4 +44,15 @@ public class JmsOutboundGatewayParserTests {
|
||||
assertTrue("Wrong message converter", converter instanceof StubMessageConverter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gatewayWithOrder() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsOutboundGatewayWithOrder.xml", this.getClass());
|
||||
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGateway");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
|
||||
Object order = accessor.getPropertyValue("order");
|
||||
assertEquals(99, order);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:si="http://www.springframework.org/schema/integration"
|
||||
xmlns:jms="http://www.springframework.org/schema/integration/jms"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
http://www.springframework.org/schema/integration/jms
|
||||
http://www.springframework.org/schema/integration/jms/spring-integration-jms-1.0.xsd">
|
||||
|
||||
<si:channel id="requestChannel"/>
|
||||
|
||||
<jms:outbound-gateway id="jmsGateway"
|
||||
request-destination="requestQueue"
|
||||
request-channel="requestChannel"
|
||||
order="99"/>
|
||||
|
||||
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.integration.jms.StubConnection">
|
||||
<constructor-arg value="test-message"/>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="requestQueue" class="org.springframework.integration.jms.StubQueue"/>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:jms="http://www.springframework.org/schema/integration/jms"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
http://www.springframework.org/schema/integration/jms
|
||||
http://www.springframework.org/schema/integration/jms/spring-integration-jms-1.0.xsd">
|
||||
|
||||
<integration:channel id="input"/>
|
||||
|
||||
<jms:outbound-channel-adapter id="adapter"
|
||||
channel="input" destination="testDestination" order="123"/>
|
||||
|
||||
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.integration.jms.StubConnection">
|
||||
<constructor-arg value="target-test"/>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="testDestination" class="org.springframework.integration.jms.StubDestination"/>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user