Class RoutingSlip
A pipeline has no coordinator. Each step reads the slip, does its work, advances the position and publishes to whatever comes next; when the position runs off the end, the run is over. That is choreography rather than orchestration, and the difference is worth the two headers it costs:
- There is no flow engine to run, page somebody about, or upgrade — nothing to be down.
- A consumer in Go reads three headers. The Java library is not privileged.
- The state survives a restart, because it is in the message rather than in a coordinator's memory.
- A message dead-lettered at step two keeps its slip, so replaying it resumes the run instead of starting it again.
The cost, and it is a real one: the route is fixed when the message is first sent. Changing a pipeline does not change messages already travelling, which finish along the route they were given. During a deploy that is usually what anyone would want, and it is occasionally surprising.
Steps are named rather than numbered on the wire, so a slip stays readable in a management
console: validate,enrich,dispatch with a position of 1 says exactly where a
message is without anybody decoding anything.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionadvance()advanceTo(int position) current()static Optional<RoutingSlip> Reads a slip off a message's headers.booleannext()intposition()runId()static RoutingSlipstatic RoutingSlipsteps()toString()
-
Field Details
-
ROUTE
The ordered step names, comma-separated.- See Also:
-
POSITION
Which step is next, counting from zero.- See Also:
-
RUN_ID
Identifies one run through a pipeline, across every hop.- See Also:
-
-
Method Details
-
startOf
- Parameters:
steps- the step names, in order- Returns:
- a slip at the beginning of that route, with a fresh run identifier
-
from
Reads a slip off a message's headers.- Parameters:
headers- the message headers- Returns:
- the slip, or empty when the message is not travelling a route
-
current
- Returns:
- the step this message is for now, or empty when the route is finished
-
next
- Returns:
- the step after the current one, or empty when this is the last
-
advanceTo
- Parameters:
position- which step to start at- Returns:
- a slip positioned there, for a message replayed straight into a queue with no slip of its own
-
advance
- Returns:
- a slip advanced by one step
-
isFinished
public boolean isFinished()- Returns:
- whether every step has been handled
-
steps
- Returns:
- the steps, in order
-
position
public int position()- Returns:
- which step is next, counting from zero
-
runId
- Returns:
- the identifier of this run, stable across every hop, a dead-letter and a replay
-
toHeaders
- Returns:
- the headers to publish this slip with; merge them into an envelope's own
-
startOf
- Parameters:
steps- step names- Returns:
- a slip at the start of that route
-
toString
-