Search code examples
nullspring-integrationchannel

Null Channel maximum size - Spring Integration Flow


This is a follow up to question

The system diagram is available above.

MY QUESTION:

By default, what is the size of new NullChannel() in Spring Integration?

What is the maximum no. of messages can it hold?

I have not written any code to consume from the null channel. Will messages be deleted on its own if it is not consumed?

Code inside 2 is:

public IntegrationFlow handleJmsInput() throws Exception {
        return IntegrationFlows
            .from(Jms
                    .inboundGateway(jmsConnectionFactory())
                    .destination(
                            "PRODUCER QUEUE NAME")
                    .errorChannel(nullableChannel()))
            .transform("Class to convert JSON to Bean")
            .channel("Common channel name").get();
}

@Bean
public MessageChannel nullableChannel() {
    return new NullChannel();
}   

Solution

  • There is no "size"; NullChannel simply discards the message; it is similar to /dev/nul on Unix.

    You cannot "consume" from NullChannel (you can, but you'll never get a message).

    While it doesn't hurt anything, you don't need a bean; the framework configures one for you; use .errorChannel("nullChannel") or .errorChannel(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME).