Huong Dan Java Logger – Part 6 – Retrieve Correlation ID and Category from the configuration

After the user has configured Huong Dan Java Logger, processing to retrieve the final value of Correlation Id and Category is necessary. Because in the Global Configuration, the value of these two cells is mandatory, so these will be the default values for these two.

Because the Global Configuration Override section in the main configuration can override the value of Correlation Id and Category, we need to check this section first, if they are not configured we will return the default value.

Detail code for obtaining Correlation Id and Category from configuration is as follows:

In the Category, its value is fixed so we do not need to support the Mule Expression Language (MEL) for it, but the Correlation Id is mandatory because the value of Correlation Id can be obtained from Mule Flow or Mule Message as the default value in the Global Configuration of this information.

I will add the following method to help us get the final value after processing the MEL:

In Mule ESB, the ExpressionManager object is responsible for parsing the MEL to get the final value that we need.

Here I will modify the getCorrelationId() method to support MEL and by the way, rename this method into getEvaluatedCorrelationId:

Here we can get the Correlation Id and Category in the main part of the Processor:

 

Add Comment