INT-2285 Implement max-subscribers on Channels
Add a subscriber limit on both unicast and publish-subscribe
channels. This permits detection of inadvertent channel wiring
during context initialization.
Also add a mechanism to globally set these defaults.
Two properties are added to ChannelInitializer. If the
'channelInitializer' bean is declared before a channel, and
these properties are set, it will globally override the
default (Integer.MAX_VALUE) for these properties.
For example:
<bean id="channelInitializer" class="org.springframework.integration.config.xml.ChannelInitializer">
<property name="autoCreate" value="true" />
<property name="defaultMaxUnicastSubscribers" value="1" />
<property name="defaultMaxMulticastSubscribers" value="2" />
</bean>
will make the default max-subscribers 1 and 2 for <channel/> and
<publish-subscribe/> channels respectively.
Also applies to module channels (jms, amqp, redis).
This commit is contained in:
committed by
Gunnar Hillert
parent
a90a7e8e0b
commit
2ecb14de2a
@@ -16,7 +16,7 @@
|
||||
time-to-live="123"
|
||||
priority="12"/>
|
||||
|
||||
<jms:channel id="queueNameChannel" queue-name="test.queue"/>
|
||||
<jms:channel id="queueNameChannel" queue-name="test.queue" max-subscribers="1" />
|
||||
|
||||
<jms:channel id="queueNameWithResolverChannel" queue-name="foo"
|
||||
destination-resolver="destinationResolver" connection-factory="connFact"/>
|
||||
|
||||
@@ -131,6 +131,8 @@ public class JmsChannelParserTests {
|
||||
assertEquals(DeliveryMode.PERSISTENT, TestUtils.getPropertyValue(jmsTemplate, "deliveryMode"));
|
||||
assertEquals(123L, TestUtils.getPropertyValue(jmsTemplate, "timeToLive"));
|
||||
assertEquals(12, TestUtils.getPropertyValue(jmsTemplate, "priority"));
|
||||
assertEquals(Integer.MAX_VALUE, TestUtils.getPropertyValue(
|
||||
TestUtils.getPropertyValue(channel, "dispatcher"), "maxSubscribers", Integer.class).intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,6 +144,8 @@ public class JmsChannelParserTests {
|
||||
AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) accessor.getPropertyValue("container");
|
||||
assertEquals("test.queue", jmsTemplate.getDefaultDestinationName());
|
||||
assertEquals("test.queue", container.getDestinationName());
|
||||
assertEquals(1, TestUtils.getPropertyValue(
|
||||
TestUtils.getPropertyValue(channel, "dispatcher"), "maxSubscribers", Integer.class).intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user