You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "Knight, Doug" <dk...@mitre.org> on 2009/09/14 17:45:25 UTC

Chat JavaScript example

All,
>From the JavaScript-based chat example, and various all-similar sources for how to configure it (i.e. see http://docs.codehaus.org/display/JETTY/Integrating+with+ActiveMQ for example), I don't understand how the JavaScript client knows what server to connect to. There is mentioned some info about adding to the web.xml, but is this used by the JavaScript app or the Jetty server on the server side? I've tried to "clone" the chat app to model my app after it (accessing a remote JMS topic to retrieve XML data, and display on a GIS map), with no success. I never get connected to the CHAT.DEMO topic. Any help on configuring both the client and server sides for a JavaScript app would be greatly appreciated. Once I get this working, I'd even be willing to share detailed info on the configuration I had to setup.

Doug

RE: Chat JavaScript example

Posted by "Knight, Doug" <dk...@mitre.org>.
OK, I think I've got it. Now, I've got a barebones sender and receiver pair, based on the example in the link below. I see the topic get created when I refresh the receiver, and it has a single consumer, as expected. When I run the sender to send to that topic, I am having issues trying to issue output to the web page on the receiver from within the message handler. I originally tried the example using the alert box. The only time I managed to get an alert to work was when I had an error in the JavaScript contained in the handler. Is there anything special I need to do to output from the handler? I've tried direct document.writes, alert with simple text, even jQuery output (both with and without the .ready function. Any suggestions?

Doug

-----Original Message-----
From: chubrilo@gmail.com [mailto:chubrilo@gmail.com] On Behalf Of Dejan Bosanac
Sent: Monday, September 14, 2009 12:34 PM
To: users@activemq.apache.org
Subject: Re: Chat JavaScript example

Hi Doug,

ajax client connects to the servlet (called AjaxServlet) that runs inside
jetty (or any other web container) that server like a proxy to the broker.
Therefore, you should all jms related stuff inside your web application.
Take a look at webapps/demo/WEB-INF/web.xml for an example of how to do it.

Cheers
--
Dejan Bosanac

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Mon, Sep 14, 2009 at 5:45 PM, Knight, Doug <dk...@mitre.org> wrote:

> All,
> From the JavaScript-based chat example, and various all-similar sources for
> how to configure it (i.e. see
> http://docs.codehaus.org/display/JETTY/Integrating+with+ActiveMQ for
> example), I don't understand how the JavaScript client knows what server to
> connect to. There is mentioned some info about adding to the web.xml, but is
> this used by the JavaScript app or the Jetty server on the server side? I've
> tried to "clone" the chat app to model my app after it (accessing a remote
> JMS topic to retrieve XML data, and display on a GIS map), with no success.
> I never get connected to the CHAT.DEMO topic. Any help on configuring both
> the client and server sides for a JavaScript app would be greatly
> appreciated. Once I get this working, I'd even be willing to share detailed
> info on the configuration I had to setup.
>
> Doug
>

Re: Chat JavaScript example

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi Doug,

this should not be the question. The message should be either TextMessage or
toString() will be used on any other kind of message. Take a look at
http://activemq.apache.org/ajax.html#Ajax-Receivingmessages. for more
details.

Please let us know if it works for you and file any bugs you find in the
process (with a test case if possible).

Cheers
--
Dejan Bosanac

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Tue, Sep 15, 2009 at 3:41 PM, Knight, Doug <dk...@mitre.org> wrote:

> All,
> I switched from using my sender page to using the console Send To
> capability. What I have discovered is that in all cases of sending from the
> admin page, both the Msgs Sent and Msgs Received counters increment.
> However, the receiver only generates output when I send well formed XML
> through the admin console send page. That leads me to my next two questions;
> 1) is it required that all messages through ActiveMQ be well formed XML? and
> 2) can I always expect the variable passed to the handler function to be a
> JavaScript object (i.e. containing XML)? Pardon me if this is an obvious
> question, I am new at working with message brokers, especially at this
> level.
>
> Doug
>
> -----Original Message-----
> From: Knight, Doug
> Sent: Monday, September 14, 2009 2:33 PM
> To: users@activemq.apache.org
> Subject: RE: Chat JavaScript example
>
> OK, I think I've got it. Now, I've got a barebones sender and receiver
> pair, based on the example in the link below. I see the topic get created
> when I refresh the receiver, and it has a single consumer, as expected. When
> I run the sender to send to that topic, I am having issues trying to issue
> output to the web page on the receiver from within the message handler. I
> originally tried the example using the alert box. The only time I managed to
> get an alert to work was when I had an error in the JavaScript contained in
> the handler. Is there anything special I need to do to output from the
> handler? I've tried direct document.writes, alert with simple text, even
> jQuery output (both with and without the .ready function. Any suggestions?
>
> Doug
>
> -----Original Message-----
> From: chubrilo@gmail.com [mailto:chubrilo@gmail.com] On Behalf Of Dejan
> Bosanac
> Sent: Monday, September 14, 2009 12:34 PM
> To: users@activemq.apache.org
> Subject: Re: Chat JavaScript example
>
> Hi Doug,
>
> ajax client connects to the servlet (called AjaxServlet) that runs inside
> jetty (or any other web container) that server like a proxy to the broker.
> Therefore, you should all jms related stuff inside your web application.
> Take a look at webapps/demo/WEB-INF/web.xml for an example of how to do it.
>
> Cheers
> --
> Dejan Bosanac
>
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
>
>
> On Mon, Sep 14, 2009 at 5:45 PM, Knight, Doug <dk...@mitre.org> wrote:
>
> > All,
> > From the JavaScript-based chat example, and various all-similar sources
> for
> > how to configure it (i.e. see
> > http://docs.codehaus.org/display/JETTY/Integrating+with+ActiveMQ for
> > example), I don't understand how the JavaScript client knows what server
> to
> > connect to. There is mentioned some info about adding to the web.xml, but
> is
> > this used by the JavaScript app or the Jetty server on the server side?
> I've
> > tried to "clone" the chat app to model my app after it (accessing a
> remote
> > JMS topic to retrieve XML data, and display on a GIS map), with no
> success.
> > I never get connected to the CHAT.DEMO topic. Any help on configuring
> both
> > the client and server sides for a JavaScript app would be greatly
> > appreciated. Once I get this working, I'd even be willing to share
> detailed
> > info on the configuration I had to setup.
> >
> > Doug
> >
>

RE: Chat JavaScript example

Posted by "Knight, Doug" <dk...@mitre.org>.
All,
I switched from using my sender page to using the console Send To capability. What I have discovered is that in all cases of sending from the admin page, both the Msgs Sent and Msgs Received counters increment. However, the receiver only generates output when I send well formed XML through the admin console send page. That leads me to my next two questions; 1) is it required that all messages through ActiveMQ be well formed XML? and 2) can I always expect the variable passed to the handler function to be a JavaScript object (i.e. containing XML)? Pardon me if this is an obvious question, I am new at working with message brokers, especially at this level. 

Doug

-----Original Message-----
From: Knight, Doug 
Sent: Monday, September 14, 2009 2:33 PM
To: users@activemq.apache.org
Subject: RE: Chat JavaScript example

OK, I think I've got it. Now, I've got a barebones sender and receiver pair, based on the example in the link below. I see the topic get created when I refresh the receiver, and it has a single consumer, as expected. When I run the sender to send to that topic, I am having issues trying to issue output to the web page on the receiver from within the message handler. I originally tried the example using the alert box. The only time I managed to get an alert to work was when I had an error in the JavaScript contained in the handler. Is there anything special I need to do to output from the handler? I've tried direct document.writes, alert with simple text, even jQuery output (both with and without the .ready function. Any suggestions?

Doug

-----Original Message-----
From: chubrilo@gmail.com [mailto:chubrilo@gmail.com] On Behalf Of Dejan Bosanac
Sent: Monday, September 14, 2009 12:34 PM
To: users@activemq.apache.org
Subject: Re: Chat JavaScript example

Hi Doug,

ajax client connects to the servlet (called AjaxServlet) that runs inside
jetty (or any other web container) that server like a proxy to the broker.
Therefore, you should all jms related stuff inside your web application.
Take a look at webapps/demo/WEB-INF/web.xml for an example of how to do it.

Cheers
--
Dejan Bosanac

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Mon, Sep 14, 2009 at 5:45 PM, Knight, Doug <dk...@mitre.org> wrote:

> All,
> From the JavaScript-based chat example, and various all-similar sources for
> how to configure it (i.e. see
> http://docs.codehaus.org/display/JETTY/Integrating+with+ActiveMQ for
> example), I don't understand how the JavaScript client knows what server to
> connect to. There is mentioned some info about adding to the web.xml, but is
> this used by the JavaScript app or the Jetty server on the server side? I've
> tried to "clone" the chat app to model my app after it (accessing a remote
> JMS topic to retrieve XML data, and display on a GIS map), with no success.
> I never get connected to the CHAT.DEMO topic. Any help on configuring both
> the client and server sides for a JavaScript app would be greatly
> appreciated. Once I get this working, I'd even be willing to share detailed
> info on the configuration I had to setup.
>
> Doug
>

Re: Chat JavaScript example

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi Doug,

ajax client connects to the servlet (called AjaxServlet) that runs inside
jetty (or any other web container) that server like a proxy to the broker.
Therefore, you should all jms related stuff inside your web application.
Take a look at webapps/demo/WEB-INF/web.xml for an example of how to do it.

Cheers
--
Dejan Bosanac

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Mon, Sep 14, 2009 at 5:45 PM, Knight, Doug <dk...@mitre.org> wrote:

> All,
> From the JavaScript-based chat example, and various all-similar sources for
> how to configure it (i.e. see
> http://docs.codehaus.org/display/JETTY/Integrating+with+ActiveMQ for
> example), I don't understand how the JavaScript client knows what server to
> connect to. There is mentioned some info about adding to the web.xml, but is
> this used by the JavaScript app or the Jetty server on the server side? I've
> tried to "clone" the chat app to model my app after it (accessing a remote
> JMS topic to retrieve XML data, and display on a GIS map), with no success.
> I never get connected to the CHAT.DEMO topic. Any help on configuring both
> the client and server sides for a JavaScript app would be greatly
> appreciated. Once I get this working, I'd even be willing to share detailed
> info on the configuration I had to setup.
>
> Doug
>