You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by ssozonoff <se...@sozonoff.com> on 2006/04/18 10:31:30 UTC

ActiveMQ and Ajax

Hi James,

I have been looking at the ActiveMQ Ajax code and docs which is some what
similar to what we are trying to achieve. I have a question.

1. I read your arguments for not doing HTTP push. How do you think your
current Ajax polling implementation versus a push based solution scales?

Thanks,
Serge 
--
View this message in context: http://www.nabble.com/ActiveMQ-and-Ajax-t1466719.html#a3964102
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ and Ajax

Posted by ssozonoff <se...@sozonoff.com>.
James,

Yes I did read that page a few times ;-) which is what led me to Jencks, it
should handle the resource pooling.... But yes, JmsTemplate might be a
little too over simplified! The farther along I get the more tempted I am to
avoid JmsTemplate for the moment.... but at first it did make things easy
for someone not very familiar with Jms.

For example, typically when running with session based transactions I have
not found a way to get the session object from JmsTemplate to rollback a
transaction! As you rightly mentioned the method to get the session object
is protected.

I am going to have a look at the new JmsTemplate support in Spring 2.0 M3
just to get a better idea where they are headed. Then I am going to dig
deaper into Jms...... Do you know of any good reference books?

Serge
--
View this message in context: http://www.nabble.com/ActiveMQ-and-Ajax-t1466719.html#a3984838
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ and Ajax

Posted by James Strachan <ja...@gmail.com>.
On 4/19/06, ssozonoff <se...@sozonoff.com> wrote:
>
> Hi James,
>
> OK I am going to work on a proof of concept using your Ajax stuff as the
> starting point.
>
> Since this is currently synchronous I am going to try and plug in Spring's
> JmsTemplate which I already have setup using Jencks for the inbound
> messaging, but it could be that I don't get enough control when using
> JmsTemplate...

BTW be a little careful using JmsTemplate; unless you're using an EJB
container its probably best to avoid it and just use the JMS API :)

http://activemq.org/JmsTemplate+Gotchas
--

James
-------
http://radio.weblogs.com/0112098/

Re: ActiveMQ and Ajax

Posted by ssozonoff <se...@sozonoff.com>.
Hi James,

OK I am going to work on a proof of concept using your Ajax stuff as the
starting point. 

Since this is currently synchronous I am going to try and plug in Spring's
JmsTemplate which I already have setup using Jencks for the inbound
messaging, but it could be that I don't get enough control when using
JmsTemplate...

Thanks for your help,
Serge


--
View this message in context: http://www.nabble.com/ActiveMQ-and-Ajax-t1466719.html#a3983723
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ and Ajax

Posted by James Strachan <ja...@gmail.com>.
On 4/19/06, ssozonoff <se...@sozonoff.com> wrote:
>
> Thanks I will give this whole issue some more thought.
>
> BTW with regards to Comet, my understanding is that it is truely push based
> and does not require more than a single poll to get started after which
> events are pushed. In that case I guess your Ajax solution would be a sort
> of hybrid since there is a poll every 20-30 seconds.... and I still agree
> that it would be more robust.

Yeah - Comet is as good as you can get over HTTP. With C#/Java
clients, we can stream lots of messages (say 1000 of them) to the
client asynchronously so they get unmarshalled into Message objects in
the background, so the consumer doesn't have to wait for each message
to arrive; leading to real high performance.


> Another alternative would be to use XMPP and JEP 124 to get it over HTTP but
> this does not address the Push aspect... only the transport layer. I saw
> somewhere that there was some XMPP support in ActiveMQ.

Yeah- but its Java only though - you'd need a C# client.

--

James
-------
http://radio.weblogs.com/0112098/

Re: ActiveMQ and Ajax

Posted by ssozonoff <se...@sozonoff.com>.
Thanks I will give this whole issue some more thought.

BTW with regards to Comet, my understanding is that it is truely push based
and does not require more than a single poll to get started after which
events are pushed. In that case I guess your Ajax solution would be a sort
of hybrid since there is a poll every 20-30 seconds.... and I still agree
that it would be more robust.

Another alternative would be to use XMPP and JEP 124 to get it over HTTP but
this does not address the Push aspect... only the transport layer. I saw
somewhere that there was some XMPP support in ActiveMQ.


--
View this message in context: http://www.nabble.com/ActiveMQ-and-Ajax-t1466719.html#a3983116
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ and Ajax

Posted by James Strachan <ja...@gmail.com>.
On 4/19/06, ssozonoff <se...@sozonoff.com> wrote:
>
> Hi James,
>
> We would like to keep the protocol between the c# client and the server as
> HTTP over a standard port. Mainly to avoid any issues with firewalls.

FWIW it'd probably be quite easy to add HTTP support to the C# client
in the same way that the Java client can tunnel through HTTP.

The main downsides right now with the REST support is performance
(there's no way to do preloading of messages in consumers like we do
in the Java/C# clients - REST is request-response so lots slower) and
that there are no transactions or acknowledgements (if the socket dies
in the middle of a GET the message is lost). Other than that, you
should be able to use the HTTP support.

As an aside; I have been pondering about making a version of STOMP
(http://stomp.codehaus.org/) which uses HTTP - as mostly its very HTTP
like already, its just a new bunch of verbs - though firewalls often
do tend to block HTTP verbs other than GET/POST so am not sure how
useful it'd be.

--

James
-------
http://radio.weblogs.com/0112098/

Re: ActiveMQ and Ajax

Posted by ssozonoff <se...@sozonoff.com>.
Hi James,

We would like to keep the protocol between the c# client and the server as
HTTP over a standard port. Mainly to avoid any issues with firewalls.

Thanks,
Serge
--
View this message in context: http://www.nabble.com/ActiveMQ-and-Ajax-t1466719.html#a3981852
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ and Ajax

Posted by James Strachan <ja...@gmail.com>.
On 4/18/06, ssozonoff <se...@sozonoff.com> wrote:
>
> Hi James,
>
> Thanks for your lengthy response. I do agree with you that the "comet" bases
> approach offers a much more robust and reliable solution. I had flagged
> Jetty 6 and Solaris as part of our solution to scale as well as possible on
> a single box.
>
> We are building a solution using a C# based rich client as the "browser" and
> I am very keen on adapting what you have in the Ajax package namespace to
> work for us.
> Basically rewriting some of the amq.js client side JavaScript in our rich
> client as well as other things.

If you are using C# then why not use the C# client for JMS/ActiveMQ?

http://activemq.org/OpenWire+dotNet

--

James
-------
http://radio.weblogs.com/0112098/

Re: ActiveMQ and Ajax

Posted by ssozonoff <se...@sozonoff.com>.
Hi James,

Thanks for your lengthy response. I do agree with you that the "comet" bases
approach offers a much more robust and reliable solution. I had flagged
Jetty 6 and Solaris as part of our solution to scale as well as possible on
a single box.

We are building a solution using a C# based rich client as the "browser" and
I am very keen on adapting what you have in the Ajax package namespace to
work for us. 
Basically rewriting some of the amq.js client side JavaScript in our rich
client as well as other things.

We are using Spring in our server side architecture so I am going to have a
look through your code and see how to best fit it into our architecture,
hopefully without having to rewrite to much.

Kind thanks,
Serge


--
View this message in context: http://www.nabble.com/ActiveMQ-and-Ajax-t1466719.html#a3974657
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ and Ajax

Posted by James Strachan <ja...@gmail.com>.
On 4/18/06, ssozonoff <se...@sozonoff.com> wrote:
>
> Hi James,
>
> I have been looking at the ActiveMQ Ajax code and docs which is some what
> similar to what we are trying to achieve. I have a question.
>
> 1. I read your arguments for not doing HTTP push. How do you think your
> current Ajax polling implementation versus a push based solution scales?

Incidentally the long-poll approach is often labelled "Comet" these
days. I'll use that term answering as its a bit less typing...

On the client side the Comet approach is a little more lightweight and
less likely to fail - as some browsers are not really ready for an
infinite JavaScript page with pushlets, so they can die/use up RAM
badly. Also the Comet approach deals with dropped connections much
neater (as the Ajax client can easily make another long poll if one
fails due to, say, some firewall/proxy killing a socket.

But really both approaches are quite similar from the browsers
perspective - they both use a single socket (with HTTP keepalive); the
main difference is rather than streaming JavaScript code with pushlets
you can send JavaScript, JSON or XML or other content types using HTTP
encoding when using Comet. So rather than tying the HTML page to the
distribution technology with pushlets (having to understand the
JavaScript functions, variables and objects available on the page on
the server side to be able to 'send a message') you can use a looser
coupling approach - sending XML or JSON object trees. e.g. many pages
could subscribe to the same events and bind the message to the page
locally, rather than a publisher being required for every page,
knowing the exact JavaScript code to publish.

On the server side they are similar; they both use a socket per
connected client. The main difference is that the Ajax support in
ActiveMQ (using Jetty 6's continuations feature) means we can suspend
the servlet to free up the thread when there is no message available
for a client; whereas pushlet approaches tend to use up a blocked BIO
servlet. Also with Comet we can use the long poll as a keep-alive so
that we use threads more efficiently and evict unactive sessions more
aggresively.

So in summary; the main issue with scalability is the same in both
approaches; to have enough boxes dealing with enough sockets to handle
your user load. However with the combination of ActiveMQ & Jetty 6 we
can both use NIO and threads more efficiently to scale better.
Certainly the Ajax approach is a bit more flexible, is much looser
coupled and uses much less threads and is a bit more resilitent to
network errors and deals more gracefully with failures (e.g. servers
temporariy rejecting access when too many clients are online)

--

James
-------
http://radio.weblogs.com/0112098/