liveBook · Manning

Message

As explained in Quarkus in Action

Message is a reactive-messaging API abstraction that wraps a produced payload and exposes operations for acknowledging or negatively acknowledging the received message.

A Message is a reactive-messaging wrapper around a produced payload. It moves through channels between CDI bean methods and can carry processing control in addition to application data. Most Quarkus messaging code consumes payloads directly, but consuming Message exposes the received payload together with explicit acknowledgement operations. section 9.10 section 9.3.3

Use Message when processing requires control over acknowledgement behavior:

  • Read the application value with getPayload(). section 9.3.3
  • Call ack() after successful processing to positively acknowledge the received message. section 9.3.3
  • Call nack(Throwable) when processing fails and the failure must be propagated. section 9.3.3
  • Return a modified message with withPayload(...) when forwarding the message through another channel. section 9.8.2

Manual acknowledgement

A consumer selects MANUAL acknowledgement and decides whether processing succeeds: on success it returns message.ack(); otherwise it returns message.nack(...) with the processing error. The method therefore controls acknowledgement rather than relying on Quarkus's implicit strategy. section 9.3.3

Listing 9.2 A manual acknowledgement example
@Incoming("channel-name")
@Acknowledgment(Acknowledgment.Strategy.MANUAL) 	 #1
public CompletionStage<Void> consumer(Message<String> message) {
    if (processMessage(message.getPayload())) {
        return message.ack();
    } else {
        return message.nack(
            new IllegalStateException(
                "Cannot process message " + message.getPayload()));
    }
}

Inspect the complete Java consumer showing @Incoming, @Acknowledgment(MANUAL), payload processing, ack(), and nack(Throwable). section 9.3.3

How Quarkus in Action covers it

How deep it goes
Defines payload wrapping, ack and nack operations, acknowledgement strategies, and chained acknowledgement behavior through a worked consumer.
Examples
Uses a manual consumer that processes String payloads and a billing processor that transforms incoming messages with withPayload(...).
What it assumes
Assumes familiarity with CDI bean methods and channels while explaining payload wrapping and acknowledgement strategies directly.
What you can do after
Apply it via Quarkus Reactive Messaging to inspect payloads, forward messages, and explicitly acknowledge or reject processing.
How it connects
Connects payload processing with channels, CDI beans, connectors, reactive streams, and acknowledgement strategies.

Also explained in

Compare how 7 books explain message →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.