Let’s imagine, Huong Dan Java Logger is an endpoint in a Mule Flow. When Mule Flow processes the request to the Huong Dan Java Logger endpoint, it executes all the lines of code contained in the log() method of the HuongDanJavaLoggerComponentConnector class. After the execution for this code is completed, the return value of this method will be the payload of the message Mule.
Currently, if you use Huong Dan Java Logger in your Mule application, you will see that after the Huong Dan Java Logger endpoint, the value of the payload is the value of the Correlation Id.
For example, I have a small Mule application like this:
In particular, Huong Dan Java Logger is configured as follows:
Global Configuration:
The Logger component is configured as follows:
When running the result will be:
As I said and as you can see, now after passing Huong Dan Java Logger, the payload of Mule Message is the value of Correlation Id.
To fix this, just change the return code in the log() method of the HuongDanJavaLoggerComponentConnector class as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
@Processor public Object log( @Placement(group = Text.GENERIC, order = 1) @Optional String message, @Placement(group = Text.GENERIC, order = 2) @Default("INFO") @FriendlyName(Text.LEVEL) LoggingLevel loggingLevel, @Placement(group = Text.OVERRIDE, order = 1) @Optional @FriendlyName(Text.OVVERIDE_CORRELATION_ID) String globalCorrelationIdOverride, @Placement(group = Text.OVERRIDE, order = 2) @Optional @FriendlyName(Text.OVVERIDE_CATEGORY) String globalCategoryOverride, MuleEvent event) { String category = getCategory(config, globalCategoryOverride); String correlationId = getEvaluatedCorrelationId(event, config, globalCorrelationIdOverride); MDC.put(CORRELATION_ID_ELEMENT, correlationId); String evaluatedMessage = getEvaluatedMessage(event, message); Logger logger = LoggerFactory.getLogger(category); if (evaluatedMessage != null) { doLogging(logger, loggingLevel, evaluatedMessage); } return event.getMessage().getPayload(); } |