You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by habumaster <ph...@ericsson.com> on 2011/01/13 23:13:42 UTC

Question about ajax.html examples on website

http://activemq.apache.org/ajax.html http://activemq.apache.org/ajax.html 

is the link I am referencing.

The statement: 
"The AMQ AjaxServlet needs to be installed in your webapplications to
support JMS over Ajax:"

I see this AjaxServlet installed in the ActiveMQ 5.4.1 install I am running.

Does this mean I must still create my own webapp to be able to use this
servlet?

I have an existing Ruby on Rails app on another port that needs to
communicate to ActiveMQ. 
The Ajax Javascript clients provided must be expecting a webapp running on
the same server to function.  
Am I correct? or is there something else I am missing :)

Thanks!
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3216811.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by habumaster <ph...@ericsson.com>.
Yes, do not send "\n" to ActiveMQ, it thinks that those are separate messages
and breaks them up.


habumaster wrote:
> 
> Using the amq-msg-type for Stomp->ActiveMQ messages from Ruby and
> ActiveMQ<->Ajax to the Browser with amq.js and prototype,js  
> 
> Had no problems when I did not use the header and we connected the Browser
> via Orbited.
> 
> Now we get 3 messages back from ActiveMQ for this single message. 
> 
> Phil   
> 

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3237234.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by habumaster <ph...@ericsson.com>.
Using the amq-msg-type for Stomp->ActiveMQ messages from Ruby and
ActiveMQ<->Ajax to the Browser with amq.js and prototype,js  

Had no problems when I did not use the header and we connected the Browser
via Orbited.

Ruby code:

javascript = render_to_string :update do |page|

                  page.insert_html :bottom,
"chat_message_list_#{params[:id]}", chat_message.to_html 

                  page << "$('chat_window_#{params[:id]}_body').scrollTop =
$('chat_window_#{params[:id]}_body').scrollHeight;"

                end

               
Orbited.send_data("CHANNEL_#{chat_message.window.workbench_id}", javascript)

Now we get 3 messages back from ActiveMQ for this single message. All this
JS has to be in one block to be run in the browser. Looking to change this
behavior back, or find a way to link these back together. 
Looking thru the messages now.........

Phil   
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3235218.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by habumaster <ph...@ericsson.com>.
Yes, that got me amq connections. It works! The "Proxying with Apache"  is a
good one. 
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3234387.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by Alex Dean <al...@crackpot.org>.
On Jan 22, 2011, at 9:23 AM, habumaster wrote:

> 
> 
> Alex Dean-2 wrote:
>> 
>> 
>> On Jan 21, 2011, at 11:13 PM, habumaster wrote:
>> 
>> 
>> Replies inline. It seems I am getting to 8161 and it is returning the
>> welcome page for ActiveMQ?

Yes, I agree.  More information below.


>>> 2. What URL do you visit to view your test web page?
>> 
>> I have run my own test send/receive web pages in the demo directory. They
>> work fine without having to redirect via a proxy, since I am local on the
>> server. 
>> 
>> What I progressed to - I login to my existing rails app I had running
>> using FireFox indcating the workbench I want. The rails app serves up that
>> workbench. Onload of the workbench, I have amq.init starting. I am
>> expecting amq client to be available. 
>> 
>> Login:
>> URL http://server:8080
>> 
>> Workbench:             
>> URL http://server:8080/workbenches/ID
>> 
>> 
>>> 3. Post the <script> tags you have in that page, and the JS code you're
> using to configure amq.js.
>> 
>> Application.js 
>> function startOV_amq(myChannel) {
>> 
>> 	var amq = org.activemq.Amq;
>> 
>>    var MyHandler = {
>> 		rcvMessage: function(message)
>> 		{ eval(message.data) }
>> 		};	
>> 		
>> 	amq.init({ uri: "/amq",
>> 	logging: true,
>> 	timeout: 45,
>> 	clientId: (new Date()).getTime().toString()});
>> 	
>> 	amq.addListener('MyHandler', myChannel, MyHandler.rcvMessage);
>> 	}
>> 
>> 
>> <%= javascript_include_tag :defaults, 'ov', 'amq_prototype_adapter', 'amq'
>> %>

Just curious why you're serving amq_prototype_adapter.js and amq.js from your Rails app instead of directly from ActiveMQ?  Do you have local changes of some kind to those libraries?  If not, I suggest just loading them from ActiveMQ itself.

>> 
>> 
>>> 4. Post the proxy configuration you've got in Apache.
>> 
>> ProxyRequests Off
>>      ProxyPass /amq http://localhost:8161 retry=10     
>>      ProxyPassReverse /amq http://localhost:8161           
>>      ProxyPassReverseCookiePath / /amq

As a test, this means you should be able to load http://server:8080/amq/demo/, which should be proxied to http://server:8161/demo - the path to the ActiveMQ demo application.  You should also be able to load http://server:8080/amq/demo/js/amq.js and http://server:8080/amq/demo/js/amq_prototype_adapter.js.

If those URLs are working, then you'll need to use:
  amq.init({ uri: "/amq/demo/amq" })

due to the default configuration in apache-activemq-5.4.2/webapps/demo/WEB-INF/web.xml:
  <servlet-mapping>
    <servlet-name>AjaxServlet</servlet-name>
    <url-pattern>/amq/*</url-pattern>
  </servlet-mapping>

>> 
>>> 5. Post a few examples of the Apache errors you see.
>> 
>> [Fri Jan 21 21:39:17 2011] [debug] mod_proxy_http.c(56): proxy: HTTP:
>> canonicalising URL //localhost:8161
>> [Fri Jan 21 21:39:17 2011] [debug] proxy_util.c(1488): [client
>> 47.102.211.208] proxy: http: found worker http://localhost:8161 for
>> http://localhost:8161/?timeout=45000&d=1295668347118&r=0.3465096321093155&clientId=1295668340376,

This should be a request for http://localhost:8161/demo/amq?timeout=45000&d=1295668347118&r=0.3465096321093155&clientId=1295668340376

I think the adjustments I suggest above will have that effect.

>>> 6. Post a few examples of whatever is filling the Firebug log.  It would
> be great to see a GET for polling, >and the response which comes back from
> ActiveMQ.
>> 
>> This was the most I could get since it spools by so fast :(
>> 
>> 47.102.211.208 - - [22/Jan/2011:08:24:26 -0600] "GET
>> /amq?timeout=45000&d=1295707035229&r=0.6207296420130076&clientId=1295706770151
>> HTTP/1.1" 200 6618 "http://47.105.91.75:8080/workbenches/12" "Mozilla/5.0
>> (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203
>> Firefox/3.6.13
>> 
>> And the incoming result 
>> 
>> Error occurred in poll. HTTP result: undefined, status: TypeError:
>> data.getElementsByTagName is not a function
>> Exception in the poll handler: <!-- Licensed to the Apache Software
>> Foundation (ASF) under one or more contributor license agreements. See the

Yup.  You're getting the HTML content of http://server:8161/ returned to you.  The amq.js code isn't getting the type of XML content it expects, and chaos ensues.  The messages are coming so fast because as soon as one request returns, the client immediately initiates a new request (which is what it's designed to do).

Let me know how it goes when you're able to make those adjustments.  Perhaps we should add a "Proxying with Apache" section to http://activemq.apache.org/ajax.html.

best,
alex


Re: Question about ajax.html examples on website

Posted by habumaster <ph...@ericsson.com>.

Alex Dean-2 wrote:
> 
> 
> On Jan 21, 2011, at 11:13 PM, habumaster wrote:
> 
> 
> Replies inline. It seems I am getting to 8161 and it is returning the
> welcome page for ActiveMQ?
> I thought through the NIO connector/selector I would be accessing the Ajax
> servelets?  
> 
>>1. Is your Ruby app Rails or something else?  Running via passenger,
mongrel, or other?
> 
> Rails via Passenger 
> 
>>2. What URL do you visit to view your test web page?
> 
> I have run my own test send/receive web pages in the demo directory. They
> work fine without having to redirect via a proxy, since I am local on the
> server. 
> 
> What I progressed to - I login to my existing rails app I had running
> using FireFox indcating the workbench I want. The rails app serves up that
> workbench. Onload of the workbench, I have amq.init starting. I am
> expecting amq client to be available. 
> 
> Login:
> URL http://server:8080
> 
> Workbench:             
> URL http://server:8080/workbenches/ID
> 
> 
>>3. Post the <script> tags you have in that page, and the JS code you're
using to configure amq.js.
> 
> Application.js 
> function startOV_amq(myChannel) {
> 
> 	var amq = org.activemq.Amq;
>     
>     var MyHandler = {
> 		rcvMessage: function(message)
> 		{ eval(message.data) }
> 		};	
> 		
> 	amq.init({ uri: "/amq",
> 	logging: true,
> 	timeout: 45,
> 	clientId: (new Date()).getTime().toString()});
> 	
> 	amq.addListener('MyHandler', myChannel, MyHandler.rcvMessage);
> 	}
> 
> 
> <%= javascript_include_tag :defaults, 'ov', 'amq_prototype_adapter', 'amq'
> %>
> 
> <%= javascript_tag "Event.observe(window, 'load', function ()
> {startOV_amq('CHANNEL_#{@workbench.id}')})" %>
> 
> <script src="/javascripts/prototype.js?1280327078"
> type="text/javascript"></script> 
> 10<script src="/javascripts/effects.js?1280327078"
> type="text/javascript"></script> 
> 11<script src="/javascripts/dragdrop.js?1280327078"
> type="text/javascript"></script> 
> 12<script src="/javascripts/controls.js?1280327078"
> type="text/javascript"></script> 
> 13<script src="/javascripts/oneview.js?1292534305"
> type="text/javascript"></script> 
> 14<script src="/javascripts/amq_prototype_adapter.js?1290766826"
> type="text/javascript"></script> 
> 15<script src="/javascripts/amq.js?1290766826"
> type="text/javascript"></script> 
> 16<script src="/javascripts/application.js?1295653682"
> type="text/javascript"></script> 
> 
>>4. Post the proxy configuration you've got in Apache.
> 
> ProxyRequests Off
>       ProxyPass /amq http://localhost:8161 retry=10     
>       ProxyPassReverse /amq http://localhost:8161           
>       ProxyPassReverseCookiePath / /amq
> 
>>5. Post a few examples of the Apache errors you see.
> 
> [Fri Jan 21 21:39:17 2011] [debug] mod_proxy_http.c(56): proxy: HTTP:
> canonicalising URL //localhost:8161
> [Fri Jan 21 21:39:17 2011] [debug] proxy_util.c(1488): [client
> 47.102.211.208] proxy: http: found worker http://localhost:8161 for
> http://localhost:8161/?timeout=45000&d=1295668347118&r=0.3465096321093155&clientId=1295668340376,
> referer: http://47.105.91.75:8080/workbenches/12
> [Fri Jan 21 21:39:17 2011] [debug] mod_proxy.c(966): Running scheme http
> handler (attempt 0)
> [Fri Jan 21 21:39:17 2011] [debug] mod_proxy_http.c(1976): proxy: HTTP:
> serving URL
> http://localhost:8161/?timeout=45000&d=1295668347118&r=0.3465096321093155&clientId=1295668340376
> [Fri Jan 21 21:39:17 2011] [debug] proxy_util.c(2044): proxy: HTTP: has
> acquired connection for (localhost)
> [Fri Jan 21 21:39:17 2011] [debug] proxy_util.c(2102): proxy: connecting
> http://localhost:8161/?timeout=45000&d=1295668347118&r=0.3465096321093155&clientId=1295668340376
> to localhost:8161
> [Fri Jan 21 21:39:17 2011] [debug] proxy_util.c(2195): proxy: connected
> /?timeout=45000&d=1295668347118&r=0.3465096321093155&clientId=1295668340376
> to localhost:8161
> [Fri Jan 21 21:39:17 2011] [debug] mod_proxy_http.c(1753): proxy: start
> body send
> [Fri Jan 21 21:39:17 2011] [debug] mod_proxy_http.c(1842): proxy: end body
> send
> [Fri Jan 21 21:39:17 2011] [debug] proxy_util.c(2062): proxy: HTTP: has
> released connection for (localhost)
> [Fri Jan 21 21:39:17 2011] [debug] mod_proxy_http.c(56): proxy: HTTP:
> canonicalising URL //localhost:8161
> 
>>6. Post a few examples of whatever is filling the Firebug log.  It would
be great to see a GET for polling, >and the response which comes back from
ActiveMQ.
> 
> This was the most I could get since it spools by so fast :(
> 
> 47.102.211.208 - - [22/Jan/2011:08:24:26 -0600] "GET
> /amq?timeout=45000&d=1295707035229&r=0.6207296420130076&clientId=1295706770151
> HTTP/1.1" 200 6618 "http://47.105.91.75:8080/workbenches/12" "Mozilla/5.0
> (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203
> Firefox/3.6.13
> 
> And the incoming result 
> 
> Error occurred in poll. HTTP result: undefined, status: TypeError:
> data.getElementsByTagName is not a function
> Exception in the poll handler: <!-- Licensed to the Apache Software
> Foundation (ASF) under one or more contributor license agreements. See the
> NOTICE file distributed with this work for additional information
> regarding copyright ownership. The ASF licenses this file to You under the
> Apache License, Version 2.0 (the "License"); you may not use this file
> except in compliance with the License. You may obtain a copy of the
> License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
> applicable law or agreed to in writing, software distributed under the
> License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
> CONDITIONS OF ANY KIND, either express or implied. See the License for the
> specific language governing permissions and limitations under the License.
> --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html
> PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta
> http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> <title>Apache ActiveMQ</title> <style type="text/css" media="screen">
> @import url(/admin/styles/sorttable.css); @import
> url(/admin/styles/type-settings.css); @import url(/admin/styles/site.css);
> @import url(/admin/styles/prettify.css); </style> <script
> type='text/javascript' src='/js/common.js'></script> <script
> type='text/javascript' src='/js/css.js'></script> <script
> type='text/javascript' src='/js/standardista-table-sorting.js'></script>
> <script type='text/javascript' src='/js/prettify.js'></script>
> <script>addEvent(window, 'load', prettyPrint)</script> </head> <body> <div
> class="white_box"> <div class="header"> <div class="header_l"> <div
> class="header_r"> </div> </div> </div> <div class="content"> <div
> class="content_l"> <div class="content_r"> <div> <!-- Banner --> <div
> id="asf_logo"> <div id="activemq_logo">  http://activemq.apache.org/
> ActiveMQ   http://www.apache.org/ ASF  </div> </div> <div
> class="top_red_bar"> <div id="site-breadcrumbs"> 
> 
> 
>>Hopefully something in there will help point out what the problem is.
> 
> alex
> 

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3231484.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by Alex Dean <al...@crackpot.org>.
On Jan 21, 2011, at 11:13 PM, habumaster wrote:

> 
> Going the servlet route.. Your app is running on a main server, not a virtual
> one I am guessing.

I've run this kind of setup successfully on a single machine (OSX), on multiple physical servers (Centos5), and on multiple OpenVZ guests (Centos5 host & guests).

> Mine is virtual and with the apache config you spec'd, I understand it was a
> starting point.
> I have ActiveMQ 5.4.2 running on the same server. Jetty.xml is in the
> activemq.xml file, so Ajax servlet should be there. Using the
> amq_prototype_adapter.js.
> 
> I have a Ruby app on :8080 on that same server that serves up a page. 
> The page calls amq.init with "\amq" onload. Using the ProxyPass etc in
> Apache with web logs set to debug.  
> As my GET goes out to \amq, I see in the apache logs the proxy getting setup
> to from the web client to localhost:8161 then back from 8161 to /amq. There
> is a body send, body end and a release. then the dame thing all over again
> in the apache error_log. I can see the client cycling like mad with multiple
> GETs to /amq. The Firebug log fills up in no time.
> Is this something in particular with the amq.js?
> 
> Did you start at this point as well when you brought your app up with this
> setup?
> Trying to figure out where to go from here.
> 

Having a little trouble following this problem report.  Some more specifics would help a lot, I think.

1. Is your Ruby app Rails or something else?  Running via passenger, mongrel, or other?
2. What URL do you visit to view your test web page?
3. Post the <script> tags you have in that page, and the JS code you're using to configure amq.js.
4. Post the proxy configuration you've got in Apache.
5. Post a few examples of the Apache errors you see.
6. Post a few examples of whatever is filling the Firebug log.  It would be great to see a GET for polling, and the response which comes back from ActiveMQ.

Hopefully something in there will help point out what the problem is.

alex

Re: Question about ajax.html examples on website

Posted by habumaster <ph...@ericsson.com>.
Going the servlet route.. Your app is running on a main server, not a virtual
one I am guessing.
Mine is virtual and with the apache config you spec'd, I understand it was a
starting point.
I have ActiveMQ 5.4.2 running on the same server. Jetty.xml is in the
activemq.xml file, so Ajax servlet should be there. Using the
amq_prototype_adapter.js.
 
I have a Ruby app on :8080 on that same server that serves up a page. 
The page calls amq.init with "\amq" onload. Using the ProxyPass etc in
Apache with web logs set to debug.  
As my GET goes out to \amq, I see in the apache logs the proxy getting setup
to from the web client to localhost:8161 then back from 8161 to /amq. There
is a body send, body end and a release. then the dame thing all over again
in the apache error_log. I can see the client cycling like mad with multiple
GETs to /amq. The Firebug log fills up in no time.
Is this something in particular with the amq.js?
 
Did you start at this point as well when you brought your app up with this
setup?
Trying to figure out where to go from here.

Thanks!

Phil   
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3231032.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by habumaster <ph...@ericsson.com>.

AHA! quick & dirty

for (prop in message) {
   alert(prop+message[prop]);
}

message.data is where it is at....
 
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3225477.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by Alex Dean <al...@crackpot.org>.
On Jan 19, 2011, at 11:21 PM, habumaster wrote:

> 
> Ah you can send Stomp to ActiveMQ and get text back out - just add the
> {'amq-msg_type'='text'} header to the stomp send and it goes as text.

One typo.  You need all hyphens, no underscores.
  {'amq-msg-type'=>'text'}

> 
> 
> Problem is now I am getting back in the response message as [object Text] in
> the alert() call in the example. Using the prototype adapter and amq.js.
> 
> "received [object Text]"
> 
> How do I get the text out of the "message" here?
> Can you shed some light on it?

If you're using Firefox/Firebug, you can also do "console.log(message)" instead of "alert(message)".  That will give you much more insight into what "message" is.

alex

Re: Question about ajax.html examples on website

Posted by habumaster <ph...@ericsson.com>.
Ah you can send Stomp to ActiveMQ and get text back out - just add the
{'amq-msg_type'='text'} header to the stomp send and it goes as text.


Problem is now I am getting back in the response message as [object Text] in
the alert() call in the example. Using the prototype adapter and amq.js.

"received [object Text]"

How do I get the text out of the "message" here?
Can you shed some light on it?

Thanks!  
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3225472.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by habumaster <ph...@ericsson.com>.
I figured it out - STOMP -> ActiveMQ then ActiveMQ -> Browser with the amq.js
library is the problem. 
Send and receive with amq from Browser -> ActiveMQ and ActiveMQ -> Browser
on both sides works fine. 
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3225434.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by habumaster <ph...@ericsson.com>.
Thanks Alex!

My config mirrors yours (Passenger,etc)

Still having issues with the demo js clients
It seems like I am asking for something from the queue that does not exist 

2 Problems

1. EOFException on injection of a message to a queue
2. Web Polling via JQuery/Prototype gets empty AjaxResponses

Setup: 
ActiveMQ 5.4.2 running

Ruby script to push item to a queue. 

#!/usr/bin/ruby
require 'rubygems'
require 'stomp'
conn=Stomp::Client.new("", "", "localhost", "61613", false)
conn.publish("/topic//topic/ActiveMQFeed", "Hello from Ruby!",
{'amq-msg_type'=>'text'})

I can see the queue created and items enqueued   

<topic name="/topic/ActiveMQFeed">
<stats size="0" consumerCount="0" enqueueCount="4" dequeueCount="0"/>
</topic>

Problem 1: 
I do see a EOFException on every insert of an item

2011-01-18 17:01:33,647 | DEBUG | Setting up new connection id:
ID:localhost.localdomain-36434-1295385138968-4:10, address: /127.0.0.1:45487
| org.apache.activemq.broker.TransportConnection | ActiveMQ Transport:
tcp:///127.0.0.1:45487
2011-01-18 17:01:33,654 | DEBUG | Transport failed: java.io.EOFException |
org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ
Transport: tcp:///127.0.0.1:45487
java.io.EOFException
        at java.io.DataInputStream.readByte(DataInputStream.java:267)
        at
org.apache.activemq.transport.stomp.StompWireFormat.readLine(StompWireFormat.java:146)
        at
org.apache.activemq.transport.stomp.StompWireFormat.parseAction(StompWireFormat.java:162)
        at
org.apache.activemq.transport.stomp.StompWireFormat.unmarshal(StompWireFormat.java:92)
        at
org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:227)
        at
org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:219)
        at
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
        at java.lang.Thread.run(Thread.java:636)




Made a myTest.html in the demo dir:

<html>
<head>
<title>Chat</title>
//<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/amq_prototype_adapter.js"></script>
<script type="text/javascript" src="js/amq.js"></script>
<script type="text/javascript"> 
var amq=org.activemq.Amq;
var MyHandler = {
	rcvMessage: function(message)
   {
    alert("received "+message);
    }
};
//amq.init({ uri: 'amq', logging: true, timeout: 45 

amq.init({ uri: 'amq', 
           sessionInitializedCallBack: function() {
		amq.addListener("testHandler", "/topic/ActiveMQFeed",
MyHandler.rcvMessage);
           }         
});
</script>
</head>
<body>
</body>
</html>


Problem 2:

I can see the web page polling for AjaxResponses (using both JQuery and
Prototytpe and getting empty responses
  
Firebug output below:

http://localhost:8161/demo/amq
timeout=25000&d=1295394122219&r=0.7264120959960031

http://localhost:8161/demo/js/prototype.js(line 1421)

Response Headersview source
Content-Type	text/xml;charset=ISO-8859-1
Cache-Control	no-cache
Content-Length	33
Server	Jetty(7.1.6.v20100715)
Request Headersview source
Host	localhost:8161
User-Agent	Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7)
Gecko/20100726 CentOS/3.6-3.el5.centos Firefox/3.6.7
Accept	text/javascript, text/html, application/xml, text/xml, */*
Accept-Language	en-us,en;q=0.5
Accept-Encoding	gzip,deflate
Accept-Charset	ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive	115
Connection	keep-alive
X-Requested-With	XMLHttpRequest
X-Prototype-Version	1.6.1
Referer	http://localhost:8161/demo/myTest.html
Cookie	JSESSIONID=rl792t9bbe6l89o4uxli0m62

ParamsHeadersPostPutResponseCacheHTML
d	1295394122219
r	0.7264120959960031
timeout	25000
Response Headersview source
Content-Type	text/xml;charset=ISO-8859-1
Cache-Control	no-cache
Content-Length	33
Server	Jetty(7.1.6.v20100715)
Request Headersview source
Host	localhost:8161
User-Agent	Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7)
Gecko/20100726 CentOS/3.6-3.el5.centos Firefox/3.6.7
Accept	text/javascript, text/html, application/xml, text/xml, */*
Accept-Language	en-us,en;q=0.5
Accept-Encoding	gzip,deflate
Accept-Charset	ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive	115
Connection	keep-alive
X-Requested-With	XMLHttpRequest
X-Prototype-Version	1.6.1
Referer	http://localhost:8161/demo/myTest.html
Cookie	JSESSIONID=rl792t9bbe6l89o4uxli0m62


Response
<ajax-response>
</ajax-response>

Turned on Stomp debugging:

2011-01-18 17:01:44,722 | DEBUG | GET
client=org.apache.activemq.web.AjaxWebClient@1f40b69
session=i1mx9l5bkiyxjqkstf49ghie clientId=null uri=/demo/amq
query=timeout=25000&d=1295391704675&r=0.2505788100026941 |
org.apache.activemq.web.MessageListenerServlet | qtp949587-35
2011-01-18 17:01:44,722 | DEBUG | doMessage timeout=25000 |
org.apache.activemq.web.MessageListenerServlet | qtp949587-35


2011-01-18 17:18:21,013 | INFO  | Started
SelectChannelConnector@0.0.0.0:8161 | org.eclipse.jetty.util.log | main
2011-01-18 17:18:41,568 | INFO  | Transport failed: java.io.EOFException |
org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ
Transport: tcp:///127.0.0.1:56318










-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Question-about-ajax-html-examples-on-website-tp3216811p3224550.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Question about ajax.html examples on website

Posted by Alex Dean <al...@crackpot.org>.
On Jan 13, 2011, at 4:13 PM, habumaster wrote:

> 
> http://activemq.apache.org/ajax.html http://activemq.apache.org/ajax.html 
> 
> is the link I am referencing.
> 
> The statement: 
> "The AMQ AjaxServlet needs to be installed in your webapplications to
> support JMS over Ajax:"
> 
> I see this AjaxServlet installed in the ActiveMQ 5.4.1 install I am running.
> 
> Does this mean I must still create my own webapp to be able to use this
> servlet?
> 
> I have an existing Ruby on Rails app on another port that needs to
> communicate to ActiveMQ. 
> The Ajax Javascript clients provided must be expecting a webapp running on
> the same server to function.  
> Am I correct? or is there something else I am missing :)
> 
> Thanks!

If you want to communicate with ActiveMQ from your server-side Ruby code, take a look at ActiveMessaging.  http://code.google.com/p/activemessaging/wiki/ActiveMessaging  You don't need the AjaxServlet to do that.

The AjaxServlet allows your clients (web browsers) to communicate with ActiveMQ.  We deploy Ruby/Rails via Passenger, using Apache as the web server.  Apache also serves as a proxy for ActiveMQ, so ajax requests stay in the same domain and don't violate JavaScript's same-origin policy.

This Apache configuration, in your main server config or in a VirtualHost, should get you started, though it might need to be tuned to your specific needs.
  ProxyRequests Off
  ProxyPass /amq http://localhost:8161 retry=10
  ProxyPassReverse /amq http://localhost:8161
  ProxyPassReverseCookiePath / /amq

A browser request for http://localhost/amq/ becomes a request for http://localhost:8161/.

alex

alex