liveBook · Manning

Command message

As explained in Microservices Patterns, Second Edition

A message requesting that a receiver invoke a specified operation with specified parameters.

A command message requests that a receiver perform a specified operation with specified parameters. It is the messaging equivalent of an RPC request; unlike a document, it tells the receiver what operation to invoke. section 8.3.1

Choose the interaction pattern based on whether the sender needs a reply:

  • For asynchronous request/reply, send the command to the service’s point-to-point channel and include a reply-channel header. The receiver replies with a correlation ID so the sender can match the response to its request. section 8.3.2
  • For a one-way notification, send the command to the service’s point-to-point channel; the service processes it without replying. section 8.3.2

Order validation

An Order Service can create an order in PENDING state, return its ID, then send ValidateConsumerInfo and ValidateOrderDetails commands to other services. Their replies drive the order’s later transition to VALIDATED. This avoids waiting for those services before responding, but the initial response gives only a partial outcome. section 8.3.9

Figure 8.12 The business logic in the sender invokes a sending port interface, which is implemented by the message sender’s adapter. The message sender sends a message to a receiver via a message channel. The message channel is an abstraction of messaging infrastructure. A message handler adapter in the receiver is invoked to handle the message. It invokes the receiving port interface implemented by the receiver’s business logic.
Messaging

Shows how sender and receiver business logic connect through port interfaces, adapters, and a message channel. section 8.3.1

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines the request and details reply channels and correlation IDs, but does not specify command-message internals.
Examples
Uses ValidateConsumerInfo and ValidateOrderDetails commands in an order-validation flow.
What you can do after
Apply it to asynchronous service requests by specifying an operation, parameters, and, when needed, a reply channel.
How it connects
Links command messages to RPC, point-to-point channels, asynchronous request/reply, and reply messages.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.