Reputation: 621
I'm doing the application with the Spring Integration Java DSL.
What is the best way to log to the database using the Spring Data JPA from the application?
I have a quite long integration flow with the multiple HTTP gets and posts. I want at least log the sent and responded messages and which URLs were used and possible some other custom values.
I have tried the logging with the method IntegrationFlowBuilder.log
. With that my plan would be create some custom logger, which logs to the database.
I have tried the method IntegrationFlowBuilder.enrichHeaders
with the method IntegrationFlowBuilder.log
to log the URLSs and the other custom values. How to change some header entry inside the IntegrationFlowBuilder
? I have added the entry with same key and different value, but the value in the logging doesn't change.
Upvotes: 1
Views: 260
Reputation: 121202
The HeaderEnricherSpec
for the enrichHeaders()
provides an option like:
/**
* Determine the default action to take when setting individual header specifications
* without an explicit 'overwrite' argument.
* @param defaultOverwrite the defaultOverwrite.
* @return the header enricher spec.
* @see HeaderEnricher#setDefaultOverwrite(boolean)
*/
public HeaderEnricherSpec defaultOverwrite(boolean defaultOverwrite) {
Also each added entry into the headers can be specified with their own override
flag:
/**
* Add a single header specification where the value is a String representation of a
* SpEL {@link Expression}.
* @param name the header name.
* @param expression the expression.
* @param overwrite true to overwrite an existing header.
* @return the header enricher spec.
*/
public HeaderEnricherSpec headerExpression(String name, String expression, Boolean overwrite) {
Upvotes: 1