apache / rocketmq-docker

Apache RocketMQ Docker
https://rocketmq.apache.org/
Apache License 2.0
683 stars 249 forks source link

error Caused by: java.util.concurrent.CancellationException: Task was cancelled. #90

Open HFFZZZ opened 1 year ago

HFFZZZ commented 1 year ago

Why do I have no problem executing quickstart environment inside docker when I start docker, but I use java client to connect, there will be this exception, ask for help

java public static void main(String[] args) throws ClientException, IOException, InterruptedException { final ClientServiceProvider provider = ClientServiceProvider.loadService(); // 接入点地址,需要设置成Proxy的地址和端口列表,一般是xxx:8081;xxx:8081。 String endpoints = "xx.xx.xx.xx:8081"; ClientConfiguration clientConfiguration = ClientConfiguration.newBuilder() .setEndpoints(endpoints) .build(); // 订阅消息的过滤规则,表示订阅所有Tag的消息。 String tag = "*"; FilterExpression filterExpression = new FilterExpression(tag, FilterExpressionType.TAG); // 为消费者指定所属的消费者分组,Group需要提前创建。 String consumerGroup = "YourConsumerGroup"; // 指定需要订阅哪个目标Topic,Topic需要提前创建。 String topic = "TestTopic"; // 初始化PushConsumer,需要绑定消费者分组ConsumerGroup、通信参数以及订阅关系。 PushConsumer pushConsumer = provider.newPushConsumerBuilder() .setClientConfiguration(clientConfiguration) // 设置消费者分组。 .setConsumerGroup(consumerGroup) // 设置预绑定的订阅关系。 .setSubscriptionExpressions(Collections.singletonMap(topic, filterExpression)) // 设置消费监听器。 .setMessageListener(new MessageListener() { @OverRide public ConsumeResult consume(MessageView messageView) { System.out.println(messageView.toString()); ByteBuffer body = messageView.getBody(); String strbody =new String(body.array()); System.out.println(strbody); //return ConsumeResult.SUCCESS; return null; } }) .build(); //Thread.sleep(Long.MAX_VALUE); // 如果不需要再使用 PushConsumer,可关闭该实例。 // pushConsumer.close(); }

error Caused by: java.util.concurrent.CancellationException: Task was cancelled. at org.apache.rocketmq.shaded.com.google.common.util.concurrent.AbstractFuture.cancellationExceptionWithCause(AbstractFuture.java:1543) at org.apache.rocketmq.shaded.com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:586) at org.apache.rocketmq.shaded.com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:567) at org.apache.rocketmq.shaded.com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91) at org.apache.rocketmq.client.java.impl.ClientImpl.startUp(ClientImpl.java:188) at org.apache.rocketmq.client.java.impl.consumer.PushConsumerImpl.startUp(PushConsumerImpl.java:161) 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.base/java.lang.Thread.run(Thread.java:833)

HappyAxin commented 1 year ago

Did you solve it? I'm having the same problem now.

dingshuangxi888 commented 11 months ago

When using a proxy, please confirm whether the server's port 8081 is open to external connections.

canghailan commented 8 months ago

用docker部署rocketmq遇到了同样的问题,启动broker时去掉--enable-proxy,独立部署proxy就没有问题了

rocketmq-v5-x-caused-by-java-util-concurrent-cancellationexception-task-was-ca

darkingG commented 4 months ago

rocketmq5.2.0,在conf/rmq-proxy.json文件加上"remotingListenPort": 8080属性解决

Li-x-r commented 3 months ago

remotingListenPort和grpcServerPort需配置,docker环境下,映射端口和remotingListenPort和grpcServerPort需一致