Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pub/Sub is giving Deadline Exceeded error

I am trying to publish multiple message at time (around 50) but Pub/Sub is giving is Deadline Exceeded at /user_code/node_modules/@google-cloud/pubsub/node_modules/grpc/src/client.js:55 error.

const pubsub = PubSub();        
const topic = pubsub.topic('send_wishes');  
const publisher = topic.publisher();

//data is dictionary object 
    Object.keys(data).forEach(function(key){
                    var userObj = data[key];
                        const dataBuffer = Buffer.from(JSON.stringify(userObj));
                        const publisher = topic.publisher();
                        publisher.publish(dataBuffer)
                        .then((results) => {
                          const messageId = results[0];
                          console.log(`Message ${messageId} published.`);
                          return;
                        });
        })

For single message it's working fine. For batching I try the batch configuration of publisher but it is also not working

const publisher = topic.publisher({
            batching: {
              maxMessages: 15,
              maxMilliseconds: 2000
            }
          });
like image 918
Muhammad chhota Avatar asked Oct 29 '22 21:10

Muhammad chhota


1 Answers

Once creating subscription please change Acknowledgement Deadline of subscription time for default 10 sec to 100 sec.

like image 156
Suman Sarkar Avatar answered Nov 08 '22 04:11

Suman Sarkar