Skip to content

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

@JanYork

Description

@JanYork

Before Creating the Bug Report

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

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

  • 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/rocketmq-client-nodejs@1.0.0/node_modules/rocketmq-client-nodejs/src/exception/StatusChecker.ts:81:15)
    at SimpleConsumer.receiveMessage (/Users/muyouzhi/Code/nest-mq/node_modules/.pnpm/rocketmq-client-nodejs@1.0.0/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/rocketmq-client-nodejs@1.0.0/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions