Package org.acemq.amqp.api
Class PublishContext
java.lang.Object
org.acemq.amqp.api.PublishContext
A message about to be published, as an interceptor sees it.
Immutable, and changed by withEnvelope(org.acemq.amqp.api.Envelope), which returns a new context. An interceptor
that mutated what it was handed would be invisible to the one after it and impossible to
reason about when two of them touch the same header.
The payload is the application's object, before encoding. That is deliberate: an interceptor
that needs to look at what is being sent should see an OrderPlaced, not a byte array it
would have to decode again to understand.
-
Constructor Details
-
PublishContext
- Parameters:
exchange- target exchangeroutingKey- routing keyenvelope- the envelope as it standspayload- the application object being sent, before encoding
-
-
Method Details
-
exchange
- Returns:
- target exchange, empty when publishing straight to a queue
-
routingKey
- Returns:
- the routing key
-
envelope
- Returns:
- the envelope, including headers an interceptor may have added
-
payload
- Returns:
- the application object being published, before encoding
-
withEnvelope
- Parameters:
replacement- the envelope to carry on with- Returns:
- a copy of this context with a different envelope
-
toString
-