rocketmq icon indicating copy to clipboard operation
rocketmq copied to clipboard

[Bug] A null pointer error occurs when SimpleConsumer calls the get message method.

Open JanYork opened this issue 1 year ago • 9 comments

Before Creating the Bug Report

  • [X] I found a bug, not just asking a question, which should be created in GitHub Discussions.

  • [X] I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.

  • [X] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.

Runtime platform environment

From the official docker image.

RocketMQ version

From the official docker image 5.3.0.

JDK Version

From the official docker image.

Describe the Bug

InternalErrorException: [request-id=undefined, response-code=50001] null. NullPointerException. org.apache.rocketmq.proxy.grpc.v2.consumer.ReceiveMessageActivity.receiveMessage(ReceiveMessageActivity.java:63)
    at Function.check (/Users/muyouzhi/Code/nest-mq/node_modules/.pnpm/[email protected]/node_modules/rocketmq-client-nodejs/src/exception/StatusChecker.ts:81:15)
    at SimpleConsumer.receiveMessage (/Users/muyouzhi/Code/nest-mq/node_modules/.pnpm/[email protected]/node_modules/rocketmq-client-nodejs/src/consumer/Consumer.ts:78:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at SimpleConsumer.receive (/Users/muyouzhi/Code/nest-mq/node_modules/.pnpm/[email protected]/node_modules/rocketmq-client-nodejs/src/consumer/SimpleConsumer.ts:122:12)
    at consumer (/Users/muyouzhi/Code/nest-mq/src/main.ts:40:22) {
  code: 50001
}

Steps to Reproduce

async function production(message: string) {
  const receipt = await producer.send({
    topic: 'kitchen',
    messageGroup: '1',
    body: Buffer.from(
      JSON.stringify({
        message,
        now: Date(),
      }),
    ),
  });
  console.log(receipt);
}

async function consumer() {
  const simpleConsumer = new SimpleConsumer({
    consumerGroup: '1',
    endpoints: '127.0.0.1:8081',
    subscriptions: new Map().set('kitchen', '*'),
  });
  await simpleConsumer.startup();

  while (true) {
    const messages = await simpleConsumer.receive(10);

    if (!messages.length) {
      continue;
    }

    for (const message of messages) {
      console.log('message=%o', message);
      console.log('body=%o', message.body.toString());
      await simpleConsumer.ack(message);
    }
  }
}
function main() {
    production('hello world')
    consumer()
}
main()

This is almost a very basic operation. I did nothing but run the consumer according to the documentation and keep getting messages. It was normal at the beginning, but after running for 2-3 minutes, this error occurred. I don’t know why this error occurred. Can anyone reply to me if this is a bug? The maintainers are too busy and I have not been able to solve this problem.

What Did You Expect to See?

Normal operation.

What Did You See Instead?

It was working normally at the beginning, but after 2 to 3 minutes, my consumer could not get the message and it would just return an error to me.

Additional Context

No response

JanYork avatar Oct 12 '24 07:10 JanYork

Did you check out this ? https://github.com/apache/rocketmq-client-nodejs/tree/master

kaustubhdeokar avatar Oct 12 '24 12:10 kaustubhdeokar

Did you check out this ? https://github.com/apache/rocketmq-client-nodejs/tree/master

I'm using a client from rocketmq-client's repository who is based on grpc, I'm using version 5.3.0.

JanYork avatar Oct 12 '24 13:10 JanYork

Did you check out this ? https://github.com/apache/rocketmq-client-nodejs/tree/master

Thank you, I hope to get your help live, I'll add what I know:

I deployed rocketmq version 5.3.0 using docker-compose with NameServe, Broker and Rocketmq-Proxy for grpc protocol support.

I used the client from the nodejs version of the client from Apache's official repository (rocketmq-client).

I followed the documentation for the nodejs client to create a consumer persistence method and a production message method.

At first it was working fine and the persistence was running for about 2~3 minutes with this error I mentioned.

I realized that the error is coming from the server side and not the client side, it seems to be an error message coming back from the broker/proxy.

JanYork avatar Oct 12 '24 13:10 JanYork

I also encountered the same problem, how to resolve it?

jack-kang-yi avatar Nov 19 '24 01:11 jack-kang-yi

I also encountered the same problem, how to resolve it?

I haven't solved this problem yet, I found this problem since August and fed back several times but no response, I've given up using nodejs to connect to rocketmq, if you find a solution, I hope you'll let me know, thanks.

JanYork avatar Nov 29 '24 12:11 JanYork

I also encountered the same problem, how to resolve it?

I haven't solved this problem yet, I found this problem since August and fed back several times but no response, I've given up using nodejs to connect to rocketmq, if you find a solution, I hope you'll let me know, thanks.

This is heartbeat interval time, https://github.com/apache/rocketmq-clients/issues/745 say this bug and there is a code fix but not release a new version in npm, you can fix it locally。

lascion avatar Dec 05 '24 11:12 lascion

I also encountered the same problem, how to resolve it?

I haven't solved this problem yet, I found this problem since August and fed back several times but no response, I've given up using nodejs to connect to rocketmq, if you find a solution, I hope you'll let me know, thanks.

This is heartbeat interval time, https://github.com/apache/rocketmq-clients/issues/745 say this bug and there is a code fix but not release a new version in npm, you can fix it locally。

Okay, thanks. I'll try it.

JanYork avatar Dec 05 '24 13:12 JanYork

The latest version still has this problem.

0xDing avatar Apr 12 '25 20:04 0xDing

The latest version still has this problem.

Did you solve it? I've given up on this, but I'd like to know the solution.

JanYork avatar Apr 22 '25 09:04 JanYork