Messaging Bridge
๋ฉ์์ง ๋ธ๋ฆฌ์ง๋ ๋ ๊ฐ์ ๋ฉ์์ง ์ฑ๋ ๋๋ ์ฑ๋ ์ด๋ํฐ๋ฅผ ์ฐ๊ฒฐํ๋ ๋น๊ต์ ๊ฐ๋จํ ๋์ ์ ๋๋ค.
Configuring a Bridge with Java Configuration
๋ค์ ์์์๋ @BridgeFrom
annotation์ ์ฌ์ฉํ์ฌ Java์์ ๋ธ๋ฆฌ์ง๋ฅผ ๊ตฌ์ฑํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค.
@Bean
public PollableChannel polled() {
return new QueueChannel();
}
@Bean
@BridgeFrom(value = "polled", poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "10"))
public SubscribableChannel direct() {
return new DirectChannel();
}
๋ค์ ์๋ @BridgeTo
annotation์ ์ฌ์ฉํ์ฌ Java์์ ๋ธ๋ฆฌ์ง๋ฅผ ๊ตฌ์ฑํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค.
@Bean
@BridgeTo(value = "direct", poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "10"))
public PollableChannel polled() {
return new QueueChannel();
}
@Bean
public SubscribableChannel direct() {
return new DirectChannel();
}
๋๋ ๋ค์ ์์ ์ ๊ฐ์ด BridgeHandler
๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
@Bean
@ServiceActivator(inputChannel = "polled",
poller = @Poller(fixedRate = "5000", maxMessagesPerPoll = "10"))
public BridgeHandler bridge() {
BridgeHandler bridge = new BridgeHandler();
bridge.setOutputChannelName("direct");
return bridge;
}
Configuring a Bridge with the Java DSL
๋ค์ ์์ ์ ๊ฐ์ด JDSL(Java Domain Specific Language)์ ์ฌ์ฉํ์ฌ ๋ธ๋ฆฌ์ง๋ฅผ ๊ตฌ์ฑํ ์ ์์ต๋๋ค.
@Bean
public IntegrationFlow bridgeFlow() {
return IntegrationFlow.from("polled")
.bridge(e -> e.poller(Pollers.fixedDelay(5000).maxMessagesPerPoll(10)))
.channel("direct")
.get();
}
Last updated
Was this helpful?