diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueInboundGateway.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueInboundGateway.java
index a811614002..ec16a05b55 100644
--- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueInboundGateway.java
+++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueInboundGateway.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2015 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.
@@ -45,6 +45,8 @@ import org.springframework.util.Assert;
* @author David Liu
* @author Artem Bilan
* @author Gary Russell
+ * @author Matthias Jeschke
+ *
* @since 4.1
*/
@ManagedResource
@@ -125,7 +127,7 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements
* @param receiveTimeout Must be non-negative. Specified in milliseconds.
*/
public void setReceiveTimeout(long receiveTimeout) {
- Assert.isTrue(receiveTimeout > 0, "'receiveTimeout' must be > 0.");
+ Assert.isTrue(receiveTimeout >= 0, "'receiveTimeout' must be >= 0.");
this.receiveTimeout = receiveTimeout;
}
diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpoint.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpoint.java
index 2b3f1317ee..10c711ebe6 100644
--- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpoint.java
+++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisQueueMessageDrivenEndpoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2016 the original author or authors
+ * Copyright 2013-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.
@@ -48,6 +48,8 @@ import org.springframework.util.Assert;
* @author Artem Bilan
* @author Gary Russell
* @author Rainer Frey
+ * @author Matthias Jeschke
+ *
* @since 3.0
*/
@ManagedResource
@@ -131,7 +133,7 @@ public class RedisQueueMessageDrivenEndpoint extends MessageProducerSupport impl
* @param receiveTimeout Must be non-negative. Specified in milliseconds.
*/
public void setReceiveTimeout(long receiveTimeout) {
- Assert.isTrue(receiveTimeout > 0, "'receiveTimeout' must be > 0.");
+ Assert.isTrue(receiveTimeout >= 0, "'receiveTimeout' must be >= 0.");
this.receiveTimeout = receiveTimeout;
}
diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests-context.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests-context.xml
index 3a1cc5b604..05c228fb5f 100644
--- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests-context.xml
+++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests-context.xml
@@ -11,7 +11,8 @@
-
+
@@ -33,9 +34,16 @@
auto-startup="false"
phase="100"/>
+
+
-
+
diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests.java
index 7376a7fd45..d9ba99274d 100644
--- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests.java
+++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueInboundChannelAdapterParserTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2015 the original author or authors.
+ * Copyright 2013-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.
@@ -41,9 +41,12 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
/**
* @author Artem Bilan
* @author Gary Russell
+ * @author Matthias Jeschke
+ *
* @since 3.0
*/
@ContextConfiguration
@@ -71,6 +74,10 @@ public class RedisQueueInboundChannelAdapterParserTests {
@Qualifier("customAdapter")
private RedisQueueMessageDrivenEndpoint customAdapter;
+ @Autowired
+ @Qualifier("zeroReceiveTimeoutAdapter")
+ private RedisQueueMessageDrivenEndpoint zeroReceiveTimeoutAdapter;
+
@Autowired
@Qualifier("errorChannel")
private MessageChannel errorChannel;
@@ -87,11 +94,13 @@ public class RedisQueueInboundChannelAdapterParserTests {
@Autowired
private RedisSerializer> serializer;
+
@Test
public void testInt3017DefaultConfig() {
assertSame(this.connectionFactory,
TestUtils.getPropertyValue(this.defaultAdapter, "boundListOperations.ops.template.connectionFactory"));
- assertEquals("si.test.Int3017.Inbound1", TestUtils.getPropertyValue(this.defaultAdapter, "boundListOperations.key"));
+ assertEquals("si.test.Int3017.Inbound1",
+ TestUtils.getPropertyValue(this.defaultAdapter, "boundListOperations.key"));
assertFalse(TestUtils.getPropertyValue(this.defaultAdapter, "expectMessage", Boolean.class));
assertEquals(1000L, TestUtils.getPropertyValue(this.defaultAdapter, "receiveTimeout"));
assertEquals(5000L, TestUtils.getPropertyValue(this.defaultAdapter, "recoveryInterval"));
@@ -105,11 +114,13 @@ public class RedisQueueInboundChannelAdapterParserTests {
assertSame(this.defaultAdapterChannel, TestUtils.getPropertyValue(this.defaultAdapter, "outputChannel"));
}
+
@Test
public void testInt3017CustomConfig() {
assertSame(this.customRedisConnectionFactory,
TestUtils.getPropertyValue(this.customAdapter, "boundListOperations.ops.template.connectionFactory"));
- assertEquals("si.test.Int3017.Inbound2", TestUtils.getPropertyValue(this.customAdapter, "boundListOperations.key"));
+ assertEquals("si.test.Int3017.Inbound2",
+ TestUtils.getPropertyValue(this.customAdapter, "boundListOperations.key"));
assertTrue(TestUtils.getPropertyValue(this.customAdapter, "expectMessage", Boolean.class));
assertEquals(2000L, TestUtils.getPropertyValue(this.customAdapter, "receiveTimeout"));
assertEquals(3000L, TestUtils.getPropertyValue(this.customAdapter, "recoveryInterval"));
@@ -121,4 +132,10 @@ public class RedisQueueInboundChannelAdapterParserTests {
assertSame(this.sendChannel, TestUtils.getPropertyValue(this.customAdapter, "outputChannel"));
}
+
+ @Test
+ public void testInt4341ZeroReceiveTimeoutConfig() {
+ assertEquals(0L, TestUtils.getPropertyValue(this.zeroReceiveTimeoutAdapter, "receiveTimeout"));
+ }
+
}