apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.53k stars 26.44k forks source link

native image run failed when project contains dubbo-native or dubbo-maven-plugin and spring-cloud-starter-stream-rocketmq #13621

Closed imgoby closed 10 months ago

imgoby commented 10 months ago

When the project contains dubbo-native or dubbo-maven-plugin and spring-cloud-starter-stream-rocketmq, the rocketmq client cannot start successfully.

 <dubbo.version>3.3.0-beta.1</dubbo.version>
<spring.cloud.alibaba.version>2022.0.0.0</spring.cloud.alibaba.version>

        <!-- Spring Cloud -->
<spring.cloud.version>2022.0.4</spring.cloud.version>

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

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
        </dependency>

        <!-- add dubbo-native -->
        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-native</artifactId>
        </dependency>

    </dependencies>

 <!-- add dubbo-native -->
            <plugin>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-maven-plugin</artifactId>
                <configuration>
                    <skip>false</skip>
                    <mainClass>com.yuhoutian.stream.demo.StreamApplication</mainClass>
                </configuration>
            </plugin>

demo is here: https://github.com/imgoby/spring-cloud-alibaba-dubbo-native/tree/main/spring-cloud-alibaba-stream-native-image

Main Exception is : org.apache.rocketmq.remoting.exception.RemotingSendRequestException: send request to <192.168.0.211:9876> failed

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.9)

2024-01-06T19:39:52.008+08:00  INFO 31112 --- [           main] c.y.stream.demo.StreamApplication        : Starting AOT-processed StreamApplication using Java 17.0.5 with PID 31112 (/root/spring-cloud-alibaba-dubbo-native/spring-cloud-alibaba-stream-native-image/target/spring-cloud-alibaba-stream-native-image started by root in /root/spring-cloud-alibaba-dubbo-native/spring-cloud-alibaba-stream-native-image/target)
2024-01-06T19:39:52.008+08:00  INFO 31112 --- [           main] c.y.stream.demo.StreamApplication        : No active profile set, falling back to 1 default profile: "default"
2024-01-06T19:39:52.032+08:00  INFO 31112 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9605 (http)
2024-01-06T19:39:52.033+08:00  INFO 31112 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-01-06T19:39:52.033+08:00  INFO 31112 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.11]
2024-01-06T19:39:52.038+08:00  INFO 31112 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-01-06T19:39:52.038+08:00  INFO 31112 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 30 ms
2024-01-06T19:39:52.133+08:00  INFO 31112 --- [           main] o.s.c.s.m.DirectWithAttributesChannel    : Channel 'stream-demo.EVENT_SIMPLE_INPUT0' has 1 subscriber(s).
2024-01-06T19:39:52.140+08:00  INFO 31112 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2024-01-06T19:39:52.140+08:00  INFO 31112 --- [           main] o.s.i.channel.PublishSubscribeChannel    : Channel 'stream-demo.errorChannel' has 1 subscriber(s).
2024-01-06T19:39:52.140+08:00  INFO 31112 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : started bean '_org.springframework.integration.errorLogger'
2024-01-06T19:39:52.142+08:00  INFO 31112 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9605 (http) with context path ''
2024-01-06T19:39:52.142+08:00  INFO 31112 --- [           main] o.s.c.s.binder.DefaultBinderFactory      : Creating binder: rocketmq
2024-01-06T19:39:52.142+08:00  INFO 31112 --- [           main] o.s.c.s.binder.DefaultBinderFactory      : Using AOT pre-prepared initializer to construct binder child context for rocketmq
2024-01-06T19:39:52.160+08:00  INFO 31112 --- [           main] o.s.c.s.binder.DefaultBinderFactory      : Caching the binder: rocketmq
2024-01-06T19:39:52.161+08:00  INFO 31112 --- [           main] o.s.c.stream.binder.BinderErrorChannel   : Channel '1833063023.EVENT_SIMPLE_INPUT0.errors' has 1 subscriber(s).
2024-01-06T19:39:52.161+08:00  INFO 31112 --- [           main] o.s.c.stream.binder.BinderErrorChannel   : Channel '1833063023.EVENT_SIMPLE_INPUT0.errors' has 0 subscriber(s).
2024-01-06T19:39:52.161+08:00  INFO 31112 --- [           main] o.s.c.stream.binder.BinderErrorChannel   : Channel '1833063023.EVENT_SIMPLE_INPUT0.errors' has 1 subscriber(s).
2024-01-06T19:39:52.161+08:00  INFO 31112 --- [           main] o.s.c.stream.binder.BinderErrorChannel   : Channel '1833063023.EVENT_SIMPLE_INPUT0.errors' has 2 subscriber(s).
2024-01-06T19:39:52.170+08:00 ERROR 31112 --- [           main] .s.b.r.i.i.RocketMQInboundChannelAdapter : DefaultMQPushConsumer init failed, Caused by org.apache.rocketmq.remoting.exception.RemotingSendRequestException: send request to <192.168.0.211:9876> failed
2024-01-06T19:39:52.170+08:00 ERROR 31112 --- [           main] o.s.cloud.stream.binding.BindingService  : Failed to create consumer binding; retrying in 30 seconds

org.springframework.cloud.stream.binder.BinderException: Exception thrown while starting consumer: 
    at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:582) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:102) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    at org.springframework.cloud.stream.binder.AbstractBinder.bindConsumer(AbstractBinder.java:144) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    at org.springframework.cloud.stream.binding.BindingService.doBindConsumer(BindingService.java:186) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    at org.springframework.cloud.stream.binding.BindingService.bindConsumer(BindingService.java:139) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    at org.springframework.cloud.stream.binding.AbstractBindableProxyFactory.createAndBindInputs(AbstractBindableProxyFactory.java:98) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    at org.springframework.cloud.stream.binding.InputBindingLifecycle.doStartWithBindable(InputBindingLifecycle.java:58) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    at java.base@17.0.5/java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:647) ~[na:na]
    at org.springframework.cloud.stream.binding.AbstractBindingLifecycle.start(AbstractBindingLifecycle.java:57) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    at org.springframework.cloud.stream.binding.InputBindingLifecycle.start(InputBindingLifecycle.java:34) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:179) ~[spring-cloud-alibaba-stream-native-image:6.0.11]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:357) ~[spring-cloud-alibaba-stream-native-image:6.0.11]
    at java.base@17.0.5/java.lang.Iterable.forEach(Iterable.java:75) ~[spring-cloud-alibaba-stream-native-image:na]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:156) ~[spring-cloud-alibaba-stream-native-image:6.0.11]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:124) ~[spring-cloud-alibaba-stream-native-image:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:958) ~[spring-cloud-alibaba-stream-native-image:6.0.11]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:611) ~[spring-cloud-alibaba-stream-native-image:6.0.11]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-cloud-alibaba-stream-native-image:3.0.9]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-cloud-alibaba-stream-native-image:3.0.9]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-cloud-alibaba-stream-native-image:3.0.9]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[spring-cloud-alibaba-stream-native-image:3.0.9]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304) ~[spring-cloud-alibaba-stream-native-image:3.0.9]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293) ~[spring-cloud-alibaba-stream-native-image:3.0.9]
    at com.yuhoutian.stream.demo.StreamApplication.main(StreamApplication.java:29) ~[spring-cloud-alibaba-stream-native-image:na]
Caused by: org.springframework.messaging.MessagingException: null
    at com.alibaba.cloud.stream.binder.rocketmq.integration.inbound.RocketMQInboundChannelAdapter.doStart(RocketMQInboundChannelAdapter.java:197) ~[na:na]
    at org.springframework.integration.endpoint.AbstractEndpoint.start(AbstractEndpoint.java:155) ~[spring-cloud-alibaba-stream-native-image:6.0.6]
    at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:524) ~[spring-cloud-alibaba-stream-native-image:4.0.4]
    ... 23 common frames omitted
Caused by: java.lang.IllegalStateException: org.apache.rocketmq.remoting.exception.RemotingSendRequestException: send request to <192.168.0.211:9876> failed
    at org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:680) ~[spring-cloud-alibaba-stream-native-image:4.9.4]
    at org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:510) ~[spring-cloud-alibaba-stream-native-image:4.9.4]
    at org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl.updateTopicSubscribeInfoWhenSubscriptionChanged(DefaultMQPushConsumerImpl.java:872) ~[na:na]
    at org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl.start(DefaultMQPushConsumerImpl.java:655) ~[na:na]
    at org.apache.rocketmq.client.consumer.DefaultMQPushConsumer.start(DefaultMQPushConsumer.java:707) ~[na:na]
    at com.alibaba.cloud.stream.binder.rocketmq.integration.inbound.RocketMQInboundChannelAdapter.doStart(RocketMQInboundChannelAdapter.java:189) ~[na:na]
    ... 25 common frames omitted
Caused by: org.apache.rocketmq.remoting.exception.RemotingSendRequestException: send request to <192.168.0.211:9876> failed
    at org.apache.rocketmq.remoting.netty.NettyRemotingAbstract.invokeSyncImpl(NettyRemotingAbstract.java:441) ~[spring-cloud-alibaba-stream-native-image:4.9.4]
    at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:390) ~[na:na]
    at org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:1394) ~[na:na]
    at org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:1384) ~[na:na]
    at org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:623) ~[spring-cloud-alibaba-stream-native-image:4.9.4]
    ... 30 common frames omitted

2024-01-06T19:39:52.171+08:00  INFO 31112 --- [           main] c.y.stream.demo.StreamApplication        : Started StreamApplication in 0.178 seconds (process running for 0.182)
2024-01-06T19:40:22.171+08:00  WARN 31112 --- [   scheduling-1] c.a.c.s.b.r.RocketMQMessageChannelBinder : The provided errorChannel '1833063023.EVENT_SIMPLE_INPUT0.errors' is an instance of DirectChannel, so no more subscribers could be added which may affect DLQ processing. Resolution: Configure your own errorChannel as an instance of PublishSubscribeChannel
2024-01-06T19:40:22.171+08:00  INFO 31112 --- [   scheduling-1] o.s.c.stream.binder.BinderErrorChannel   : Channel 'stream-demo.1833063023.EVENT_SIMPLE_INPUT0.errors' has 1 subscriber(s).
2024-01-06T19:40:22.171+08:00  INFO 31112 --- [   scheduling-1] o.s.c.stream.binder.BinderErrorChannel   : Channel 'stream-demo.1833063023.EVENT_SIMPLE_INPUT0.errors' has 2 subscriber(s).
2024-01-06T19:40:22.171+08:00  INFO 31112 --- [   scheduling-1] o.s.c.stream.binder.BinderErrorChannel   : Channel 'stream-demo.1833063023.EVENT_SIMPLE_INPUT0.errors' has 3 subscriber(s).
2024-01-06T19:40:22.186+08:00 ERROR 31112 --- [   scheduling-1] .s.b.r.i.i.RocketMQInboundChannelAdapter : DefaultMQPushConsumer init failed, Caused by org.apache.rocketmq.remoting.exception.RemotingSendRequestException: send request to <192.168.0.211:9876> failed
2024-01-06T19:40:22.186+08:00 ERROR 31112 --- [   scheduling-1] o.s.cloud.stream.binding.BindingService  : Failed to create consumer binding; retrying in 30 seconds

If I remove the setting as below, I will be OK.

        <plugin>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-maven-plugin</artifactId>
            <configuration>
                <skip>false</skip>
                <mainClass>com.yuhoutian.stream.demo.StreamApplication</mainClass>
            </configuration>
        </plugin>
imgoby commented 10 months ago

It is urgent.Could you check for it? @CrazyHZM

CrazyHZM commented 10 months ago

@imgoby Is dubbo functioning properly except for message errors?

imgoby commented 9 months ago

It was resolved. It cuases by other issue.for example JSON.parseArray() failed. not for dubbo.

imgoby commented 7 months ago

The reason is that the rocketmq-client contains a lower version of fastJSON,for example fastjson 1.2.83,this version of fastjson doesn't support native-image well. check your dependencies and update the fastjson version to

<dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>2.0.31</version>
        </dependency>