@Bean("Channel1")
@BridgeTo("Channel1and2")
PollableChannel c1() {...}
@Bean("Channel2")
@BridgeTo("Channel1and2")
PollableChannel c2() {...}
注意te @BridgeTo
註解。從它的JavaDocs:
* Messaging Annotation to mark a {@link org.springframework.context.annotation.Bean}
* method for a {@link org.springframework.messaging.MessageChannel} to produce a
* {@link org.springframework.integration.handler.BridgeHandler} and Consumer Endpoint.
* <p>
* The {@link org.springframework.messaging.MessageChannel} {@link org.springframework.context.annotation.Bean}
* marked with this annotation is used as the {@code inputChannel} for the
* {@link org.springframework.integration.endpoint.AbstractEndpoint}
* and determines the type of endpoint -
* {@link org.springframework.integration.endpoint.EventDrivenConsumer} or
* {@link org.springframework.integration.endpoint.PollingConsumer}.
您也可以考慮對@BridgeTo
使用@Poller
,因爲你的輸入通道PollableChannel
。
關於此事的參考手冊:http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/configuration.html#_creating_a_bridge_with_annotations