in application-workloads/pubnub/pubnub-eventhub-bridge/tools/provisioningListener.js [84:137]
function fireEHListeners() {
console.log("Ingress Event Hub Connection String: ", EHInConnectionString);
console.log("");
console.log("Egress Event Hub Connection String: ", EHOutConnectionString);
console.log();
console.log("Waiting for messages to arrive via Event Hubs...");
console.log();
var receiveAfterTime = Date.now() - 0;
var printError = function (err) {
console.log("Error: " + err.message);
};
function printInMessage(msg) {
console.log("Message Received on Ingress Event Hub: " + ": " + JSON.stringify(msg.body));
console.log();
}
function printOutMessage(msg) {
console.log("Message Received on Egress Event Hub: " + ": " + JSON.stringify(msg.body));
console.log();
}
/************** Create the Ingress Path */
var EHInClient = EventHubClient.fromConnectionString(EHInConnectionString);
var EHOutClient = EventHubClient.fromConnectionString(EHOutConnectionString);
EHOutClient.open()
.then(EHOutClient.getPartitionIds.bind(EHOutClient))
.then(function (partitionIds) {
return Promise.map(partitionIds, function (partitionId) {
return EHOutClient.createReceiver('$Default', partitionId, {'startAfterTime': receiveAfterTime}).then(function (receiver) {
receiver.on('errorReceived', printError);
receiver.on('message', printOutMessage);
});
});
}).catch(printError);
EHInClient.open()
.then(EHInClient.getPartitionIds.bind(EHInClient))
.then(function (partitionIds) {
return Promise.map(partitionIds, function (partitionId) {
return EHInClient.createReceiver('$Default', partitionId, {'startAfterTime': receiveAfterTime}).then(function (receiver) {
receiver.on('errorReceived', printError);
receiver.on('message', printInMessage);
});
});
}).catch(printError);
}