pub struct PendingOutbox {
pub message_type: Box<str>,
pub recipient: Box<str>,
pub payload: Value,
pub deliver_after: Option<OffsetDateTime>,
pub payload_schema: Option<Box<str>>,
pub caused_by_event_index: usize,
}Expand description
A lightweight outbox message specification produced by Workflow::handle.
Workflow::handle is a pure function: it cannot know the store-assigned
fields (event_id, stream_id, process_id, etc.) of the events it is
about to emit. PendingOutbox carries only the information the domain
workflow can produce deterministically, without I/O or clock access.
The engine fills in the store-assigned fields after the event append
succeeds, converting PendingOutbox into a fully materialised
OutboxMessage inside SlateDbStore::append_with_outbox.
§Example
// Inside Workflow::handle, when DispatchAperak succeeds:
let outbox = vec![
PendingOutbox::new("APERAK", &state.sender_party_id().to_string(), aperak_payload)
.caused_by(0), // caused by the first event in this batch
];
Ok(WorkflowOutput { events, outbox })Fields§
§message_type: Box<str>EDIFACT or XML message type (e.g. "APERAK", "CONTRL", "REMADV").
recipient: Box<str>GLN or EIC code of the intended recipient market participant.
payload: ValueDomain-level message payload (JSON).
Typically encodes the intent (e.g. positive/negative APERAK reason) rather than the final EDIFACT bytes. The delivery worker or AS4 gateway is responsible for rendering the final wire format.
deliver_after: Option<OffsetDateTime>Do not deliver before this time.
None means deliver immediately (as soon as the delivery worker runs).
Must not use the wall clock inside handle — derive from domain data
only (e.g. a schedule date carried in the command).
payload_schema: Option<Box<str>>BO4E JSON Schema URL that describes the payload shape.
Set this to the canonical BO4E schema URL when the payload is a
BO4E-typed object (e.g. Marktlokation, Messlokation). Leave
None for raw EDIFACT or untyped payloads.
Example:
"https://raw.githubusercontent.com/BO4E/BO4E-Schemas/v202607.1.0/src/bo4e_schemas/bo/Marktlokation.json"
caused_by_event_index: usizeZero-based index into the concurrent events batch that caused this outbound message.
Used by the engine to set causation_event_id on the materialised
OutboxMessage from the stamped EventEnvelope at the same index.
Clamped to events.len() - 1 when out-of-range.
Implementations§
Source§impl PendingOutbox
impl PendingOutbox
Sourcepub fn new(
message_type: impl Into<Box<str>>,
recipient: impl Into<Box<str>>,
payload: Value,
) -> Self
pub fn new( message_type: impl Into<Box<str>>, recipient: impl Into<Box<str>>, payload: Value, ) -> Self
Construct a pending outbox message for immediate delivery.
caused_by_event_index defaults to 0 (first event in the batch).
Chain caused_by to change it.
Sourcepub fn caused_by(self, index: usize) -> Self
pub fn caused_by(self, index: usize) -> Self
Set the zero-based index of the event that caused this outbox message.
Sourcepub fn with_deliver_after(self, deliver_after: OffsetDateTime) -> Self
pub fn with_deliver_after(self, deliver_after: OffsetDateTime) -> Self
Set a deferred delivery time (must be derived from domain data, not
the wall clock, to preserve Workflow::handle purity).
Sourcepub fn with_schema(self, schema_url: &'static str) -> Self
pub fn with_schema(self, schema_url: &'static str) -> Self
Attach a BO4E JSON Schema URL to the payload.
Use this when the payload is a BO4E-typed object so the ERP adapter can deserialise it into the correct type without inspecting the JSON.
Sourcepub fn aperak_anerkennung(from: &str, to: &str, orig_message_ref: &str) -> Self
pub fn aperak_anerkennung(from: &str, to: &str, orig_message_ref: &str) -> Self
APERAK 29002 Anerkennungsmeldung (BGM+312) for a message that
parsed and was accepted for processing.
from is this deployment’s MP-ID, to the Marktpartner that sent the
acknowledged message, and orig_message_ref its UNH DE 0062.
The reference is a parameter rather than an option because SG2 RFF+ACE/DTM+171/RFF+AGO are Muss in both APERAK
Anwendungsfälle: an acknowledgement that does not say what it
acknowledges is refused by the receiving Marktpartner, and there is no
second field it could be recovered from. The two Anwendungsfälle also
take different BGM codes — 29001 admits only 313, 29002 only 312
— so the pairing lives here rather than in each workflow.
Sourcepub fn aperak_fehler(
from: &str,
to: &str,
orig_message_ref: &str,
error_code: &str,
reason: impl Into<String>,
) -> Self
pub fn aperak_fehler( from: &str, to: &str, orig_message_ref: &str, error_code: &str, reason: impl Into<String>, ) -> Self
APERAK 29001 Verarbeitbarkeitsfehlermeldung (BGM+313) for a
message that could not be processed.
error_code is an ERC DE 9321 code from crate::erc::codes;
reason becomes the FTX+ABO free text. See
aperak_anerkennung for the other three
arguments.
Trait Implementations§
Source§impl Clone for PendingOutbox
impl Clone for PendingOutbox
Source§fn clone(&self) -> PendingOutbox
fn clone(&self) -> PendingOutbox
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more