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 —
plus its headers: the application's own and any x-acemq- extensions it carried. The
relay publishes all of them, so a message sent through the outbox is the message that was
recorded (TCK OUTBOX-001). Up to 0.7.18 the headers were not kept and the relay published
without them. How a store persists them is the store's business; JdbcOutboxStore
writes them as a JSON object in a headers column.
-
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.OutboxRecord(String id, String exchange, String routingKey, String type, String payload, @Nullable String correlationId, @Nullable String causationId, Instant createdAt, int attempts, @Nullable String lastError, @Nullable Map<String, Object> headers) Full constructor with headers, 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
-
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, @Nullable Map<String, Object> headers) Full constructor with headers, 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, ornullheaders- headers to publish with — application headers andx-acemq-extensions together — ornullfor none
-
-
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
-
headers
- Returns:
- headers the message is published with — application headers and
x-acemq-extensions together; empty when there are none, nevernull
-
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
-