Erlang/OTP Forums

Author Message

<  RabbitMQ mailing list  ~  Streaming stock prices to long-polling clients

Guest
Posted: Thu Oct 15, 2009 9:52 am Reply with quote
Guest
Hi,

In my application I need to stream stock prices to users.
The 'last price' will be retrieved from a separate service when a consumer connects which simplifies things.
Each user will subscribe to several stocks.
Users are web browsers connecting using long-polling.

Do I create one queue per consumer with several bindings, one for each stock?
Prices in this case will be sent with a topic routing key.
Another option is to create one queue per stock. each consumer will be subscribed to several queues.
Messages will be sent with a direct routing key.

Users will connect using a browser with long-polling to the mochiweb plugin.
Each user will be presented at the server side as an erlang AMQP client.
When using long-polling it is possible that the server sent responses to both connections and have to wait for the user to send a new request.
How do I handle this scenario? Does the erlang client store the messages in its state?
Every time the erlang client gets a new long-polling request it checks for messages in the state,
if there are messages it sends them immediately and if there aren't it keep-alive the request.
Another option is that the erlang client will acknowledge messages only if it can pass it to the web client.
What will happen in this case? Will the queue keep sending new messages or will it wait for the erlang client o 'initialize' the channel?
Are there a suspend and resume features?

Thanks


Post received from mailinglist
Guest
Posted: Mon Oct 19, 2009 11:24 am Reply with quote
Guest
Ben,

Ben Browitt wrote:
> In my application I need to stream stock prices to users.
> The 'last price' will be retrieved from a separate service when a
> consumer connects which simplifies things.
> Each user will subscribe to several stocks.
> Users are web browsers connecting using long-polling.
>
> Do I create one queue per consumer with several bindings, one for each
> stock?
> Prices in this case will be sent with a topic routing key.
> Another option is to create one queue per stock. each consumer will be
> subscribed to several queues.
> Messages will be sent with a direct routing key.

In the latter case, each quote would only go to one consumer, which is
probably not what you want. In an AMQP system, to get the same message
delivered to N consumers you need (at least) N queues. Exchanges *copy*
messages to queues, whereas queues *round-robin* message delivery to
consumers.

Your first setup should work fine, except there is no need to use a
topic exchange. Just use a direct exchange, one queue per user and for
each of the stock symbols a user is interested in create a binding
between the user's queue and the direct exchange.

> Users will connect using a browser with long-polling to the mochiweb plugin.
> Each user will be presented at the server side as an erlang AMQP client.

Have you considered using the rabbitmq-jsonrpc-channel plugin? Even if
you don't want to use it, it's worth taking a look at how it's
implemented since that may well answer some of your questions regarding
long-polling.


Regards,

Matthias.

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post received from mailinglist
Guest
Posted: Tue Oct 20, 2009 3:56 pm Reply with quote
Guest
Matthias,

Thank you. The round-robin and direct exchange were the missing parts.

Ben

On Mon, Oct 19, 2009 at 1:24 PM, Matthias Radestock <matthias@lshift.net (matthias@lshift.net)> wrote:
Quote:
Ben,

Ben Browitt wrote:
> In my application I need to stream stock prices to users.
> The 'last price' will be retrieved from a separate service when a
> consumer connects which simplifies things.
> Each user will subscribe to several stocks.
> Users are web browsers connecting using long-polling.
>
> Do I create one queue per consumer with several bindings, one for each
> stock?
> Prices in this case will be sent with a topic routing key.
> Another option is to create one queue per stock. each consumer will be
> subscribed to several queues.
> Messages will be sent with a direct routing key.


In the latter case, each quote would only go to one consumer, which is
probably not what you want. In an AMQP system, to get the same message
delivered to N consumers you need (at least) N queues. Exchanges *copy*
messages to queues, whereas queues *round-robin* message delivery to
consumers.

Your first setup should work fine, except there is no need to use a
topic exchange. Just use a direct exchange, one queue per user and for
each of the stock symbols a user is interested in create a binding
between the user's queue and the direct exchange.

> Users will connect using a browser with long-polling to the mochiweb plugin.
> Each user will be presented at the server side as an erlang AMQP client.


Have you considered using the rabbitmq-jsonrpc-channel plugin? Even if
you don't want to use it, it's worth taking a look at how it's
implemented since that may well answer some of your questions regarding
long-polling.


Regards,

Matthias.




Post received from mailinglist
business-investment
Posted: Fri Nov 20, 2009 3:21 pm Reply with quote
Joined: 20 Nov 2009 Posts: 1
thanks for sharing the information

__________
Penny Stocks Pick Newsletter
Purchase Hot Penny Stocks Online
View user's profile Send private message
Jeminyrider
Posted: Wed Dec 16, 2009 11:25 am Reply with quote
Joined: 16 Dec 2009 Posts: 1
I am very much appreciate to this good information. Many online penny stocks websites makes available information on hottest stock trends, news alerts etc.


Penny Stocks Report and Penny stock Alerts
View user's profile Send private message
AllenMass
Posted: Thu Dec 24, 2009 9:35 am Reply with quote
Guest
I am very much appreciate to this good information. Many online penny stocks websites makes available information on Penny stocks ,penny stocks trading etc.
Penny Stocks
stock-man
Posted: Fri Feb 05, 2010 4:40 pm Reply with quote
Joined: 05 Feb 2010 Posts: 1
even one can subscribe to penny stock newletters for getting regular updates
View user's profile Send private message
Tomcleverley
Posted: Tue Aug 16, 2011 11:47 am Reply with quote
Joined: 16 Aug 2011 Posts: 2
Thanks for the information. This really very knowledgeable for the beginners. I am also decided to invest money in Penny stock picks.

Penny stock picks
View user's profile Send private message
Tomcleverley
Posted: Wed Aug 24, 2011 9:35 am Reply with quote
Joined: 16 Aug 2011 Posts: 2
People invest in stocks for many reasons, the most obvious one is you can make money doing it but there are other reasons such as it is nice to take part in this pastime and can be a fun and rewarding hobby if you work at it

Invest in stocks market
View user's profile Send private message
pennystockshark
Posted: Sat Sep 03, 2011 4:47 am Reply with quote
Joined: 03 Sep 2011 Posts: 5 Location: USA
Its a great thing that now most are interested on investing on penny stocks.

Penny Stock Alerts
Micro Cap
View user's profile Send private message
pennyplayersclub
Posted: Tue Oct 04, 2011 12:36 pm Reply with quote
Joined: 04 Oct 2011 Posts: 8
Lots of investors are attracted to trade penny stock because it doesn't cost a lot of money to buy any particular stock and you can buy penny stock online for a $100 investment

Hot Penny Stocks
Best Penny Stocks
View user's profile Send private message
hotstockpicks
Posted: Tue Jan 17, 2012 10:40 am Reply with quote
Joined: 17 Jan 2012 Posts: 1
Thanks for sharing that will be really so valuable. it will be true that in most of the cases the penny stocks investing is found to be unprofitable investments and beginners used to suffer losses in stock trading.Hot Stocks
View user's profile Send private message
xtremepicks
Posted: Mon Jan 30, 2012 9:59 am Reply with quote
Joined: 10 Jan 2012 Posts: 9
It will be true that A deck is an expansion of your home which can enhance space along with the beauty of the house.Hot Penny Stocks
View user's profile Send private message
clubpennystocks
Posted: Tue Feb 21, 2012 1:19 pm Reply with quote
Joined: 18 Feb 2012 Posts: 2 Location: http://www.clubpennystocks.com/
Click here to receive stock information from Profit Confidential.


Penny Stock Investing
View user's profile Send private message
xtremepicks
Posted: Mon Feb 27, 2012 5:11 am Reply with quote
Joined: 10 Jan 2012 Posts: 9
Thanks for good discussion about stocks.

Best Penny Stocks
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 2
Goto page 1, 2  Next
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum