Web push service built around ActiveMQ (or any STOMP broker)


Web push service built around ActiveMQ (or any STOMP broker).

ActivePush subscribes to a STOMP broker and relays messages with a specific push_id header to subscribed clients. The message bodies are opaque to ActivePush, so the service is useful in a variety of applications.


npm install
bin/activepush [environment]


npm install -d

Or, to auto-reload on changes:


The optional environment argument corresponds to a configuration file in configure, which defaults to development and overrides values in the "default.yml" configuration file.

By default ActivePush expects a STOMP broker (e.x. ActiveMQ) to be running on localhost:61613.

If ActiveMQ is installed you can start it with the following command:

activemq start broker:stomp://localhost:61613

Configuration files are located in the config directory. default.yml is loaded first, and an environment-specific configuration (defaulting to development.yml) overrides the defaults.

The environment can be specified as the first argument the the activepush executable, or in the NODE_ENV environment variable.

All HTTP endpoints except those under the "/" URL should not be exposed externally as they could expose private information (e.g. "/health") or capabilities (e.g. "/send"). Alternatively, those endpoints could easily be moved to a separate port (see commented out code in the start method of ActivePush)

Multiple instances of ActivePush can be load-balanced, keeping the following in mind:

  • A STOMP message bus rather than a queue should be used to ensure all instances recieve all messages
  • needs clients to be "pinned" to the same backend across multiple requests (perhaps using cookies or the source IP address), in particular for the XHR polling transport.

The ActivePush class in creates the server using the StompProducer and SocketIOConsumer. This could be made configurable, or even support multiple simultaneous producer/consumers.

The STOMP and WebSocket components are implemented in and, respectively. Other producers/consumers could be implemented.

The producer/consumer components share a SubscriptionBroker subscriptions object, which is essentially an EventEmitter they can listen or emit push_id events to.

ActivePush makes extensive use of "promises" (specifically Q promises, which are compatible with the Promises/A+ standard) in both the application and tests.

npm test


mocha --compilers coffee:coffee-script test

The integration tests assume a STOMP broker is running on localhost:61613. ActiveMQ can be started with the following command:

activemq start broker:stomp://localhost:61613

They also assume Selenium/WebDriver is running on localhost:4444. If you want to disable the WebDriver tests (they are significantly slower) comment out the last line of test/, or run:

mocha --compilers coffee:coffee-script test/ implements the logic of the tests while and implement a common API to create either an in-process or a remote WebDriver instance running the demo.html page (which stores messages it receives in window.messages for introspection by the test)

Unfortunately there is no easy way to tell when all messages have propagated from the running test to the ActiveMQ queue back to the ActivePush server and through the client, so we currently have short delays before testing that messages have been received. This leads to occasional non-deterministic test failures. Increasing the delays reduces the frequency at a cost of longer running tests.