Search code examples
javamuletransformer-model

How to access record variables in a java transaformer


I'm converting a flow from straight single thread, to use a batch processor. So, I'm converting most of the flow variables to recordVars. Some questions i can't find in the docs:

  • How do i access a record var in a java transformer? I'm used to message.getInvocationProperty for flow vars
  • What happens when i change a flow var - can other threads in the batch see the changes?

Solution

  • You can access recordVars form Java or Groovy component using the following:

    import com.mulesoft.module.batch.record.BatchUtils;
    ...
    BatchUtils.getRecord(message).getVariable('myVar');