'How can I configure a QueueChannel with Poller using Java DSL?

we used to configure the poller in int:chain like below, the inboundChannel is configured with queue

    <int:chain id="messageProcessChain" input-channel="inboundChannel" >
        <int:poller fixed-delay="1" max-messages-per-poll="1"/>

This time, we'd like to programmatically initialize int flows, so using DSL. my test code as below:

                            Jms.messageDrivenChannelAdapter(inConnFactory).destination(flowProperties.getInputQueue()))
                            .channel(MessageChannels.queue(mongoDbChannelMessageStore,"groupId"))
//                            .enrichHeaders(testHeaders)
                            .handle(m -> {
                                System.out.println("test handler");

                                logger.info("test dsl flow:"+m.getPayload().toString());
                                },c -> c.poller(Pollers.fixedRate(flowProperties.getInboudFixedRate()).maxMessagesPerPoll(10)))
                            .get()

it cannot work with the ".enrichHeaders(testHeaders)", due to'No poller has been defined for endpoint', but neither can I configure a poller for the header richer because it has an implicit SubscribableChannel?

In such case, can only use a bridge to connect the two channel? Is there some other approaches?



Solution 1:[1]

Use .enrichHeaders(headers, e -> e.poller(...)).

However, you should NOT use a queue channel with a message-driven channel adapter, you will likely lose messages in the event of a failure.

To achieve concurrency, increase concurrency on the adapter.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gary Russell