Reputation: 623
In Pact's specification for asynchronous messaging, consumers are the services that read messages and providers the ones that write those messages.
As discussed in the section "Message Pact and the Command Pattern" of this blogpost, that works well for messages that are some kind of Event. Multiple consumers are interested in those messages, and they consume them. But doesn't fit when the messages are Commands.
If we consider a distributed command pattern, however, commands are serialized as messages that asynchronously invoke other services. Commands typically target a service that is known by the invoking component. Instead of a message broker, where multiple services can subscribe, the command is placed into a queue which gets polled regularly by the receiver.
In this scenario treating the message creator as the provider seems counter-intuitive. Instead the message creator is consuming functionality of the command receiver. It is just like the request-response pattern but asynchronous and without a response as there is no back-channel through the queue.
It's similar for Query messages:
Queries describe a request for information or state. A query can have multiple handlers. When dispatching queries, the client indicates whether he wants a result from one or from all available query handlers.
Services containing Query Handlers would be expecting query messages. From Pact's perspective they would be consumers. If different services are interested on that information, a consumer test would need to be written for each service wanting to get the data.
I can't see any real problem with all this, but I'm concerned that tools like can-i-deploy
or CI pipelines have assumptions on the use cases that I'm not aware of.
Does anyone know more about this topic? Any problems I'm not aware of? I'll be using Pact for the JVM and Axon Framework & Server but I feel this is something related to Pact's specification.
Thanks a lot.
Upvotes: 2
Views: 807
Reputation: 661
I have some example (Axon Framework - Spring Boot) of using Pact to test message (commands, events) passing contracts https://github.com/idugalic/axon-contract-testing-demo
Please note that this is a demo. In the real world, you should consider using Pact Broker instead of sharing contracts in the pacts folder, and integrating the Pact broker into your CI.
Upvotes: 2