I’m consuming a message from RabbitMQ and then want to send a push notification to APNS/GSM using raix-push plugin. I have RabbitMQ integrated with Meteor but when I try to query the user’s record for their _id (required for raix-push), it gives this exception:
W20150930-16:03:53.929(-7)? (STDERR) Error: [Error: Can't wait without a fiber]
W20150930-16:03:53.929(-7)? (STDERR) at Connection.<anonymous> (packages/jakobloekke_rabbitmq/packages/jakobloekke_rabbitmq.js:20:1)
W20150930-16:03:53.929(-7)? (STDERR) at Connection.emit (events.js:117:20)
W20150930-16:03:53.929(-7)? (STDERR) at Connection.<anonymous> (/Users/lsacco/.meteor/packages/jakobloekke_rabbitmq/.0.0.2.1lqodho++os+web.browser+web.cordova/npm/node_modules/amqp/lib/connection.js:176:14)
W20150930-16:03:53.930(-7)? (STDERR) at Connection.emit (events.js:95:17)
W20150930-16:03:53.930(-7)? (STDERR) at CleartextStream.emit (events.js:95:17)
W20150930-16:03:53.933(-7)? (STDERR) at CleartextStream.<anonymous> (_stream_readable.js:765:14)
W20150930-16:03:53.933(-7)? (STDERR) at CleartextStream.emit (events.js:92:17)
W20150930-16:03:53.933(-7)? (STDERR) at emitReadable_ (_stream_readable.js:427:10)
W20150930-16:03:53.933(-7)? (STDERR) at _stream_readable.js:420:7
W20150930-16:03:53.933(-7)? (STDERR) at process._tickCallback (node.js:448:13)
I’ve tried many different things to such as wrapping as Fiber, using Meteor.bindEnivornment and the approach mentioned here. Any idea what I’m missing here?
RabbitMQ.connection.on('ready', function () {
RabbitMQ.connection.queue('ma.services.gapns', {'durable': true, 'autoDelete': false, closeChannelOnUnsubscribe: true }, function (queue) {
try
queue.bind('ma.integration.exchange', 'gapns');
queue.subscribe(function (msg) {
var data = {};
if (msg.content) {
data = msg.content;
}
var uid = data.uid,
system = data.system,
count = data.count;
if (uid && system && count >= 0) {
var user = getUser(uid);
Push.send({
from: 'push',
title: 'Hub Notification',
text: system + " request(s) to approve",
badge: count,
sound: 'ping.aiff',
query: {
userId: user._id
}
});
}
});
}
catch (e) {
logger.error("Exception occurred while processing push notifications: " + e);
}
});
});
function getUser(uid) {
var Future = Npm.require('fibers/future');
var future = new Future();
Meteor.users.findOne({username: uid}, {}, function(err, result) {
if (err) {
future.throw(err);
}
future.return(result);
});
return future.wait();
}