Skip to content

External Events

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

External Event

External or Manual event is an event which is posted to Flux externally once the task is done.

In the above example, Admin approval is a manual task. After getting user details and validating, the workflow will wait in Admin approval state until the event is submitted externally.

Using @ExternalEvent annotation user can indicate that the task is waiting for an external event.

@Task(version = 1, timeout = 1000l)
public SellerVerificationStatus waitForVerification(@ExternalEvent("sellerVerification") SellerVerificationStatus verificationStatus) {
    System.out.println("[ManualSellerVerificationService] Received verification status " + verificationStatus.isVerifiedSeller() + " for seller " + verificationStatus.getSellerId());
    return verificationStatus;
}

In the above sellerVerification is the name of the event. Using the event name the user can post the event to Flux engine.

new FluxRuntimeConnectorHttpImpl(1000l,1000l,"http://flux_url:port/api/machines").submitEvent("sellerVerification", new SellerVerificationStatus(new SellerId(1l), true), correlationId, "Manual Trigger From Customer Support");

Class com.flipkart.flux.examples.externalevents.ManualSellerVerificationFlow contains example code.

Points to be noted:
  • Paas null in place of external event while calling a task which is dependant on external event.
sellerVerificationService.waitForVerification(null);
  • The name of the External event needs to be unique across the workflow.

Clone this wiki locally