How to use the amqplib.credentials function in amqplib

To help you get started, we’ve selected a few amqplib 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 alice-si / etheroscope / backend / common / rabbitMq.js View on Github external
*/
var requestChannel = (channelName) => '@request:' + channelName + '@'

/**
 *
 * @param channelName
 * @param query
 * @returns {string}
 */
var responseChannel = (channelName, query) => '@response:' + channelName + ':' + query + '@'

/**
 *
 * @param cb
 */
const opt = { credentials: require('amqplib').credentials.plain('test', 'test') };
var connectRabbitMq = (cb) => amqp.connect('amqp://' + settings.RABBITMQHOST,
    opt,
    (err, conn) => {
        if (err) console.log(err)
        else cb(conn)
    });

/**
 *
 * @returns {*}
 */
var defaultTimeout = (conn) => setTimeout(() => conn.close(), 500)

/**
 *
 * @param queueName
github SAP / i40-aas / apps / https-endpoint-ingress / src / services / aas-router / messaging / AMQPClient.ts View on Github external
private connect(cb: () => void) {
    let opt = {
      credentials: require("amqplib").credentials.plain(
        this.brokerUser,
        this.brokerPass
      )
    };
    let url = this.ampqUrl + "?heartbeat=60";
    logger.debug("Connecting to " + url);
    var that = this;
    try {
      this.connectToBroker(url, opt, async function(err, conn: Connection) {
        if (err) {
          logger.error("[AMQP] Error:" + err.message);
          logger.info("Waiting to reconnect");
          let timeout: number;
          if (that.reconnectAfterMilliSecs)
            timeout = that.reconnectAfterMilliSecs;
          else timeout = 6000;
github SAP / i40-aas / apps / https-endpoint-egress / src / messaging / AMQPClient.ts View on Github external
private static doConnection(
    cb: () => void,
    user: string,
    pass: string,
    ampqUrl: string,
    myConn: AmqpConnectionDetails,
    brokerExchange: string
  ) {
    let opt = {
      credentials: require("amqplib").credentials.plain(user, pass)
    };
    let url = ampqUrl + "?heartbeat=60";
    logger.debug("Connecting to " + url);
    try {
      amqp.connect(url, opt, async function(err, conn: Connection) {
        if (err) {
          logger.error("[AMQP]:" + err.message);
          //return;
          logger.info("Waiting to reconnect");
          await AmqpClient.sleep(6000);
          logger.info("reconnecting. Call count:" + AmqpClient.retryCounter++);
          //TODO: recursion, watch out for stack overflow
          AmqpClient.doConnection(
            cb,
            user,
            pass,
github SAP / i40-aas / apps / onboarding-skill / src / messaging / AmqpClient.ts View on Github external
private connect(cb: () => void) {
    let opt = {
      credentials: require("amqplib").credentials.plain(
        this.brokerUser,
        this.brokerPass
      )
    };
    let url = " amqp://" + this.ampqUrl + "?heartbeat=60";
    logger.debug("Connecting to " + url);
    var that = this;
    try {
      this.connectToBroker(url, opt, async function(err, conn: Connection) {
        if (err) {
          logger.error("[AMQP] Error:" + err.message);
          logger.info("Waiting to reconnect");
          let timeout: number;
          if (that.reconnectAfterMilliSecs)
            timeout = that.reconnectAfterMilliSecs;
          else timeout = 6000;
github alice-si / etheroscope / backend / process-contract-service / server.js View on Github external
const amqp = require('amqplib/callback_api')
const log = require('loglevel')
const Parity = require('../common/parity')
const Promise = require('bluebird')

const errorHandler = require('../common/errorHandlers')
const settings = require('../common/settings')
const db = require('../db')

log.enableAll()
const parity = Parity(db, log)

const opt = { credentials: require('amqplib').credentials.plain(settings.RABBITMQ.user,
        settings.RABBITMQ.password) }

/**
 * Function responsible for caching all variables' values in a given range [from, upTo]
 *
 * Consists of 4 steps
 * Step 1 - parity,getHistory call (getting events in a given range)
 * Step 2 - caching blocks' timestamps
 * Step 3 - caching transactions
 * Step 4 - caching values for each variable
 *
 * @param contractInfo
 * @param variables
 * @param from
 * @param upTo
 * @return {Promise<*>}

amqplib

An AMQP 0-9-1 (e.g., RabbitMQ) library and client.

MIT
Latest version published 20 days ago

Package Health Score

91 / 100
Full package analysis