Lemline documentation Help

Shop checkout workflow

Run the example against the local Node.js shop by following Reserve, charge and ship an order. Use the approved and declined inputs there to compare the final inventory, shipment and inbox records.

Complete the SQLite setup and keep its worker running. Start the shop from the root of the Lemline source checkout, then run the other commands from a second terminal in the setup directory (with the JAR, substitute java -jar lemline.jar for bin/lemline):

docker compose -f examples/tutorial-services/compose.yaml up -d

Save this definition as compensate-reservation.yaml:

document: dsl: '1.0.3' namespace: examples name: compensate-reservation version: '1.0.0' do: - reserveInventory: call: http with: method: post endpoint: http://127.0.0.1:8787/reservations body: orderId: ${ $workflow.input.orderId } items: ${ $workflow.input.items } export: as: '${ $context + { reservationId: .id } }' - completeOrder: try: - chargePayment: call: http with: method: post endpoint: http://127.0.0.1:8787/charges body: orderId: ${ $workflow.input.orderId } paymentInfo: ${ $workflow.input.paymentInfo } catch: do: - releaseInventory: call: http with: method: delete endpoint: '${ "http://127.0.0.1:8787/reservations/\($context.reservationId | @uri)" }' - reportFailure: raise: error: type: https://errors.example.com/order-failed status: 502 title: Order completion failed - compareCarriers: fork: branches: - economy: try: - quote: call: http with: method: post endpoint: http://127.0.0.1:8787/quotes/economy body: orderId: ${ $workflow.input.orderId } failTwice: ${ $workflow.input.failTwice // false } catch: retry: delay: { seconds: 1 } limit: attempt: { count: 3 } - express: call: http with: method: post endpoint: http://127.0.0.1:8787/quotes/express body: orderId: ${ $workflow.input.orderId } - selectCarrier: set: carrier: ${ min_by(.price).carrier } - bookShipment: call: http with: method: post endpoint: http://127.0.0.1:8787/shipments body: orderId: ${ $workflow.input.orderId } carrier: ${ .carrier } - confirmShipment: call: http with: method: post endpoint: http://127.0.0.1:8787/notifications body: reference: ${ .orderId } recipient: customer message: '${ "Shipment booked with " + .carrier }'
bin/lemline definition post -f compensate-reservation.yaml bin/lemline instance start examples compensate-reservation --input '{"orderId":"ORD-201","items":[{"id":"SKU-1","quantity":2}],"paymentInfo":{"token":"approved"},"failTwice":true}' bin/lemline instance start examples compensate-reservation --input '{"orderId":"ORD-202","items":[{"id":"SKU-1","quantity":2}],"paymentInfo":{"token":"declined"}}'

Open the shop: 98 units remain, ORD-201 is shipped with economy after two failed economy quotes, and ORD-202 is released with no shipment. The second instance faults with Order completion failed.

The payment catch block releases the reservation identified in workflow context. Carrier retries happen after payment; a transient carrier failure retries the quote without charging the customer again. When both branches finish, the workflow compares their prices and passes the selected carrier to the shipment task.

Stop the shop when you are done:

docker compose -f examples/tutorial-services/compose.yaml down
25 November 2026