Skip to content

Correlation Id

Shyam Kumar Akirala edited this page Dec 26, 2016 · 3 revisions

Correlation Id

Correlation Id is an unique id value to identify an entity across multiple systems.

It can used to uniquely identify a workflow instance processing an entity. To use this feature annotate a string field of one of the Events which are passed during workflow invocation with @CorrelationId.

Correlation Id is useful at a later stage in workflow lifecycle to post ExternalEvent(s). Refer to class com.flipkart.flux.examples.externalevents.ManualSellerVerificationFlow for example.

    @Workflow(version = 1)
    public void verifySeller(SellerId sellerId) {
        // call tasks
    }

    public class SellerId implements Event {

        @CorrelationId
        private String correlationId;

        //other fields
    }

Correlation Id also ensures Idempotency of a workflow.

Gotchas
  • Ideally, the presence of @CorrelationId on two or more fields across a workflow invocation params (i.e either within the same object or across object) should be a failure. However, currently this detection is not implemented yet & the behaviour is undefined
  • The @CorrelationId annotation needs to be present in the actual class of the object passed as workflow invocation parameter and not in any of its superclasse(s). Although it is possible to search the entire class hierarchy for the presence of this annotation, it makes the code harder to reason about and error prone.
Clone this wiki locally