BBC Consumer SQS Issues

耗尽温柔 提交于 2020-01-17 01:10:29

问题


I'm using the sqs-consumer node module package.

I have the following code:

 init: function () {
        var app = Consumer.create({
            queueUrl: Settings.getSetting("sendgrid-aws-sqs-queue"),
            batchSize: 1,
            visibilityTimeout: 30,
            waitTimeSeconds: 20,
            sqs: MarvelAWS.sqs,
            handleMessage: function (message, done) {
                try {
                    var msgBody;

                    try {
                        msgBody = JSON.parse(message.Body);
                    } catch (err) {
                        msgBody = null;
                        this._warn("parsing error handling SQS queue " + err, msgBody);
                    }

                    var environment = Settings.getSetting('environment');

                    if (validateMsg(msgBody) && (environment !== "prod" || this.LIST_TO_ID[msgBody.listId.toString()])) {

                        var userProfile = msgBody.profile,
                            timeSent = msgBody.timeSent,
                            action = msgBody.action,
                            listId = msgBody.listId.toString(),
                            suppressionListId = msgBody.suppressionListId.toString();

                        _.each(this.actionsMap[action], function (oneAction) {
                            this._debug(oneAction + ':' + listId + ' ' + msgBody.profile.email);

                            sendgridQueueManager.createQueue({
                                action: oneAction
                            });
                            sendgridQueueManager.push({
                                action: oneAction,
                                listId: listId,
                                suppressionListId: suppressionListId,
                                timeSent: timeSent,
                                profile: userProfile
                            });

                        }.bind(this));

                        EngineMonitor.countOperation(EngineMonitor.OPS.SENDGRID_SQS_QUEUE_PULL_SUCCESS);
                    } else {
                        this._warn("validation error", msgBody);
                        EngineMonitor.countOperation(EngineMonitor.OPS.SENDGRID_SQS_QUEUE_PULL_ERROR);
                    }
                    done();
                } catch (err) {
                    this._warn("error_processing_message " + err);
                    done(new Error('error processing message'));
                }

            }.bind(this)
        });

        app.on("message_received", function () {
            this._debug("message_received");
            EngineMonitor.countOperation(EngineMonitor.OPS.SENDGRID_SQS_QUEUE_MESSAGE_RECEIVED);
        }.bind(this));

        app.on("message_processed", function () {
            this._debug("message_processed");
            EngineMonitor.countOperation(EngineMonitor.OPS.SENDGRID_SQS_QUEUE_MESSAGE_PROCESSED);
        }.bind(this));

        app.on("error", function (err, message) {
            this._warn("message_error " + err + " " + message);
            EngineMonitor.countOperation(EngineMonitor.OPS.SENDGRID_SQS_QUEUE_PULL_ERROR);
        }.bind(this));

        app.on("processing_error", function (err, message) {
            this._warn("processing_error " + err);
            EngineMonitor.countOperation(EngineMonitor.OPS.SENDGRID_SQS_QUEUE_PULL_ERROR);
        }.bind(this));

        app.start();

        this._debug('sqs_app_start');
    },

sometimes a message gets added to the SQS queue but doesn't not get received by the consumer/ Here are my sqs queue settings:

Can someone please help?

In what cases do a message get added to the Queue and not received by the consumer?

来源:https://stackoverflow.com/questions/50650834/bbc-consumer-sqs-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!