Saturday, February 22, 2014

Camel Groovy script validator for cxfEndpoint

This applies to Camel 2.12.1/2.12.2
Using a Groovy script as a validator for incoming messages received through an inbound cfxEndpoint has an erratic behaviour: sometimes the message body has the value of a previous message. This looks like being dependent on the thread allocated to process the message: if it is the original thread that processed the first incoming message (when the script was compiled) than the expected body content is OK, otherwise it is  the previous messages processed on that first thread.

Solution:

  • get the sources for camel-script-2.12.x
  • change in org.apache.camel.builder.script.ScriptBuilder:
    • from result = compiledScript.eval();
    • to result = compiledScript.eval(getScriptContext());
    • in runScript method
  • recompile the package and deploy it

No comments :

Post a Comment