Added automatic subscription activation upon registration for endpoints that provide 'inputChannelName' and 'consumerPolicy'.
This commit is contained in:
@@ -124,6 +124,13 @@ public class MessageBus implements ChannelMapping, ApplicationContextAware, Life
|
||||
public void registerEndpoint(String name, MessageEndpoint endpoint) {
|
||||
this.endpoints.put(name, endpoint);
|
||||
endpoint.setChannelMapping(this);
|
||||
if (endpoint.getInputChannelName() != null && endpoint.getConsumerPolicy() != null) {
|
||||
Subscription subscription = new Subscription();
|
||||
subscription.setChannel(endpoint.getInputChannelName());
|
||||
subscription.setEndpoint(name);
|
||||
subscription.setPolicy(endpoint.getConsumerPolicy());
|
||||
this.activateSubscription(subscription);
|
||||
}
|
||||
}
|
||||
|
||||
public void activateSubscription(Subscription subscription) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.endpoint;
|
||||
|
||||
import org.springframework.integration.bus.ConsumerPolicy;
|
||||
import org.springframework.integration.channel.ChannelMapping;
|
||||
import org.springframework.integration.message.Message;
|
||||
|
||||
@@ -28,8 +29,12 @@ public interface MessageEndpoint {
|
||||
|
||||
void setInputChannelName(String inputChannelName);
|
||||
|
||||
String getInputChannelName();
|
||||
|
||||
void setDefaultOutputChannelName(String defaultOutputChannelName);
|
||||
|
||||
ConsumerPolicy getConsumerPolicy();
|
||||
|
||||
void setChannelMapping(ChannelMapping channelMapping);
|
||||
|
||||
void messageReceived(Message message);
|
||||
|
||||
@@ -21,9 +21,16 @@
|
||||
<bean id="sink" class="org.springframework.integration.endpoint.TestSink"/>
|
||||
|
||||
<bean id="endpoint" class="org.springframework.integration.endpoint.GenericMessageEndpoint">
|
||||
<property name="inputChannelName" value="inboundAdapter"/>
|
||||
<property name="defaultOutputChannelName" value="outboundAdapter"/>
|
||||
<property name="consumerPolicy">
|
||||
<bean class="org.springframework.integration.bus.ConsumerPolicy">
|
||||
<property name="receiveTimeout" value="100"/>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
<bean class="org.springframework.integration.bus.Subscription">
|
||||
<property name="channel" value="inboundAdapter"/>
|
||||
<property name="endpoint" value="endpoint"/>
|
||||
@@ -33,5 +40,6 @@
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
-->
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user