'Spring-Cloud-Stream-Rabbit lead to netty fails to start

They can't work together,way ? In fact, the port is not occupied.Using Netty tcp to connect port 58888 (or change to any other port) it (Netty) is not working. When I don't use SpringCloudStream, netty can start normally.

netty startup error : "java.net.BindException: Address already in use: bind"

--------------------------------Part Maven-----------------------------------

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>2.6.7</version>
  </dependency>

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
    <version>3.2.2</version>
</dependency>

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>4.1.75.Final</version>
</dependency>

--------------------------------Config-----------------------------------

  rabbitmq:
    host: 192.168.31.248
    port: 5672
    username: rabbit
    password: 123456
    virtual-host: /
  cloud:
    stream:
      bindings:
        sms-out-0:
          destination: sms-exchange

--------------------------------Consumer-----------------------------------

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import java.util.function.Consumer;

@Component
public class SmsConsumer {
    
    @Bean
    public Consumer<String> sms() {
        return System.out::println;
    }
}

--------------------------------Producer-----------------------------------

import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

@Component
public class SmsProducer{
    
    @Resource
    private StreamBridge streamBridge;
    
    public void send(String message) {
        streamBridge.send("sms-out-0" , message);
    }
}

Why is no one having this problem, I don't understand why there are no results..............

-----The follow-up is coming, with new progress!!!!!!!!!!!!!

When I removed the Consumer, Netty started normally. It seems that this problem has nothing to do with the port, and I still don't understand the reason.

import org.springframework.stereotype.Component;

@Component
public class SmsConsumer {
    
//    @Bean
//    public Consumer<String> sms() {
//        return System.out::println;
//    }
}

When I noticed that the official documentation has tips to avoid confusion made the following changes

  rabbitmq:
    host: 192.168.31.248
    port: 5672
    username: rabbit
    password: 123456
    virtual-host: /
  cloud:
    function:
      definition: sms
    stream:
      function:
        autodetect: false
      bindings:
        sms-out-0:
          destination: sms-exchange

Spring Cloud Stream official documentation has tips to avoid confusion

But the problem persists and I can't solve it

netty startup error images



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source