<commit_before>'use strict';
//var AMQPClient = require('amqp10').Client;
var AMQPClient  = require('../lib').Client;

var uri = 'amqp://some.host/random2';
var msgId = Math.floor(Math.random() * 10000);

var client = new AMQPClient();
client.connect(uri).then(function () {
    var msgStr = JSON.stringify({"DataString": "From Node", "DataValue": msgId});
    console.log('Sending ' + msgStr);
    client.send(msgStr).then(function () {
        console.log('Sent');
    }).catch(function (e) {
        console.log('Error Sending ' + e);
    });
}).then(function() {
    client.createReceiver(function (err, message) {
        if (err) {
            console.log('Error Receiving ' + err);
        } else {
            console.log('Recv: ');
            console.log(message.body);
            if (message.annotations) {
                console.log('Annotations:');
                console.log(message.annotations);
            }
            console.log('');
            try {
                var asJson = JSON.parse(message.body);
                if (asJson.DataValue === msgId) {
                    client.disconnect(function () {
                        console.log("Received expected message.  Disconnected.");
                    });
                }
            } catch (e) {
                console.log("Error parsing payload " + message.body);
                console.log(e);
            }
        }
    });
}).catch(function (e) {
    console.log('Error Connecting: ' + e);
});
<commit_msg>refactor(activemq-test): refactor simple test to use updated API<commit_after>'use strict';
//var AMQPClient = require('amqp10').Client;
var AMQPClient  = require('../lib').Client,
    Promise = require('bluebird');

var uri = 'amqp://some.host',
    msgId = Math.floor(Math.random() * 10000),
    client = new AMQPClient();

client.connect(uri)
  .then(function () {
    return Promise.all([
      client.createReceiver('amq.topic'),
      client.createSender('amq.topic')
    ]);
  })
  .spread(function(receiver, sender) {
    receiver.on('errorReceived', function(err) { console.log('error receiving: ', err); });
    receiver.on('message', function(message) {
      console.log('received: ', message.body);
      if (message.annotations) console.log('annotations: ', message.annotations);
      if (message.body.dataValue === msgId) {
        client.disconnect().then(function() {
          console.log("received expected message, disconnected.");
        });
      }
    });

    var message = { dataString: "From Node", dataValue: msgId };
    console.log('sending: ', message);
    return sender.send(message);
  })
  .catch(function (e) {
    console.log('connection error: ', e);
  });

{'fraction_non_alphanumeric': 0.16623376623376623, 'fraction_numerical': 0.0055658627087198514, 'mean_word_length': 2.382685069008783, 'pattern_counts': {'":': 2, '<': 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': '6179254', 'n_tokens_mistral': 805, 'n_tokens_neox': 771, 'n_words': 148}