Message and Headers
Message
The Message (package io.pipelite.spi.flow.exchange) is the container for the application payload.
Each Exchange has an input Message and, optionally, an output Message.
Main API
Message input = exchange.getInput();
// Payload access
Object payload = input.getPayloadAs(Object.class);
MyDto dto = input.getPayloadAs(MyDto.class);
Class<?> payloadType = input.getPayloadType();
boolean hasPayload = input.hasPayload();
// Payload modification (inside a processor)
input.setPayload(newValue);
Headers
The Headers class (interface and implementation HeadersImpl) provides access to message metadata.
Read
Headers headers = exchange.getHeaders();
// Optional read
Optional<String> value = headers.tryGetHeader("x-request-id");
// Read with expectation (throws NoSuchElementException if absent)
String value = headers.expectHeader("x-request-id");
// Typed read
Optional<Integer> n = headers.tryGetHeaderAs("retry-count", Integer.class);
// Presence check
boolean present = headers.hasHeader("x-request-id");
System headers
The framework uses several reserved headers, defined in IOKeys:
| Constant | Purpose |
|---|---|
|
Address of the reply flow (Return Address pattern) |
|
Dynamic list of flows to traverse (property, not header) |
| Do not use system-reserved keys as application headers to avoid collisions with framework behaviour. |