From b7159c909f05666e4c48febee2b356b51721350b Mon Sep 17 00:00:00 2001 From: Julien Richard Date: Sat, 21 Oct 2023 01:40:11 +0200 Subject: [PATCH] [backend] Improve RabbitMQ consume to prevent error on none classic queue type (#4706) --- .../src/connector/importCsv/importCsv-connector.ts | 1 + opencti-platform/opencti-graphql/src/database/rabbitmq.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opencti-platform/opencti-graphql/src/connector/importCsv/importCsv-connector.ts b/opencti-platform/opencti-graphql/src/connector/importCsv/importCsv-connector.ts index c883e8a935f3..51efae3ae178 100644 --- a/opencti-platform/opencti-graphql/src/connector/importCsv/importCsv-connector.ts +++ b/opencti-platform/opencti-graphql/src/connector/importCsv/importCsv-connector.ts @@ -107,6 +107,7 @@ const initImportCsvConnector = () => { const handleCsvImport = async (context: AuthContext) => { consumeQueue(context, connector.id, connectionSetterCallback, consumeQueueCallback).catch(() => { + if (rabbitMqConnection) rabbitMqConnection.close(); setTimeout(handleCsvImport, RETRY_CONNECTION_PERIOD); }); }; diff --git a/opencti-platform/opencti-graphql/src/database/rabbitmq.js b/opencti-platform/opencti-graphql/src/database/rabbitmq.js index b1fcb9023c09..8fc487096ef9 100644 --- a/opencti-platform/opencti-graphql/src/database/rabbitmq.js +++ b/opencti-platform/opencti-graphql/src/database/rabbitmq.js @@ -255,14 +255,13 @@ export const consumeQueue = async (context, connectorId, connectionSetterCallbac channel.on('error', (onChannelError) => { reject(onChannelError); }); - channel.assertQueue(listenQueue); channel.consume(listenQueue, (data) => { if (data !== null) { callback(context, data.content.toString()); } }, { noAck: true }, (consumeError) => { if (consumeError) { - logApp.error('CONNECTOR_CONSUMER_QUEUE_ERROR', { error: consumeError, connector: cfg.name }); + logApp.error('CONNECTOR_CONSUMER_QUEUE_CONSUME', { error: consumeError }); } }); }