spring-cloud-contract icon indicating copy to clipboard operation
spring-cloud-contract copied to clipboard

Specify routing key for Pact contracts

Open EvgheniiShipilov opened this issue 4 years ago • 7 comments

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.

EvgheniiShipilov avatar Feb 17 '21 17:02 EvgheniiShipilov

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

marcingrzejszczak avatar Feb 17 '21 18:02 marcingrzejszczak

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.

EvgheniiShipilov avatar Feb 18 '21 16:02 EvgheniiShipilov

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

marcingrzejszczak avatar Feb 18 '21 16:02 marcingrzejszczak

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.

EvgheniiShipilov avatar Feb 23 '21 13:02 EvgheniiShipilov

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?

marcingrzejszczak avatar Feb 24 '21 08:02 marcingrzejszczak

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.

EvgheniiShipilov avatar Feb 24 '21 08:02 EvgheniiShipilov

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 avatar Apr 12 '22 07:04 marcingrzejszczak

Pact support was dropped.

marcingrzejszczak avatar Dec 14 '23 10:12 marcingrzejszczak