Patrik Mihalčin
Patrik Mihalčin

Reputation: 3971

Log spring integration message lifecycle travelling through IntegrationFlow

Is there a way how to log the lifecycle of the spring integration message?

e.g. given DSL IntegrationFlow

jmsFlowsUtils.jmsXmlInputFlow(queue)
    .<Object, Class<?>>route(Object::getClass, firstFlow -> firstFlow
            .subFlowMapping(SomeClass.class.getName(), amEventFlow -> amEventFlow
                    .filter(...)
                    .transform(...)
                    .channel(...)
                    .handle(...)
            )
            .subFlowMapping(OtherClass.class.getName(), secondFlow -> secondFlow
                    .filter(...)
                    .transform(...)
                    .channel(...)
                    .handle(...)                    
            )
    )
    .get();

The log message would be a string containing EIP endpoint ids/names the message travelled through including timestamps

This would build the basis for some other tool to extract information from logs and present it to users in nice form (e.g. ELK stack might be used for that purpose: https://www.elastic.co/products)

Does anybody have any experience with this use-case?

Upvotes: 1

Views: 335

Answers (1)

Gary Russell
Gary Russell

Reputation: 174514

You can use @EnableMessageHistory to turn on message history tracking and that information is added to the headers as the message progresses through the flow.

See Message History.

You can use component name patterns to restrict the history tracking to certain components.

Upvotes: 1

Related Questions