-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I use Pact V4 Synchronous Messages to write contract tests for Kafka with request-response pattern? #1681
Comments
Can you try one of the 4.4.x or 4.5.x versions, instead of 4.3.x? I see you have |
I tried with:
Exception throwed from ProviderVerifier class
Exception throwed from TestTarget class:
|
looks like because of class SynchronousMessages in V4Interaction not implement interface MessageInteraction in 4.5.3 version |
I am also facing this issue in 4.5.4. The only difference is that I use AMQP and PactBroker. The exception is thrown on this line https://github.com/pact-foundation/pact-jvm/blob/4_5_4/provider/junit5/src/main/kotlin/au/com/dius/pact/provider/junit5/TestTarget.kt#L194 Do you have any suggestions? |
👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-889). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps. |
…ssages with MessageTestTarget #1681
I've added support for V4 Synchronous Messages with the MessageTestTarget. @akadnikov, I have also tested your example with the change and it works. You will also not need to store the interaction in the test, you can just add a parameter to the message method: @SneakyThrows
@PactVerifyProvider("a test message")
public MessageAndMetadata messageRecievedAndCreated(MessageContents requestMessage) {
var req = MyMessageHandler.getRequest(requestMessage.getContents().valueAsString());
Message<String> message = MyMessageBuilder.createResponse(req);
return generateMessageAndMetadata(message);
} |
It works with |
It works. Thank you. |
Hi!
I am trying to figure out how to use Pact when services communicate over Kafka and use the request-reply pattern.
(request-reply pattern https://callistaenterprise.se/blogg/teknik/2018/10/26/synchronous-request-reply-over-kafka/)
I use simple test project: https://github.com/akadnikov/spring-kafka-request-reply/blob/main/readme.md
i tried to write a consumer test using V4 with the Synchronous/Messages Pact type
(according to the example https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit5/src/test/groovy/au/com/dius/pact/consumer/junit5/V4SyncMessageTest.groovy)
It seems to work fine.
Here is the consumer test class:
https://github.com/akadnikov/spring-kafka-request-reply/blob/57473f5c8cd468cbd92e1dc768c6eb3f9d0ff215/spring-kafka-client/src/test/java/com/techgalery/springkafkaclient/PactTest.java#L27
And pact:
https://github.com/akadnikov/spring-kafka-request-reply/blob/57473f5c8cd468cbd92e1dc768c6eb3f9d0ff215/spring-kafka-server/pact/pactflow-example-consumer-java-kafka-pactflow-example-provider-java-kafka.json#L1
But when I run test on provider side I faced with exception:
Here is the provider test class:
https://github.com/akadnikov/spring-kafka-request-reply/blob/57473f5c8cd468cbd92e1dc768c6eb3f9d0ff215/spring-kafka-server/src/test/java/com/techgalery/springkafkaserver/ProductsKafkaProducerTest.java#L25
I've not found any examples for V4 with the Synchronous/Messages Pact tests on the provider side. If there are, I'd be grateful for the links.
Can I use Pact V4 Synchronous Messages to write contract test for Kafka with request-reply pattern or is there a better option? If yes, what am I doing wrong?
Thanks in advance.
The text was updated successfully, but these errors were encountered: