keep track of queue length; omit some messages from entering the queue (pong,..)

This commit is contained in:
Anton Georgiev 2015-11-09 21:35:03 +00:00
parent e3efd24a2b
commit d3f9f4e8a7
2 changed files with 20 additions and 9 deletions

View File

@ -53,14 +53,19 @@ class Meteor.RedisPubSub
_Q: (pattern, channel, jsonMsg) =>
message = JSON.parse(jsonMsg)
eventName = message.header.name
console.log "Q #{eventName} #{Meteor.myQueue.total()}"
messagesWeIgnore = [
"BbbPubSubPongMessage"
"bbb_apps_is_alive_message"
]
Meteor.myQueue.add({
pattern: pattern
channel: channel
jsonMsg: jsonMsg
})
unless eventName in messagesWeIgnore
console.log "Q #{eventName} #{Meteor.myQueue.total()}"
Meteor.myQueue.add({
pattern: pattern
channel: channel
jsonMsg: jsonMsg
})
_onMessage: (pattern, channel, jsonMsg) =>
# TODO: this has to be in a try/catch block, otherwise the server will

View File

@ -26,10 +26,18 @@ Meteor.startup ->
Meteor.log.error "got a failure on taskHandler #{eventName} #{failures}"
else
handleRedisMessage(data, ()->
Meteor.log.error "in callback after handleRedisMessage #{eventName}"
length = Meteor.myQueue.length()
lengthString = ->
if length>0
"In the queue we have #{length} event(s) to process."
else ""
Meteor.log.info "in callback after handleRedisMessage #{eventName}.
#{lengthString()}"
next()
)
# To ensure that we process the redis json event messages serially we use a
# callback. This callback is to be called when the Meteor collection is
# updated with the information coming in the payload of the json message. The
@ -153,8 +161,6 @@ Meteor.startup ->
# only process if requester is nodeJSapp means only process in the case when
# we explicitly request the users
else if eventName is 'get_users_reply' and message.payload.requester_id is 'nodeJSapp'
Meteor.log.error JSON.stringify(message)
if !Meteor.Meetings.findOne({meetingId: meetingId})? #TODO consider removing this cond
users = message.payload.users