INT-4343: Add executor option to the RedisInChA
JIRA: https://jira.springsource.org/browse/INT-4343 * Add a `Executor` setter named `setTaskExecutor` in `RedisInboundChannelAdapter` to set the container's task executor. * Add a `task-executor` attribute to `<int-redis:inbound-channel-adapter>`. * Update RedisInboundChannelAdapterParser configuration validation tests. * Update redis.adoc and whats-new.adoc. * Polishing according PR comments * Improve `RedisQueueGatewayIntegrationTests` performance
This commit is contained in:
committed by
Artem Bilan
parent
b1865dab3a
commit
a65de25572
@@ -9,7 +9,14 @@
|
||||
<int-redis:inbound-channel-adapter
|
||||
id="adapter" topics="foo" topic-patterns="f*, b*" channel="receiveChannel" error-channel="testErrorChannel"
|
||||
message-converter="testConverter"
|
||||
serializer="serializer"/>
|
||||
serializer="serializer"
|
||||
task-executor="executor" />
|
||||
|
||||
<bean id="executor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
|
||||
<property name="corePoolSize" value="5" />
|
||||
<property name="maxPoolSize" value="10" />
|
||||
<property name="queueCapacity" value="25" />
|
||||
</bean>
|
||||
|
||||
<int:channel id="receiveChannel">
|
||||
<int:queue />
|
||||
|
||||
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -49,6 +51,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Gunnar Hillert
|
||||
* @author Venil Noronha
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -61,9 +64,13 @@ public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests {
|
||||
@Autowired
|
||||
private MessageChannel autoChannel;
|
||||
|
||||
@Autowired @Qualifier("autoChannel.adapter")
|
||||
@Autowired
|
||||
@Qualifier("autoChannel.adapter")
|
||||
private RedisInboundChannelAdapter autoChannelAdapter;
|
||||
|
||||
@Autowired
|
||||
private Executor executor;
|
||||
|
||||
@Test
|
||||
public void validateConfiguration() {
|
||||
RedisInboundChannelAdapter adapter = context.getBean("adapter", RedisInboundChannelAdapter.class);
|
||||
@@ -76,6 +83,10 @@ public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests {
|
||||
assertEquals(converterBean, accessor.getPropertyValue("messageConverter"));
|
||||
assertEquals(context.getBean("serializer"), accessor.getPropertyValue("serializer"));
|
||||
|
||||
Object container = accessor.getPropertyValue("container");
|
||||
DirectFieldAccessor containerAccessor = new DirectFieldAccessor(container);
|
||||
assertSame(this.executor, containerAccessor.getPropertyValue("taskExecutor"));
|
||||
|
||||
Object bean = context.getBean("withoutSerializer.adapter");
|
||||
assertNotNull(bean);
|
||||
assertNull(TestUtils.getPropertyValue(bean, "serializer"));
|
||||
@@ -109,6 +120,7 @@ public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class TestMessageConverter extends SimpleMessageConverter {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,16 +26,15 @@
|
||||
<int-redis:queue-outbound-gateway id="outboundGateway"
|
||||
request-channel="sendChannel"
|
||||
queue="#{redisQueue.toString()}"
|
||||
reply-timeout="10000"
|
||||
requires-reply="true"
|
||||
reply-timeout="500"
|
||||
reply-channel="outputChannel"/>
|
||||
|
||||
<int-redis:queue-inbound-gateway id="inboundGateway"
|
||||
queue="#{redisQueue.toString()}"
|
||||
request-channel="requestChannel"
|
||||
reply-timeout="20001"
|
||||
reply-timeout="200"
|
||||
receive-timeout="100"
|
||||
request-timeout="20000"/>
|
||||
request-timeout="200"/>
|
||||
|
||||
<int:service-activator input-channel="requestChannel" expression="payload + 1"/>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 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.
|
||||
@@ -39,16 +39,15 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author David Liu
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@DirtiesContext
|
||||
public class RedisQueueGatewayIntegrationTests extends RedisAvailableTests {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user