INT-1147 Allow socket handling Task Executors to be injected, allowing use of specific executors like WorkManagerTaskExecutor.
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:ip="http://www.springframework.org/schema/integration/ip"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
|
||||
xmlns:task="http://www.springframework.org/schema/task"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<bean id="tcpIpUtils" class="org.springframework.integration.ip.util.SocketUtils" />
|
||||
|
||||
@@ -13,6 +15,8 @@
|
||||
<int:channel id="tcpChannel" />
|
||||
<int:channel id="replyChannel" />
|
||||
|
||||
<task:executor id="externalTE" pool-size="10"/>
|
||||
|
||||
<ip:inbound-channel-adapter id="testInUdp"
|
||||
channel="udpChannel"
|
||||
check-length="true"
|
||||
@@ -27,6 +31,7 @@
|
||||
so-send-buffer-size="31"
|
||||
so-timeout="32"
|
||||
local-address="127.0.0.1"
|
||||
task-executor="externalTE"
|
||||
/>
|
||||
|
||||
<ip:inbound-channel-adapter id="testInUdpMulticast"
|
||||
@@ -122,7 +127,8 @@
|
||||
so-receive-buffer-size="52"
|
||||
so-send-buffer-size="53"
|
||||
so-timeout="54"
|
||||
local-address="127.0.0.1"
|
||||
local-address="127.0.0.1"
|
||||
task-executor="externalTE"
|
||||
/>
|
||||
|
||||
<ip:outbound-channel-adapter id="testOutUdpiMulticast"
|
||||
@@ -221,6 +227,7 @@
|
||||
so-send-buffer-size="125"
|
||||
so-timeout="126"
|
||||
local-address="127.0.0.1"
|
||||
task-executor="externalTE"
|
||||
/>
|
||||
|
||||
<ip:outbound-gateway id="simpleOutGateway"
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
package org.springframework.integration.ip.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -24,6 +26,7 @@ import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.integration.ip.tcp.CustomNetSocketReader;
|
||||
import org.springframework.integration.ip.tcp.CustomNetSocketWriter;
|
||||
import org.springframework.integration.ip.tcp.CustomNioSocketReader;
|
||||
@@ -118,6 +121,10 @@ public class ParserUnitTests {
|
||||
@Qualifier(value="org.springframework.integration.ip.tcp.SimpleTcpNetOutboundGateway#1")
|
||||
SimpleTcpNetOutboundGateway simpleTcpNetOutboundGatewayClose;
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="externalTE")
|
||||
TaskExecutor taskExecutor;
|
||||
|
||||
@Test
|
||||
public void testInUdp() {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(udpIn);
|
||||
@@ -128,6 +135,7 @@ public class ParserUnitTests {
|
||||
assertEquals(31, dfa.getPropertyValue("soSendBufferSize"));
|
||||
assertEquals(32, dfa.getPropertyValue("soTimeout"));
|
||||
assertEquals("127.0.0.1", dfa.getPropertyValue("localAddress"));
|
||||
assertSame(taskExecutor, dfa.getPropertyValue("taskExecutor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -141,6 +149,7 @@ public class ParserUnitTests {
|
||||
assertEquals(31, dfa.getPropertyValue("soSendBufferSize"));
|
||||
assertEquals(32, dfa.getPropertyValue("soTimeout"));
|
||||
assertEquals("127.0.0.1", dfa.getPropertyValue("localAddress"));
|
||||
assertNotSame(taskExecutor, dfa.getPropertyValue("taskExecutor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,6 +229,7 @@ public class ParserUnitTests {
|
||||
assertEquals(53, dfa.getPropertyValue("soSendBufferSize"));
|
||||
assertEquals(54, dfa.getPropertyValue("soTimeout"));
|
||||
assertEquals("127.0.0.1", dfa.getPropertyValue("localAddress"));
|
||||
assertSame(taskExecutor, dfa.getPropertyValue("taskExecutor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -317,6 +327,8 @@ public class ParserUnitTests {
|
||||
assertEquals(23, dfa.getPropertyValue("poolSize"));
|
||||
assertEquals(false, dfa.getPropertyValue("close"));
|
||||
assertEquals("127.0.0.1", dfa.getPropertyValue("localAddress"));
|
||||
assertSame(taskExecutor, dfa.getPropertyValue("taskExecutor"));
|
||||
assertSame(taskExecutor, delegateDfa.getPropertyValue("taskExecutor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -95,6 +95,7 @@ public class DatagramPacketSendingHandlerTests {
|
||||
UnicastSendingMessageHandler handler =
|
||||
new UnicastSendingMessageHandler("localhost", testPort, true,
|
||||
true, "localhost", ackPort, 5000);
|
||||
handler.afterPropertiesSet();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
@@ -64,6 +64,7 @@ public class UdpChannelAdapterTests {
|
||||
// whichNic,
|
||||
SocketUtils.findAvailableUdpSocket(), 5000);
|
||||
// handler.setLocalAddress(whichNic);
|
||||
handler.afterPropertiesSet();
|
||||
Message<byte[]> message = MessageBuilder.withPayload("ABCD".getBytes()).build();
|
||||
handler.handleMessage(message);
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(2000);
|
||||
|
||||
Reference in New Issue
Block a user