JanYork opened a new issue, #8133:
URL: https://github.com/apache/rocketmq/issues/8133

   ### Before Creating the Bug Report
   
   - [X] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   
   - [X] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/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
   
   Macos
   
   ### RocketMQ version
   
   5.1.x
   
   ### JDK Version
   
   _No response_
   
   ### Describe the Bug
   
   Two questions:
   1. For the messages I produce, the consumer occasionally loses the first 
message.
   2. nodejs client threw an error: `Cannot invoke 
"apache.rocketmq.v2.Settings.getSubscription()" because "settings" is null. 
NullPointerException. 
org.apache.rocketmq.proxy.grpc.v2.consumer.ReceiveMessageActivity 
.receiveMessage(ReceiveMessageActivity.java:63)`
   
   
   I used the SimpleConsumer of the nodejs client to receive messages and found 
that the messages I produced were not received.
   
   This is my producer, it is sequential, and the topic type is also FIFO:
   ```js
   import { Producer } from 'rocketmq-client-nodejs';
   
   const producer = new Producer({
       endpoints: '192.168.1.162:8081',
   });
   
   (async () => {
       await producer.startup();
   
       for (let i = 1; i <= 5; i++) {
           await producer.send({
               messageGroup: 'checkout-group',
               topic: 'checkout-topic-fifo',
               tag: 'checkout',
               keys: ['checkout-key'],
               body: Buffer.from("Hello World:"+i.toString())
           }).then(() => {
               console.log('message %d sent', i);
               console.log('checkout:send message success!');
           }).catch((e) => {
               console.error(e);
           });
       }
   
       process.exit(0);
   })()
   ```
   
   Here is my consumer, which simulates a situation where I am constantly 
listening for messages and receiving them:
   ```js
   import { SimpleConsumer } from 'rocketmq-client-nodejs';
   
   const simpleConsumer = new SimpleConsumer({
       consumerGroup: 'checkout-group',
       endpoints: '127.0.0.1:8081',
       subscriptions: new Map().set('checkout-topic-fifo', '*'),
   });
   
   (async () => {
       await simpleConsumer.startup();
   
       async function consumeMessages(){
           try {
               const messages = await simpleConsumer.receive(1);
   
               if (messages.length > 0) {
                   console.log('got %d messages', messages.length);
   
                   for (const message of messages) {
                       console.log('body=%o', message.body.toString());
                       await simpleConsumer.ack(message);
                   }
               } else {
                   console.log('No messages received, waiting...');
               }
           } catch (error) {
               console.error('An error occurred:', error);
           } finally {
               console.log('waiting for messages...');
               await consumeMessages();
           }
       }
   
       await consumeMessages();
   })()
   ```
   
   I will only get one message at a time, that is to say, it should be received 
sequentially. When I sent 5 messages sequentially, my consumer did not receive 
the first piece of data, but 2-5 were successfully received. .
   I need to wait for a long time to receive the first one (or the retry 
mechanism), and this is a random phenomenon, and the first data sent is lost 
inexplicably.
   
   The second problem is that nodejs client will have an error for no reason in 
my above message listening code:
   ```
   An error occurred: InternalErrorException: [request-id=undefined, 
response-code=50001] Cannot invoke 
"apache.rocketmq.v2.Settings.getSubscription()" because "settings" is null. 
NullPointerException. 
org.apache.rocketmq.proxy.grpc.v2.consumer.ReceiveMessageActivity.receiveMessage(ReceiveMessageActivity.java:63)
       at StatusChecker.check 
(/Users/muyouzhi/Code/demo/html-demo/node_modules/.pnpm/rocketmq-client-nodejs@1.0.0/node_modules/rocketmq-client-nodejs/dist/exception/StatusChecker.js:83:23)
       at SimpleConsumer.receiveMessage 
(/Users/muyouzhi/Code/demo/html-demo/node_modules/.pnpm/rocketmq-client-nodejs@1.0.0/node_modules/rocketmq-client-nodejs/dist/consumer/Consumer.js:64:35)
       at process.processTicksAndRejections 
(node:internal/process/task_queues:95:5)
       at async SimpleConsumer.receive 
(/Users/muyouzhi/Code/demo/html-demo/node_modules/.pnpm/rocketmq-client-nodejs@1.0.0/node_modules/rocketmq-client-nodejs/dist/consumer/SimpleConsumer.js:95:16)
       at async consumeMessages 
(/Users/muyouzhi/Code/demo/html-demo/dist/test/c.js:13:30)
       at async consumeMessages 
(/Users/muyouzhi/Code/demo/html-demo/dist/test/c.js:30:13)
       at async consumeMessages 
(/Users/muyouzhi/Code/demo/html-demo/dist/test/c.js:30:13)
       at async consumeMessages 
(/Users/muyouzhi/Code/demo/html-demo/dist/test/c.js:30:13)
       at async consumeMessages 
(/Users/muyouzhi/Code/demo/html-demo/dist/test/c.js:30:13)
       at async consumeMessages 
(/Users/muyouzhi/Code/demo/html-demo/dist/test/c.js:30:13) {
     code: 50001
   }
   ```
   
   ### Steps to Reproduce
   
   It's very simple. Use nodejs client to run a consumer to continuously listen 
for messages, and then run a producer to send multiple messages. The Topic type 
is FIFO.
   If the problem does not occur, try closing and running it again. Sometimes 
it takes many attempts to reproduce the problem.
   
   ### What Did You Expect to See?
   
   I should receive the first piece of data.
   
   ### What Did You See Instead?
   
   The first piece of data is often lost.
   
   ### Additional Context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to