Search code examples
spring-integrationspring-integration-dsl

Split up an IntegrationFlow for testing


I am planning to test an IntegrationFlow and have a question?

Let me walk you thru what I am planning to do.

IntegrationFlows
        .from(Amqp.inboundAdapter(connectionFactory, queue)
            .acknowledgeMode(AcknowledgeMode.AUTO)
            .concurrentConsumers(10).prefetchCount(100))
        .<byte[], String>transform(String::new)     
        .transform(objectMapperProcessor::process) 
        .enrichHeaders(header)                           
        .handle(Amqp.outboundAdapter(amqpTemplate)                                
            .routingKeyExpression("headers.routingKey_delta"))
        .get();

This is a sample IntegrationFlow I wish to test. Now, I want to test it by diving it right at each transform's and enrichHeaders. From the Spring Integration documentation, the way to do this is to split up the flow and write messages to the channel and read from the channel in the subsequent flows.

My question is when I split it up to either a QueueChannel or DirectChannel, am I altering the default performance? Because there is now an extra layer to which the data is being sent to, will that slow down things if I use the wrong type of channel when passing the data to a different flow?


Solution

  • Well, actually there is no any performance impact. Channels are there by default in between endpoints anyway. And they even bean and you can already get access to them and interact. You might even don't need any extra channel and this flow dividing.

    On the other hand the IntegrationFlow is just a logical container and when you divide one of them to several by some logical reason, there is no any performance impact again. Just because the target hard work is done by the endpoints, not flows.

    You may find this info as useful: https://docs.spring.io/spring-integration/docs/5.0.2.RELEASE/reference/html/java-dsl.html#java-dsl-channels

    Also pay attention to the Testing Framework in Spring Integration: https://docs.spring.io/spring-integration/docs/5.0.2.RELEASE/reference/html/testing.html#test-context