spring-cloud / spring-cloud-contract

Support for Consumer Driven Contracts in Spring
https://cloud.spring.io/spring-cloud-contract
Apache License 2.0
719 stars 438 forks source link

Specify routing key for Pact contracts #1613

Closed EvgheniiShipilov closed 10 months ago

EvgheniiShipilov commented 3 years ago

Spring Cloud Contract allows converting Pact contracts and specifying the destination exchange as a sentTometadata 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.

marcingrzejszczak commented 3 years ago

Shouldn't this issue be created in the Pact project?

EvgheniiShipilov commented 3 years ago

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.

marcingrzejszczak commented 3 years ago

No, I'm talking about fixing it properly in the Pact specification first and only then fix it here.

EvgheniiShipilov commented 3 years ago

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.

marcingrzejszczak commented 3 years ago

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?

EvgheniiShipilov commented 3 years ago

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:

marcingrzejszczak commented 2 years ago

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.

marcingrzejszczak commented 10 months ago

Pact support was dropped.