feat: Enable parallel processing on multiple queue nodes (#6295)

* Add non-parallel execution

* Add parallel processing for MQTT

* Fix logic expression for trigger

* fixes

* remove unused import

* fix MQTT parallel processing

* fix AMQPTrigger node parallelProcessing

* MQTTTrigger node default parallelProcessing to true

* add AMQP credential test

* improve error handling

---------

Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
agobrech
2023-08-16 13:06:47 +02:00
committed by GitHub
parent 198a977f57
commit 44afcff959
4 changed files with 95 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import type { ContainerOptions, Dictionary, EventContext } from 'rhea';
import type { Connection, ContainerOptions, Dictionary, EventContext } from 'rhea';
import { create_container } from 'rhea';
import type {
@@ -7,6 +7,10 @@ import type {
INodeExecutionData,
INodeType,
INodeTypeDescription,
ICredentialTestFunctions,
INodeCredentialTestResult,
ICredentialsDecrypted,
ICredentialDataDecryptedObject,
} from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';
@@ -28,6 +32,7 @@ export class Amqp implements INodeType {
{
name: 'amqp',
required: true,
testedBy: 'amqpConnectionTest',
},
],
properties: [
@@ -95,6 +100,52 @@ export class Amqp implements INodeType {
],
};
methods = {
credentialTest: {
async amqpConnectionTest(
this: ICredentialTestFunctions,
credential: ICredentialsDecrypted,
): Promise<INodeCredentialTestResult> {
const credentials = credential.data as ICredentialDataDecryptedObject;
const connectOptions: ContainerOptions = {
reconnect: false,
host: credentials.hostname as string,
hostname: credentials.hostname as string,
port: credentials.port as number,
username: credentials.username ? (credentials.username as string) : undefined,
password: credentials.password ? (credentials.password as string) : undefined,
transport: credentials.transportType ? (credentials.transportType as string) : undefined,
};
let conn: Connection | undefined = undefined;
try {
const container = create_container();
await new Promise<void>((resolve, reject) => {
container.on('connection_open', function (_contex: EventContext) {
resolve();
});
container.on('disconnected', function (context: EventContext) {
reject(context.error ?? new Error('unknown error'));
});
conn = container.connect(connectOptions);
});
} catch (error) {
return {
status: 'Error',
message: (error as Error).message,
};
} finally {
if (conn) (conn as Connection).close();
}
return {
status: 'OK',
message: 'Connection successful!',
};
},
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
try {
const credentials = await this.getCredentials('amqp');