Skip to content

spericas/helidon-examples-lra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Long Running Activity Demo...

3 microservices:

LRA Coordinator:

  • *Note narayana pom.xml dependencies and need to repackage lra-coordinator.war as jar for Helidon execution.
  • Narayana coordinator running on Helidon

Order Service:

  • *Note narayana pom.xml dependencies and io.narayana.lra.filter.FilterRegistration DynamicFeature added in app.
  • call to placeOrder by client begins an LRA due to @LRA RequiresNew annotation and registers service with the LRA coordinator.
  • calls inventory service to check inventory with/propagating LRA_HTTP_CONTEXT_HEADER with the LRA id.
  • if inventory exists (the default) success is returned to order service which implicitly completes the LRA and coordinator calls the @Complete annotated method completeOrder
  • if inventory does not exist (can be achieved by calling the removeInventory endpoint on inventory service) failure is returned to order service which cancels the LRA and coordinator calls the @Compensate annotated method cancelOrder

Inventory Service:

  • *Note narayana pom.xml dependencies and io.narayana.lra.filter.FilterRegistration DynamicFeature added in app.
  • call to reserveInventoryForOrder by order service is executed within LRA started and propagated by order service due to @LRA Mandatory annotation and registers service with the LRA coordinator
  • calls inventory service to check and returns the result (success or fail) to the inventory service.

To build*:

  • ./build.sh

To run

  • java -jar lra-coordinator-helidon/target/lra-coordinator-helidon-0.0.1-SNAPSHOT.jar
  • java -jar order/target/order-0.0.1-SNAPSHOT.jar
  • java -jar inventory/target/inventory-0.0.1-SNAPSHOT.jar

For success/complete case ...

You should see the following output in the Order Service...

OrderResource.placeOrder in LRA due to LRA.Type.REQUIRES_NEW lraId:[...]

OrderResource.placeOrder response from inventory:inventorysuccess

OrderResource.completeOrder

And the following output in the Inventory Service...

InventoryResource.addInventory

InventoryResource.placeOrder in LRA due to LRA.Type.MANDATORY lraID:[...]

InventoryResource.completeOrder prepare item for shipping lraId:[...]

For failure/compensate case...

You should see the following output in the Order service...

OrderResource.placeOrder in LRA due to LRA.Type.REQUIRES_NEW lraId:[...]

OrderResource.placeOrder response from inventory:inventoryfailure

OrderResource.cancelOrder

And the following output in the Inventory Service...

InventoryResource.removeInventory

InventoryResource.placeOrder in LRA due to LRA.Type.MANDATORY lraID:[...]

InventoryResource.cancelOrder put inventory back lraId:[...]

About

Examples of LRA running on Helidon

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published