amqp10-link-cache
A link caching plugin for the amqp10 module
Last updated 4 years ago by mbroadst .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install amqp10-link-cache 
SYNC missed versions from official npm registry.

amqp10-link-cache

Build Status Dependency Status

This module allows you to reuse already created links with the same link options throughout your codebase. This is particularly useful as you no longer need to make all of the links up front before using them, you can simply always create the links where you need them and know that it will either be created or a cached copy will be returned.

By default receiver links are not cached, the user must explicitly opt in to this behavior for both receiver links and receiver streams.

usage

'use strict';
var amqp = require('amqp10'),
    linkCache = require('amqp10-link-cache');

// plug-in the link cache, with optional parameters
amqp.use(linkCache({ ttl: 5000 }));

var client = new amqp.Client();
client.connect('amqp://localhost')
  .then(function() {
    // defaults for sender:
    var senderOpts = {
      bypassCache: false      // set to true to disable caching this link
    };

    // defaults for receiver:
    var receiverOpts = {
      bypassCache: true
    };

    return Promise.all([
      client.createSender('amq.topic', senderOpts),
      client.createSender('amq.topic'),
      client.createSender('amq.topic', { bypassCache: true }),
      client.createReceiver('amqp.topic', receiverOpts),
      client.createReceiver('amqp.topic'),
      client.createReceiver('amq.topic', { bypassCache: false }),
      client.createReceiver('amq.topic', { bypassCache: false })
    ]);
  })
  .spread(function(sender1, sender2, sender3, receiver1, receiver2, receiver3, receiver4) {
    // sender1 === sender2
    // sender1 !== sender3 && sender2 !== sender3
    // receiver1 !== receiver2
    // receiver3 === receiver4
  });

Current Tags

  • 1.2.2                                ...           latest (4 years ago)

9 Versions

  • 1.2.2                                ...           4 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 2
Dependencies (2)
Dev Dependencies (5)

Copyright 2014 - 2016 © taobao.org |