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?