How to use the rhea.options function in rhea

To help you get started, we’ve selected a few rhea examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github n8n-io / n8n / packages / nodes-base / nodes / Amqp / AmqpTrigger.node.ts View on Github external
}
		let durable = false;
		if(subscription && clientname) {
			durable = true;
		}

		const container = require('rhea');
		const connectOptions: ContainerOptions = {
			host: credentials.hostname,
			port: credentials.port,
			reconnect: true,		// this id the default anyway
			reconnect_limit: 50,	// try for max 50 times, based on a back-off algorithm
			container_id: (durable ? clientname : null)
		};
		if (credentials.username || credentials.password) {
			container.options.username = credentials.username;
			container.options.password = credentials.password;
		}

		let lastMsgId: number | undefined = undefined;
		const self = this;

		container.on('message', (context: any) => { // tslint:disable-line:no-any
			if (context.message.message_id && context.message.message_id === lastMsgId) {
				// ignore duplicate message check, don't think it's necessary, but it was in the rhea-lib example code
				lastMsgId = context.message.message_id;
				return;
			}
			self.emit([self.helpers.returnJsonArray([context.message])]);
		});

		const connection = container.connect(connectOptions);
github n8n-io / n8n / packages / nodes-base / nodes / Amqp / AmqpTrigger.node.ts View on Github external
let durable = false;
		if(subscription && clientname) {
			durable = true;
		}

		const container = require('rhea');
		const connectOptions: ContainerOptions = {
			host: credentials.hostname,
			port: credentials.port,
			reconnect: true,		// this id the default anyway
			reconnect_limit: 50,	// try for max 50 times, based on a back-off algorithm
			container_id: (durable ? clientname : null)
		};
		if (credentials.username || credentials.password) {
			container.options.username = credentials.username;
			container.options.password = credentials.password;
		}

		let lastMsgId: number | undefined = undefined;
		const self = this;

		container.on('message', (context: any) => { // tslint:disable-line:no-any
			if (context.message.message_id && context.message.message_id === lastMsgId) {
				// ignore duplicate message check, don't think it's necessary, but it was in the rhea-lib example code
				lastMsgId = context.message.message_id;
				return;
			}
			self.emit([self.helpers.returnJsonArray([context.message])]);
		});

		const connection = container.connect(connectOptions);
		let clientOptions = undefined;
github n8n-io / n8n / packages / nodes-base / nodes / Amqp / Amqp.node.ts View on Github external
}

		if (sink === '') {
			throw new Error('Queue or Topic required!');
		}

		const container = require('rhea');

		const connectOptions: ContainerOptions = {
			host: credentials.hostname,
			port: credentials.port,
			reconnect: true,		// this id the default anyway
			reconnect_limit: 50,	// try for max 50 times, based on a back-off algorithm
		};
		if (credentials.username || credentials.password) {
			container.options.username = credentials.username;
			container.options.password = credentials.password;
		}

		const allSent = new Promise(( resolve ) => {
			container.on('sendable', (context: any) => { // tslint:disable-line:no-any

				const message = {
					application_properties: headerProperties,
					body: JSON.stringify(item)
				};

				const sendResult = context.sender.send(message);

				resolve(sendResult);
			});
		});
github n8n-io / n8n / packages / nodes-base / nodes / Amqp / Amqp.node.ts View on Github external
if (sink === '') {
			throw new Error('Queue or Topic required!');
		}

		const container = require('rhea');

		const connectOptions: ContainerOptions = {
			host: credentials.hostname,
			port: credentials.port,
			reconnect: true,		// this id the default anyway
			reconnect_limit: 50,	// try for max 50 times, based on a back-off algorithm
		};
		if (credentials.username || credentials.password) {
			container.options.username = credentials.username;
			container.options.password = credentials.password;
		}

		const allSent = new Promise(( resolve ) => {
			container.on('sendable', (context: any) => { // tslint:disable-line:no-any

				const message = {
					application_properties: headerProperties,
					body: JSON.stringify(item)
				};

				const sendResult = context.sender.send(message);

				resolve(sendResult);
			});
		});
github amqp / rhea / examples / sasl / simple_sasl_client.js View on Github external
var container = require('rhea');
var args = require('../options.js').options({
    'username': { describe: 'username to connect with'},
    'password': { describe: 'password to connect with (will use PLAIN)'},
    'h': { alias: 'host', default: 'localhost', describe: 'dns or ip name of server where you want to connect'},
    'p': { alias: 'port', default: 5671, describe: 'port to connect to'}
}).help('help').argv;

/**
 * Default SASL behaviour is as follows. If the username and password
 * are both specified, PLAIN will be used. If only a username is
 * specified, ANONYMOUS will be used. If neither is specified, no SASl
 * layer will be used.
 */
if (args.username) {
    container.options.username = args.username;
}
if (args.password) {
    container.options.password = args.password;
}
container.on('connection_open', function (context) {
    console.log('Connected!');
    context.connection.close();
});
container.connect({ port: args.port, host: args.host });
github mthirion / microsaga / cards / src / main / amq / node_modules / rhea / examples / sasl / simple_sasl_client.js View on Github external
'username': { describe: 'username to connect with'},
      'password': { describe: 'password to connect with (will use PLAIN)'},
      'p': { alias: 'port', default: 5671, describe: 'port to connect to'}
    }).help('help').argv;

/**
 * Default SASL behaviour is as follows. If the username and password
 * are both specified, PLAIN will be used. If only a username is
 * specified, ANONYMOUS will be used. If neither is specified, no SASl
 * layer will be used.
 */
if (args.username) {
    container.options.username = args.username;
}
if (args.password) {
    container.options.password = args.password;
}
container.on('connection_open', function (context) {
    console.log('Connected!');
    context.connection.close();
});
container.connect({'port':args.port});
github mthirion / microsaga / cards / src / main / amq / node_modules / rhea / examples / sasl / simple_sasl_client.js View on Github external
*/
var container = require('rhea');
var args = require('../options.js').options({
      'username': { describe: 'username to connect with'},
      'password': { describe: 'password to connect with (will use PLAIN)'},
      'p': { alias: 'port', default: 5671, describe: 'port to connect to'}
    }).help('help').argv;

/**
 * Default SASL behaviour is as follows. If the username and password
 * are both specified, PLAIN will be used. If only a username is
 * specified, ANONYMOUS will be used. If neither is specified, no SASl
 * layer will be used.
 */
if (args.username) {
    container.options.username = args.username;
}
if (args.password) {
    container.options.password = args.password;
}
container.on('connection_open', function (context) {
    console.log('Connected!');
    context.connection.close();
});
container.connect({'port':args.port});
github amqp / rhea / examples / sasl / simple_sasl_client.js View on Github external
'password': { describe: 'password to connect with (will use PLAIN)'},
    'h': { alias: 'host', default: 'localhost', describe: 'dns or ip name of server where you want to connect'},
    'p': { alias: 'port', default: 5671, describe: 'port to connect to'}
}).help('help').argv;

/**
 * Default SASL behaviour is as follows. If the username and password
 * are both specified, PLAIN will be used. If only a username is
 * specified, ANONYMOUS will be used. If neither is specified, no SASl
 * layer will be used.
 */
if (args.username) {
    container.options.username = args.username;
}
if (args.password) {
    container.options.password = args.password;
}
container.on('connection_open', function (context) {
    console.log('Connected!');
    context.connection.close();
});
container.connect({ port: args.port, host: args.host });