rabbit.js icon indicating copy to clipboard operation
rabbit.js copied to clipboard

rabbit.js within AngularJS

Open rtubio opened this issue 9 years ago • 6 comments
trafficstars

Can rabbit.js be included in an Angular JS application or is it strictly restricted to be used within Node.js? I know that both the Node.js and Angular JS environments are JavaScript based, but I would like to now whether rabbit.js requires specifically to be used from within Node.js.

rtubio avatar Nov 28 '15 09:11 rtubio

rabbit.js is fairly portable code in itself (although, inevitably, written in callback/promises style); however, since it relies on amqp.node (aka amqplib), I don't think it's usable outside a Node.JS environment.

squaremo avatar Nov 28 '15 11:11 squaremo

@squaremo : I know that I made you a question in the repository for AMQP that is pretty similar to this one, but I want to explore all the possibilities.

Is there any pure JS or AngularJS library for RabbitMQ?

rtubio avatar Nov 28 '15 17:11 rtubio

I don't think anyone really connects directly to RabbitMQ from a browser. What's your use case?

analytik avatar Dec 03 '15 15:12 analytik

@analytik : my use case is a system composed of 2 different types of clients:

  • Web application developed with Angular JS that, right now, is using pusher.com and JSON/RPC over HTTPS for the communications with a Django server.
  • Python client that connects to a Twisted server to exchange messages with low latency (real time).

I am trying to find an integrated communications system to use a single protocol for all the above mentioned 3 connections. RabbitMQ, together with Redis, Crossbar.io and gunicorn-websockets, match pretty well my requirements; however, each of them has a little drawback that I am trying to work around:

  1. RabbitMQ and Redis do not have an Angular/Javascript browser support, so I cannot directly communicate my first app (Angular JS based) with the server;
    1. crossbar.io and gunicorn-websocket: libraries available for JS and even Angular (WAMP);
  2. RabbitMQ and Redis directly integrate with Django through Celery (2/3 steps configuration process) that is really fast and efficient;
    1. crossbar.io and gunicorn-websocket: not a so-clear-integration process w/Django;
    2. there is a project/example to integrate crossbar.io w/Django through Celery, but it is not very mature yet;
  3. crossbar.io and gunicorn-websocket implement WAMP, which is the correct protocol for this application (offers RPC and PUB/SUB, both for clients ant the web);
    1. RabbitMQ offers STOMP, but you kind of have to run it as a slightly separate server on its own.

As you may have noticed, I am trying to find the most suitable option and that is why I am asking for clarifications on some of the issues above to understand correctly the actual limits of these options.

rtubio avatar Dec 03 '15 18:12 rtubio

www.rethinkdb.com

Although no single technology ever will be a silver bullet, I would say that RethinkDB has the potential to simplify your stack, although maybe not exactly as you imagine. It can replace Pusher.com with its realtime push, it's a full-featured database, and to some degree it can work as PUB/SUB, although it's not trying to compete with RabbitMQ.

In the next release (1-3 months) it will add support for direct connection from browsers, although I'm not sure if they plan any library-specific support on Day 1. However, hooking up RethinkDB -> Node.js + Socket.io -> Angular + Socket.io is very easy, and can be done in an hour or two.

If you're a fan of ORMs, you can use Angular + JS-Data-Angular -> Node.js + JS-Data-RethinkDB, although that doesn't have a direct support for websockets/push, but can get you up and running with basic filtering in place.

You could also try https://github.com/mikemintz/rethinkdb-websocket-client - but I have not tried that one.

(And sorry to squaremo if this feels disrespectful to have this discussion on a rabbit.js issue.)

analytik avatar Dec 04 '15 08:12 analytik

(And sorry to squaremo if this feels disrespectful to have this discussion on a rabbit.js issue.)

Yeah that is a bit cheeky, but since you had the grace to apologise, I'll allow it ;)

squaremo avatar Dec 04 '15 10:12 squaremo