 allMessages = Rx.Observable
 .interval(500)
 .filter (tick) ->
-  stats.applyBackpressureAtTick(tick)
+  not stats.applyBackpressureAtTick(tick)
 .flatMap ->
   messageService.getMessages()
 .map (msg) ->


Rx = require 'rx'
Q = require 'q'
{_} = require('underscore')
express = require 'express'

messageProcessors = [((m)-> Q(m)), ((m)-> Q(m)), ((m)-> Q(m))]

  persistenceService.reportMessageProcessingFailure m, m.processingResults
.subscribe recycleBin

initiateSelfDestructionSequence = ->
  Rx.Observable.interval(500).subscribe ->
    if stats.messagesInProgress() is 0
      console.info "Graceful exit", stats.get()
      process.exit 0

statsApp = express()

statsApp.get '/', (req, res) ->
  res.json stats.get()

statsApp.get '/stop', (req, res) ->
  res.send 'Ok'
  stats.panicMode = true
  initiateSelfDestructionSequence()

statsApp.listen 7777, ->
  console.log "Statistics is on port 7777"
