spring-cloud-contract
spring-cloud-contract copied to clipboard
Specify routing key for Pact contracts
Spring Cloud Contract allows converting Pact contracts and specifying the destination exchange as a sentTo
metadata entry(part of MessagingSCContractCreator
class). However there is no way to work with routing keys (as opposed to pure Spring Cloud Contracts approach that allows to specify an amqp_receivedRoutingKey
header).
A possible solution would be adding an optional metadata routingKey
metadata field along the sentTo
entry.
I've also tried specifying directly the amqp_receivedRoutingKey
header, however it wasn't picked up and it seemed a messier solution.
Shouldn't this issue be created in the Pact project?
Shouldn't this issue be created in the Pact project?
Do you mean there's a separate Spring Pact project? If so could you please point me to the correct repo?
If you mean the basic Pact specification- I agree there's no way to use routing keys there now. However there's no exchange specification either. It would make sense to add routing keys as well if we have the "sendTo" destination.
No, I'm talking about fixing it properly in the Pact specification first and only then fix it here.
I'm not quite sure what has to be fixed. According to specification both destination and routing key are specified using metadata. Destination is currently taken directly from metadata. Routing key is ignored although both are specified in the same way.
Ok I'm completely lost. In your opinion should we do anything in Spring Cloud Contract or not? We're delegating fork to Pact so should Pact upgrade the way they deal with messaging?
I'm not an expert, but my opinion is that yes, some changes have to be applied to Spring Cloud Contract. I see that as adding a new metadata key for "Routing Key" and extracting it in the same way as it's currently done with "Send To" destination key.
Let me reiterate my context:
- I see that PACT itself supports routing keys(ex. see this reply).
- I also see that Spring Cloud Contract supports routing keys (see documentation)
- The missing piece is that Spring Cloud Contract does not extract routing keys for pact contracts, which means the right place to implement it is there.
Are you willing to provide a PR to extend the current behaviour? We could leverage the existing amqp_receivedRoutingKey
property and remap it to Pact's routing keys.
Pact support was dropped.