<commit_before>var amqp = require('amqp'),
    local = require('./local'),
    _ = require('underscore');

var Registry = function () {
    this.sockets = {};
    this.subscriptions = {};
}

Registry.prototype.create = function (options) {
    options = options || {};

    local.create(options);

    var connection = this.connection = amqp.createConnection({
        url: options.amqp
    });

    this.__read = options.read || function () {
        throw "No read defined";
    };
    this.__invalidate = options.invalidate || function () {};

    connection.on('ready', _.bind(function () {
        console.log("amqp - Connection ready");
        connection.exchange('triggers', {
            type: 'fanout'
        }, _.bind(function (exchange) {
            this.exchange = exchange;
            console.log('amqp - Exchange ' + exchange.name + ' is open');

            connection.queue('trigger-queue', _.bind(function (queue) {
                this.queue = queue;
                console.log('amqp - Queue ' + queue.name + ' is open');

                queue.bind('triggers', '#');<commit_msg>Fixed AMQP fanout pattern to use unique exclusive queues<commit_after>var amqp = require('amqp'),
    local = require('./local'),
    _ = require('underscore');

var Registry = function () {
    this.sockets = {};
    this.subscriptions = {};
}

Registry.prototype.create = function (options) {
    options = options || {};

    local.create(options);

    var connection = this.connection = amqp.createConnection({
        url: options.amqp
    });

    this.__read = options.read || function () {
        throw "No read defined";
    };
    this.__invalidate = options.invalidate || function () {};

    connection.on('ready', _.bind(function () {
        console.log("amqp - Connection ready");
        connection.exchange('triggers', {
            type: 'fanout'
        }, _.bind(function (exchange) {
            this.exchange = exchange;
            console.log('amqp - Exchange ' + exchange.name + ' is open');

            connection.queue('', {
                exclusive: true
            }, _.bind(function (queue) {
                this.queue = queue;
                console.log('amqp - Queue ' + queue.name + ' is open');

                queue.bind('triggers', '#');
{'fraction_non_alphanumeric': 0.15199299167761718, 'fraction_numerical': 0.0, 'mean_word_length': 2.235127478753541, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '727657', 'n_tokens_mistral': 636, 'n_tokens_neox': 605, 'n_words': 132}