rocketmq5.0消费者启动报错provider.newPushConsumerBuilder().buil[阿里云消息队列MQ]

Exception in thread “main” java.lang.reflect.InvocationTargetException

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:498)

    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)

    at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)

    at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)

    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)

Caused by: java.lang.IllegalStateException: Expected the service PushConsumerImpl [FAILED] to be RUNNING, but the service has FAILED

    at org.apache.rocketmq.shaded.com.google.common.util.concurrent.AbstractService.checkCurrentState(AbstractService.java:381)

    at org.apache.rocketmq.shaded.com.google.common.util.concurrent.AbstractService.awaitRunning(AbstractService.java:305)

    at org.apache.rocketmq.shaded.com.google.common.util.concurrent.AbstractIdleService.awaitRunning(AbstractIdleService.java:165)

    at org.apache.rocketmq.client.java.impl.consumer.PushConsumerBuilderImpl.build(PushConsumerBuilderImpl.java:128)

    at com.osd.ynwrkj.OrganizationApplication.main(OrganizationApplication.java:57)

    … 8 more

Caused by: java.lang.NullPointerException

    at org.apache.rocketmq.client.java.impl.consumer.PushConsumerImpl.shutDown(PushConsumerImpl.java:190)

    at org.apache.rocketmq.client.java.impl.consumer.PushConsumerImpl.startUp(PushConsumerImpl.java:178)

    at org.apache.rocketmq.shaded.com.google.common.util.concurrent.AbstractIdleService$DelegateService$1.run(AbstractIdleService.java:62)

    at org.apache.rocketmq.shaded.com.google.common.util.concurrent.Callables.lambda$threadRenaming$3(Callables.java:103)

    at java.lang.Thread.run(Thread.java:750)

「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!
=====这是一个广告位,招租中,联系qq 78315851====
1 条回复 A 作者 M 管理员
  1. @EnableDiscoveryClient@EnableFeignClients@SpringBootApplicationpublic class  OrganizationApplication {    public static void main(String[] args) throws InterruptedException, IOException, ClientException, ClientException {        SpringApplication.run(OrganizationApplication.class, args);        final ClientServiceProvider provider = ClientServiceProvider.loadService();        // Credential provider is optional for client configuration.        String accessKey = "";        String secretKey = "";        String endpoints = "192.168.1.46:8081";        ClientConfiguration clientConfiguration = ClientConfiguration.newBuilder()                .setEndpoints(endpoints)                .build();        String tag = "";        FilterExpression filterExpression = new FilterExpression(tag, FilterExpressionType.TAG);        String consumerGroup = "please_rename_unique_group_name_4";        String topic = "VENDING_DEVICE_TOPIC";        PushConsumer pushConsumer = provider.newPushConsumerBuilder()                .setClientConfiguration(clientConfiguration)                // Set the consumer group name.                .setConsumerGroup(consumerGroup)                // Set the subscription for the consumer.                .setSubscriptionExpressions(Collections.singletonMap(topic, filterExpression))                .setMessageListener(messageView -> {                    // Handle the received message and return consume result.                    ByteBuffer body = messageView.getBody();                    String resultJson = StandardCharsets.UTF_8.decode(body).toString();                    System.out.println("消息监听"+resultJson);                    return ConsumeResult.SUCCESS;                })                .build();    }}

  2. https://developer.aliyun.com/ask/480595?spm=5176.21213303.J_6704733920.10.795953c9ALCbGh&scm=20140722.S_community%40%40%E9%97%AE%E7%AD%94%40%40480595._.ID_community%40%40%E9%97%AE%E7%AD%94%40%40480595-RL_PushConsumerImpl-LOC_main-OR_ser-V_2-P0_1

    这里有个同样的问题呢,我看到有人回答了:

    根据错误信息来看的话,首先来看最明显的错误信息java.lang.NullPointerException,在PushConsumerImpl.java类的190行报空指针异常,也就是程序在执行PushConsumerImpl.shutDown()的时候报空指针,那么首先你检查一下PushConsumerImpl对象是否为空,debug排查程序中什么操作导致PushConsumerImpl对象为空。

    如果没有解决问题,能不能把代码段po一下看看呢?