Skip to content

Commit

Permalink
[backend] Improve RabbitMQ consume to prevent error on none classic q…
Browse files Browse the repository at this point in the history
…ueue type (#4706)
  • Loading branch information
richard-julien committed Oct 20, 2023
1 parent 975bb42 commit b7159c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};
Expand Down
3 changes: 1 addition & 2 deletions opencti-platform/opencti-graphql/src/database/rabbitmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
});
}
Expand Down

0 comments on commit b7159c9

Please sign in to comment.