Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ spec:

### Shape the outbox pattern message

You can override the outbox pattern message published to the pub/sub broker by setting a different message. This is done via a projected transaction payload, called `outboxProjections`, which is ignored when the state is written and is used as the outbox pattern message published to the user topic.
You can override the outbox pattern message published to the pub/sub broker by setting another transaction that is not be saved to the database and is explicitly mentioned as a projection. This transaction is added a metadata key named `outbox.projection` with a value set to `true`. When added to the state array saved in a transaction, this payload is ignored when the state is written and the data is used as the payload sent to the upstream subscriber.

To set the `outboxProjections` to `true`, the `key` values must match between the operation on the state store and the message projection. If the keys do not match, the whole transaction fails.
To use correctly, the `key` values must match between the operation on the state store and the message projection. If the keys do not match, the whole transaction fails.

If you have two or more `outboxProjections` for the same key, the first one defined is used and the others are ignored.
If you have two or more `outbox.projection` enabled state items for the same key, the first one defined is used and the others are ignored.

[Learn more about default and custom CloudEvent messages.]({{< ref pubsub-cloudevents.md >}})

Expand Down Expand Up @@ -368,26 +368,33 @@ You can pass the message override using the following HTTP request:
curl -X POST http://localhost:3500/v1.0/state/starwars/transaction \
-H "Content-Type: application/json" \
-d '{
"operations": [
{
"operation": "upsert",
"request": {
"key": "key1",
"value": "2"
}
},
{
"operation": "upsert",
"request": {
"key": "key1"
"value: "3"
"metadata": {
"outboxProjection": "true"
}
}
}
],
}'
"operations": [
{
"operation": "upsert",
"request": {
"key": "order1",
"value": {
"orderId": "7hf8374s",
"type": "book",
"name": "The name of the wind"
}
}
},
{
"operation": "upsert",
"request": {
"key": "order1",
"value": {
"orderId": "7hf8374s"
},
"metadata": {
"outbox.projection": "true"
},
"contentType": "application/json"
}
}
]
}'
```

By setting the metadata item `"outbox.projection"` to `"true"` and making sure the `key` values match (`key1`):
Expand Down