Class OutboxRecord
The payload is text rather than bytes, which is a deliberate choice with a cost. The cost is that a binary codec cannot use this store as it stands. The gain is that the outbox table can be read with SQL, and an operator asking "why has this order not been published?" at three in the morning can answer it with a select rather than a hex dump. Every codec AceMQ ships today produces text, so nothing is lost yet, and a bytes column can be added beside this one when that changes.
The envelope is reduced to its identifying fields — id, type, correlation and causation — rather than stored whole. Arbitrary headers would need a serialisation format, and inventing one here to avoid depending on a codec would be the worse trade. Until the JSON codec lands, a message published through the outbox carries these four fields and no custom headers.
-
Constructor Summary
ConstructorsConstructorDescriptionOutboxRecord(String id, String exchange, String routingKey, String type, String payload, @Nullable String correlationId, @Nullable String causationId, Instant createdAt, int attempts, @Nullable String lastError) Full constructor, used when reading a record back out of storage. -
Method Summary
-
Constructor Details
-
OutboxRecord
public OutboxRecord(String id, String exchange, String routingKey, String type, String payload, @Nullable String correlationId, @Nullable String causationId, Instant createdAt, int attempts, @Nullable String lastError) Full constructor, used when reading a record back out of storage.- Parameters:
id- message identifier, unique across the outboxexchange- exchange to publish to; empty string for the default exchangeroutingKey- routing key to publish withtype- logical message typepayload- encoded message bodycorrelationId- correlation identifier, ornullcausationId- causation identifier, ornullcreatedAt- when the record was writtenattempts- how many publish attempts have been madelastError- why the last attempt failed, ornull
-
-
Method Details
-
of
public static OutboxRecord of(String exchange, String routingKey, Envelope envelope, String payload) A new record for a message that has not been attempted yet.- Parameters:
exchange- exchange to publish to; empty string for the default exchangeroutingKey- routing key to publish withenvelope- envelope the message will carry; its id becomes the record's idpayload- encoded message body- Returns:
- the record to hand to
OutboxStore.add(org.acemq.amqp.api.OutboxRecord)
-
envelope
Rebuilds the envelope this record should be published with.The identifier is carried through rather than regenerated, so a relay that publishes the same record twice — which it will, if it dies between the broker's confirm and the database commit — sends the same identifier both times and an idempotent consumer can recognise the second as a duplicate.
- Returns:
- the envelope to publish with
-
id
- Returns:
- message identifier, unique across the outbox
-
exchange
- Returns:
- exchange to publish to; empty string for the default exchange
-
routingKey
- Returns:
- routing key to publish with
-
type
- Returns:
- logical message type
-
payload
- Returns:
- encoded message body
-
correlationId
- Returns:
- correlation identifier, if the message carries one
-
causationId
- Returns:
- causation identifier, if the message carries one
-
createdAt
- Returns:
- when the record was written
-
attempts
public int attempts()- Returns:
- how many publish attempts have been made
-
lastError
- Returns:
- why the last attempt failed, if one has
-
equals
-
hashCode
public int hashCode() -
toString
-