简体   繁体   中英

Java: Consumer-Driven Contracts for non-RESTful APIs

I would like to implement consumer-driven contracts in my Spring Boot micro-services.

However, not all services are RESTful. Some of them use proprietary communication protocols. Some of them do not have Java API implemented by me. For all these service, I have written a "java client" library, which I include in the consumers as a dependency, and that way I aid integration.

Could you please tell me if there exists an extension to Spring Cloud Contract, or an alternative Java implementation of Consumer-Driven Contracts which have stub and tests generation for POJO classes or Spring Boot services out of the contract, the same way this is done for the RESTful APIs?

What you can do is call the API via a proxy and generate stubs of it. You can check out an example of such a flow here https://github.com/marcingrzejszczak/the-legacy-app/tree/master/stubs_with_proxy/

With such an approach, your communication with the service you don't own will be recorded and can be later reused as a stub.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM