I'm finding this question incomplete without proper usage example of how things should be set up.
Since op did not mention target language I'm feeling like to share Kotlin setup that works in my case:
build.gradle.kts
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("com.playtika.reactivefeign:feign-reactor-core:3.2.1")
implementation("com.playtika.reactivefeign:feign-reactor-spring-configuration:3.2.1")
implementation("com.playtika.reactivefeign:feign-reactor-webclient:3.2.1")
Config.kt
@Configuration
@EnableWebFlux
@EnableReactiveFeignClients
class Config {
}
MyFeignClient.kt
@Component
@ReactiveFeignClient(
url = "\${package.service.my-service-url}",
name = "client"
)
interface MyFeignClient {
@GetMapping(value = ["/my/url?my_param={my_value}"], consumes = ["application/json"])
fun getValues(
@PathVariable(name = "my_value") myValue: String?,
): Mono<MyEntity?>?
}
Then here goes code in some service class:
val myClient: MyFeignClient = WebReactiveFeign.builder<MyFeignClient>()
.contract(ReactiveContract(SpringMvcContract()))
.target(MyFeignClient::class.java, "http://example.com")
// feel free to add .block() to get unpacked value or just chain your logic further
val response = myClient.getValues(param)
Answer from im_infamous on Stack OverflowI'm finding this question incomplete without proper usage example of how things should be set up.
Since op did not mention target language I'm feeling like to share Kotlin setup that works in my case:
build.gradle.kts
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("com.playtika.reactivefeign:feign-reactor-core:3.2.1")
implementation("com.playtika.reactivefeign:feign-reactor-spring-configuration:3.2.1")
implementation("com.playtika.reactivefeign:feign-reactor-webclient:3.2.1")
Config.kt
@Configuration
@EnableWebFlux
@EnableReactiveFeignClients
class Config {
}
MyFeignClient.kt
@Component
@ReactiveFeignClient(
url = "\${package.service.my-service-url}",
name = "client"
)
interface MyFeignClient {
@GetMapping(value = ["/my/url?my_param={my_value}"], consumes = ["application/json"])
fun getValues(
@PathVariable(name = "my_value") myValue: String?,
): Mono<MyEntity?>?
}
Then here goes code in some service class:
val myClient: MyFeignClient = WebReactiveFeign.builder<MyFeignClient>()
.contract(ReactiveContract(SpringMvcContract()))
.target(MyFeignClient::class.java, "http://example.com")
// feel free to add .block() to get unpacked value or just chain your logic further
val response = myClient.getValues(param)
You can check this library: https://github.com/Playtika/feign-reactive
implementation of Feign on Spring WebClient. Brings you the best of two worlds together: concise syntax of Feign to write client-side API on fast, asynchronous and non-blocking HTTP client of Spring WebClient