liveBook · Manning

Invoke pattern

As explained in Microservices Patterns, Second Edition

The invoke pattern is a collaboration mechanism in which one domain module synchronously calls a method on another domain module.

The invoke pattern coordinates an operation spanning domain modules through a direct method call. It is familiar and simple, and works well with transaction-per-operation. Its trade-off is design-time coupling: the risk of lock-step changes grows with the number of dependencies, especially when calls reach modules outside the caller’s core responsibilities. section 6.2.4

Creating an order

Order Management can call reserveCredit() on Consumer Management while creating an order. Calling Notification Management to send a confirmation email is a less suitable dependency because notifications are secondary to order management. section 6.2.4

Figure 6.16 The Invoke pattern is the most common and simplest collaboration mechanism. For example, the Order Domain Module can invoke the reserveCredit() method on the Consumer Management domain module.
module collaboration synchronous

Shows a direct call from Order Management to Consumer Management. section 6.2.4

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines direct invocation and explains its simplicity, transaction fit, and design-time coupling trade-offs.
Examples
Demonstrates Order Management calling reserveCredit() on Consumer Management during order creation.
What you can do after
Apply it by making a direct method call between domain modules, while accounting for dependency coupling.
How it connects
Links invocation to transaction-per-operation and contrasts it with Observer and asynchronous messaging.

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.