question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Springfox 3.0.0 brokes spring-cloud-stream

See original GitHub issue

Please take the time to search the repository, if your question has already been asked or answered.

  • What version of the library are you using? Is it the latest version? The latest released version is Download

Springfox version: 3.0.0

What kind of issue is this?

  • Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests or steps to reproduce get fixed faster. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9
    • spring xml/java config that is relevant
    • springfox specific configuration if it makes sense Not special configuration is applied, just add the springfox dependency
    • include any output you’ve received; logs, json snippets etc.; and what the expected output should be
    • if you have a repo that demonstrates the issue for bonus points! See this example

Springfox version: 3.0.0 Github project: https://github.com/SrMouraSilva/course-spring-microservices/tree/springfox-broken-spring-cloud-stream

What kind of issue is this?

When I add Springfox 3.0.0 dependency, spring-cloud-stream don’t find the Consumers anymore.

Instruction

The code is based on a simplest example (article, video).

# Go to code
git clone https://github.com/SrMouraSilva/course-spring-microservices
cd course-spring-microservices/
git checkout springfox-broken-spring-cloud-stream

# Starts the rabbitmq server with docker
docker run -d --name rabbit -h rabbit -p 5672:5672 -p 15672:15672 rabbitmq:3-management

# Starts a consumer server
cd event-driven/consumer-a-service/
mvn spring-boot:run

In my source code, the Springfox dependency is commented (event-driven/consumer-a-service/pom.xml), then in the log appears:

2020-10-08 11:21:51.134  INFO 86492 --- [           main] o.s.c.f.c.c.SimpleFunctionRegistry       : Looking up function '' with acceptedOutputTypes: []
2020-10-08 11:21:51.141  INFO 86492 --- [           main] o.s.c.f.c.c.SimpleFunctionRegistry       : Looking up function 'callmeEventConsumer' with acceptedOutputTypes: []
2020-10-08 11:21:51.154  INFO 86492 --- [           main] o.s.c.f.c.c.SimpleFunctionRegistry       : Looking up function 'callmeEventConsumer' with acceptedOutputTypes: []
2020-10-08 11:21:51.155  INFO 86492 --- [           main] o.s.c.f.c.c.SimpleFunctionRegistry       : Looking up function 'callmeEventConsumer' with acceptedOutputTypes: []
2020-10-08 11:21:51.303  INFO 86492 --- [           main] o.s.c.s.m.DirectWithAttributesChannel    : Channel 'consumer-a-service.callmeEventConsumer-in-0' has 1 subscriber(s).
2020-10-08 11:21:51.318  INFO 86492 --- [           main] o.s.c.f.c.c.SimpleFunctionRegistry       : Looking up function 'callmeEventConsumer' with acceptedOutputTypes: []
2020-10-08 11:21:51.379  INFO 86492 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2020-10-08 11:21:51.379  INFO 86492 --- [           main] o.s.i.channel.PublishSubscribeChannel    : Channel 'consumer-a-service.errorChannel' has 1 subscriber(s).
2020-10-08 11:21:51.379  INFO 86492 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : started bean '_org.springframework.integration.errorLogger'

But when is uncommeted, appears:

2020-10-08 13:58:30.486  INFO 98308 --- [           main] o.s.c.f.c.c.SimpleFunctionRegistry       : Looking up function '' with acceptedOutputTypes: []

Apparently the dependence on springfox somehow stops the search for Consumer/Function beans carried out by spring-cloud-stream, making it impossible to receive messages.

If you wish, I can do a simpler project that will test the problem.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
garyrussellcommented, Oct 12, 2020

This is because springfox registers a Supplier @Bean:

inMemorySwaggerResourcesProvider=springfox.documentation.swagger.web.InMemorySwaggerResourcesProvider@4cad79bc

spring-cloud-stream can only work without configuration if exactly one Function<?>, Consumer<?> or Supplier<?> bean exists.

Since it can’t disambiguate, no binding is implied.

You have to add the property spring.cloud.function.definition=consumerMethodName to indicate which method(s) to bind.

2reactions
zongweiyangcommented, May 31, 2022

@opcooc I was having a problem with the production of messages in the topic inMemorySwaggerResourcesProvider-out-0. As explained by @garyrussell, I got the solution by registering the default supplier like this:

@Configuration
public class DisableProducerInMemorySwaggerResourcesProvider {
    
    @Bean
    public Supplier<Message<String>> defaultSupplierProducer() {
        return () -> {
            return null;
        };
    }
    
}

solve my problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Springfox 3.0.0 is not working with Spring Boot 2.6.0 [duplicate]
Up to now, Springfox 3.0.0 only works with Spring 2.6.0-M2 but not with versions above. See the open Springfox issue ...
Read more >
Spring Cloud Stream Reference Guide
A Spring Cloud Stream application consists of a middleware-neutral core. The application communicates with the outside world through input and output channels ...
Read more >
spring-cloud/spring-cloud-stream - Gitter
Hello, I'm having a problem to synchronise a producer with a DataSourceTransactionManager, I'm consuming a message through a StreamListener with an interaction ...
Read more >
Springfox Reference Documentation - GitHub Pages
repositories { jcenter() } dependencies { // For Spring boot Projects implementation "io.springfox:springfox-boot-starter:3.0.0" ...
Read more >
SpringFox Release 3.0.0 (finally!) : r/java - Reddit
r/java - SpringFox Release 3.0.0 (finally!) ... promised fixing a certain issue (only documented in github issues) broke other things again.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found