'Spring Integration: save integration flows logs to database
I have been required to log the integration flow requests and save to logs that I am getting to the database. Logging the request is working fine, but my question is how can I store this logs that I am getting from the logAndReply() to the database?
return IntegrationFlows.from(Http.inboundGateway("/foo")
.requestMapping(m -> m.methods(HttpMethod.POST))
.validator(new Validator()).errorChannel("errorHandler.input"))
.transform(Transformers.objectToString())
.transform(new TransformingMethod())
.logAndReply(LoggingHandler.Level.INFO);
Solution 1:[1]
This is the part of your logging framework and in most cases it is called JdbcAppender. For example Log4J:
https://howtodoinjava.com/log4j2/jdbcappender-example/ log4j2 JDBCAppender with Spring http://smasue.github.io/log4j2-spring-database-appender
On the other hand, instead of relying on the logging framework, you can do it yourself and use a JdbcMessageHandler: https://docs.spring.io/spring-integration/docs/current/reference/html/jdbc.html#jdbc-outbound-channel-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 | Artem Bilan |
