Hello, I am trying to implement a Synchronous mes...
# pact-jvm
r
Hello, I am trying to implement a Synchronous message pact interaction. Where the consumer uses messaging to send a request message (command) and expects a response message back. The request body uses a field that is a value from the provider state. However when processing the message in the provider, then we do not receive the provider state variable in the message, but the example from the Consumer pact.
Copy code
@PactVerifyProvider("A command message")
    public MessageAndMetadata processCommand(MessageContents messageContents) {
        var jsonMessage = messageContents.getContents().valueAsString();
        // this json message does not have the provider state applied
        // instead it contains the example value provided by the consumer...

    }
I tried to look for examples in the pact SDK, but could not really find any. Am I doing this in the right way? Is provider state supported in message pacts?
One workaround that I now use is to generate a providerState map copy in my test, and use the following to regenerate the message contents:
Copy code
var generated = DefaultResponseGenerator.INSTANCE
                .generateContents(messageContents,
                        Map.of("providerState", providerState),
                        GeneratorTestMode.Provider,
                        List.of(), Map.of(), true);
I would have expected the Pact SDK to have already applied this before calling the
@PactVerifyProvider
method