You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Zanderfax <jd...@pearldf.org> on 2007/09/04 19:36:46 UTC

Looking for Help ActiveMQ and Jetty

I am trying to configure Jetty to act as the servlet server for a ActiveMQ
broker.  

I have a broker configured so I can send and receive messages via stomp, and
it it is working successfully. I am trying to integrate the broker into a
web page so I can created a GUI for an application that I am developing.

I have read all the documentation on this site as well as the Jetty site and
I have tried all the various combinations of configuration that are listed
with no luck. I have looked at the demo extensively to see if I could figure
it out, as well as the template stuff from the Webtide folks.  I am a
seasoned Perl developer and a novice Java developer so I am behind on the
knowledge that is presumed by the authors of the documentation. I have been
trying to solve this for about 3 months now.

So my question is this:  Is there any resource available that offers step by
step instructions on how to configure Jetty to talk with an external broker
and can use the amq.js mechanism for forwarding the messages to a web page?

Ultimately I would like to have a set of queues that I can send and receive
message from via a web UI for my application.

Any help would be greatly appreciated!!

Thanks in advance,

J
-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12482925
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by Zanderfax <jd...@pearldf.org>.
Thanks for the info, and the patience.


I will download Firebug and see what I can see.  You will most likely be
hearing from me.

J

chago wrote:
> 
> I have tried your example and it works for me with my new amq.js file and
> the one that is in the head. I suspect that their is some component
> outside the javascript and servlets that is silently failing for you.
> FWIW, I have disabled persistence in my configuration:
> 
>     <context-param>
>         <param-name>org.apache.activemq.brokerURL</param-name>
>         <param-value>vm://localhost?broker.persistent=false</param-value>
>     </context-param>
> 
> 
> The first two connections that you see should be a GET and a POST. 
> 
> The POST should will look like this:
> http://localhost:8080/webapp/amq
>   - destination=channel://gnip
>   - message=gnip
>   - type=listen
> 
> (Note: the response from the server is an empty string)
> 
> The first GET should have a timeout value of 0 and looks like this:
> http://localhost:8080/webapp/amq
>   - timeout=0
> 
> Both of these should return very quickly. Then another GET request is made
> without a timeout value. The MessageListenerServlet uses a default timeout
> of 25 secs. These GET requests are the long polls and are the basis for
> the Comet approach to AJAX calls. It works very well with an asynchronous
> interface like JMS.
> 
> As for debugging, here are some general approaches I have used.
> 
> #1 - Firebug
> Firebug is a developer's plugin for Firefox browser that lets you easily
> monitor XmlHttpRequest (AJAX) calls made by the client. It shows you the
> message that was sent out and the response returned by the server. It
> shows you these in real time so you can see your request sending and
> waiting for a response. 
> 
> By using this, you can make sure that the client is actually sending the
> message. You can also verify that the server responds with a reply; proper
> or not. There is also a two connection limit to the server, so this tool
> will show you how many outstanding connections there are.
> 
> #2 - Live Debugging
> I sometime remote debug or debug an embedded Jetty server by placing
> breakpoints in MessageListenerServlet.
> 
> #3 - Debug Logging
> I generally turn on full debug output for as many components that I can.
> The MessageListenerServlet has debug statements that are useful when faced
> with a strange problem.
> 
> Hope it helps.
> 
> Feel free to Skype me if you want to walk thru it in more detail. You will
> find me by searching for skype.at.visualxs.dot.com.
> 
> 
> Zanderfax wrote:
>> 
>> Attached is the logfile with debug info. 
>> 
>> I started activemq, then jetty, loaded the web page and sent 2 messages. 
>> 
>> I see the connections but there is nothing transfered.
>> 
>> Any ideas?
>> 
>>  http://www.nabble.com/file/p12665375/activemq.log activemq.log  
>> 
>> chago wrote:
>>> 
>>> http://activemq.apache.org/how-do-i-enable-debug-logging.html
>>> 
>>> 
>>> Zanderfax wrote:
>>>> 
>>>> I made the changes with no apparent effect.  Where would I look for the
>>>> debug log or stack trace if they exist?
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12757627
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by chago <na...@visualxs.com>.
I have tried your example and it works for me with my new amq.js file and the
one that is in the head. I suspect that their is some component outside the
javascript and servlets that is silently failing for you. FWIW, I have
disabled persistence in my configuration:

    <context-param>
        <param-name>org.apache.activemq.brokerURL</param-name>
        <param-value>vm://localhost?broker.persistent=false</param-value>
    </context-param>


The first two connections that you see should be a GET and a POST. 

The POST should will look like this:
http://localhost:8080/webapp/amq
  - destination=channel://gnip
  - message=gnip
  - type=listen

(Note: the response from the server is an empty string)

The first GET should have a timeout value of 0 and looks like this:
http://localhost:8080/webapp/amq
  - timeout=0

Both of these should return very quickly. Then another GET request is made
without a timeout value. The MessageListenerServlet uses a default timeout
of 25 secs. These GET requests are the long polls and are the basis for the
Comet approach to AJAX calls. It works very well with an asynchronous
interface like JMS.

As for debugging, here are some general approaches I have used.

#1 - Firebug
Firebug is a developer's plugin for Firefox browser that lets you easily
monitor XmlHttpRequest (AJAX) calls made by the client. It shows you the
message that was sent out and the response returned by the server. It shows
you these in real time so you can see your request sending and waiting for a
response. 

By using this, you can make sure that the client is actually sending the
message. You can also verify that the server responds with a reply; proper
or not. There is also a two connection limit to the server, so this tool
will show you how many outstanding connections there are.

#2 - Live Debugging
I sometime remote debug or debug an embedded Jetty server by placing
breakpoints in MessageListenerServlet.

#3 - Debug Logging
I generally turn on full debug output for as many components that I can. The
MessageListenerServlet has debug statements that are useful when faced with
a strange problem.

Hope it helps.

Feel free to Skype me if you want to walk thru it in more detail. You will
find me by searching for skype.at.visualxs.dot.com.


Zanderfax wrote:
> 
> Attached is the logfile with debug info. 
> 
> I started activemq, then jetty, loaded the web page and sent 2 messages. 
> 
> I see the connections but there is nothing transfered.
> 
> Any ideas?
> 
>  http://www.nabble.com/file/p12665375/activemq.log activemq.log  
> 
> chago wrote:
>> 
>> http://activemq.apache.org/how-do-i-enable-debug-logging.html
>> 
>> 
>> Zanderfax wrote:
>>> 
>>> I made the changes with no apparent effect.  Where would I look for the
>>> debug log or stack trace if they exist?
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12735606
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by Zanderfax <jd...@pearldf.org>.
Attached is the logfile with debug info. 

I started activemq, then jetty, loaded the web page and sent 2 messages. 

I see the connections but there is nothing transfered.

Any ideas?

http://www.nabble.com/file/p12665375/activemq.log activemq.log  

chago wrote:
> 
> http://activemq.apache.org/how-do-i-enable-debug-logging.html
> 
> 
> Zanderfax wrote:
>> 
>> I made the changes with no apparent effect.  Where would I look for the
>> debug log or stack trace if they exist?
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12665375
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by chago <na...@visualxs.com>.
http://activemq.apache.org/how-do-i-enable-debug-logging.html


Zanderfax wrote:
> 
> I made the changes with no apparent effect.  Where would I look for the
> debug log or stack trace if they exist?
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12633606
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by Zanderfax <jd...@pearldf.org>.
I made the changes with no apparent effect.  Where would I look for the debug
log or stack trace if they exist?



chago wrote:
> 
> FWIW, I can't reproduce the timing issue... It seems your original code
> runs fine on my setup.
> 
> Keep in mind that I am using a different version of amq.js. (See JIRA
> issue  http://issues.apache.org/activemq/browse/AMQ-1377 AMQ-1377 . )
> 
> Find the debug log and see if there were any exceptions or stack traces.
> 
> -- jim
> 
> 
> chago wrote:
>> 
>> It appears to be some kind of timing issue. The code above works on my
>> setup.
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12627388
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by chago <na...@visualxs.com>.
FWIW, I can't reproduce the timing issue... It seems your original code runs
fine on my setup.

Keep in mind that I am using a different version of amq.js. (See JIRA issue 
http://issues.apache.org/activemq/browse/AMQ-1377 AMQ-1377 . )

Find the debug log and see if there were any exceptions or stack traces.

-- jim


chago wrote:
> 
> It appears to be some kind of timing issue. The code above works on my
> setup.
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12535383
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by chago <na...@visualxs.com>.
Try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>Observatory</title>
    <script type="text/javascript" src="amq/amq.js"></script>
	<script type="text/javascript">
                amq.uri='amq';
                

		var myHandler = {
			rcvMessage: function(message) {
				alert("received " + message);
			}
		};

		var dest = 'channel://gnip';
		//var dest = 'topic://gnip';

		function listen() {
			amq.addListener('gnip', dest, myHandler.rcvMessage);
		}

		function sendMsg() {
			amq.sendMessage(dest, "<message item='hello'/>");
			alert("message sent");
		}
	</script>
</head>
<body>
<p>Observatory</p>
<p>
	<input type="button" value="Listen" onclick="listen()"/>
	<input type="button" value="Fire one" onclick="sendMsg()"/>
</p>

</body>
</html>

I added the listen code to a handler that gets called when the listen button
is pressed. I am using a modified version of amq.js, and when I ran your
code against my copy I never received a response to my listen POST request.

It appears to be some kind of timing issue. The code above works on my
setup.

-- jim
-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12535357
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by Zanderfax <jd...@pearldf.org>.
Ok, It looks like the webpage is talking via the servlet, I am seeing post
and get messages in the log file when I hit the send button on my page.
Below is the HTML I am using:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
    <title>Observatory</title>
    <script type="text/javascript" src="amq/amq.js"></script>
    <script type="text/javascript">amq.uri='amq';</script>
    <script type="text/javascript">
        var myHandler =
            {
                rcvMessage: function(message) {
                    alert("received "+message);
                }
            };


     amq.addListener(gnip, 'channel://gnip', myHandler.rcvMessage);

     function sendMsg() {
        amq.sendMessage('channel://gnip', "<message item='hello'/>");
        alert("message sent");
      }
    </script>
</head>
<body>
    Observatory <br>
    <input type = "button" value = "Fire one" onclick = "sendMsg()" />

</body>
</html>


My question is am I addressing the queue gnip properly in the html?

J




Zanderfax wrote:
> 
> I tried them, but I could not get them to work.  Sorry for all the dumb
> questions.
> 
> J
> 
> chago wrote:
>> 
>> That's correct. Have you tried the examples in web demo?
>> 
>> 
>> Zanderfax wrote:
>>> 
>>> So I don't have to configure anything on the Jetty side to have the
>>> topics available?
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12534612
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by Zanderfax <jd...@pearldf.org>.
I tried them, but I could not get them to work.  Sorry for all the dumb
questions.

J

chago wrote:
> 
> That's correct. Have you tried the examples in web demo?
> 
> 
> Zanderfax wrote:
>> 
>> So I don't have to configure anything on the Jetty side to have the
>> topics available?
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12534131
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by chago <na...@visualxs.com>.
That's correct. Have you tried the examples in web demo?


Zanderfax wrote:
> 
> So I don't have to configure anything on the Jetty side to have the topics
> available?
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12533912
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by Zanderfax <jd...@pearldf.org>.
So I don't have to configure anything on the Jetty side to have the topics
available?

J


chago wrote:
> 
> When using the javascript client (amq.js) you subscribe to topics and
> queues in your javascript code. For example, in the chat.js file when the
> 'join' button is pressed, an event fires that is coded as:
> 
> amq.addListener('chat', 'topic://CHAT.DEMO', chatHandlerCallback);
> 
> Any messages posted to that topic (regardless of whether the source is
> another client's javascript call or a server-side JMS call) will be
> received by the javascript function chatHandler(message).
> 
> -- jim
> 
> 
> Zanderfax wrote:
>> 
>> Next question, how do I define what queue I want to watch?  I have tried
>> to follow the docs on the Jetty page, but I am not sure that I have the
>> right things in the jetty.xml and jetty-plus.xml files. Or is that not
>> where you set that up?  The docs are not very clear on this..
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12533778
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by chago <na...@visualxs.com>.
When using the javascript client (amq.js) you subscribe to topics and queues
in your javascript code. For example, in the chat.js file when the 'join'
button is pressed, an event fires that is coded as:

amq.addListener('chat', 'topic://CHAT.DEMO', chatHandlerCallback);

Any messages posted to that topic (regardless of whether the source is
another client's javascript call or a server-side JMS call) will be received
by the javascript function chatHandler(message).

-- jim


Zanderfax wrote:
> 
> Next question, how do I define what queue I want to watch?  I have tried
> to follow the docs on the Jetty page, but I am not sure that I have the
> right things in the jetty.xml and jetty-plus.xml files. Or is that not
> where you set that up?  The docs are not very clear on this..
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12533724
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by Zanderfax <jd...@pearldf.org>.
Ok, I understand that.

Next question, how do I define what queue I want to watch?  I have tried to
follow the docs on the Jetty page, but I am not sure that I have the right
things in the jetty.xml and jetty-plus.xml files. Or is that not where you
set that up?  The docs are not very clear on this..

J

ttmdev wrote:
> 
> You use the http: scheme to connect your client to a remote or external
> broker. You also have available other schemes like https:, tcp:, and ssl:
> to connect to a remote broker. Just depends what protocol you want to use. 
> 
> The vm: scheme is used to start an intra-JVM or embedded broker. So if you
> use vm://bobert, you will launch and intra-JVM broker called "bobert". 
> 
> Joe
> 
> 
> Zanderfax wrote:
>> 
>> So if my broker is running on server bob, I would change the value to
>> vm://bob:1234 or would it be http://bob:1234?
>> 
>> J
>> 
>> 
>> 
>> chago wrote:
>>> 
>>> If you download ActiveMQ, the web demo module contains a few demos that
>>> use Jetty with an embedded broker talking to web pages using the amq.js
>>> script file. The embedded broker is configured in the web.xml file by
>>> specifying the vm://localhost value. If you want to use an external
>>> broker, you can just change this URL.
>>> 
>>> Be sure to use Jetty 6.1.4. I had problems using Jetty 6.1.5.
>>> 
>>> Please, point out any specific problems you run into.
>>> 
>>> -- jim
>>> 
>>> 
>>> Zanderfax wrote:
>>>> 
>>>> So my question is this:  Is there any resource available that offers
>>>> step by step instructions on how to configure Jetty to talk with an
>>>> external broker and can use the amq.js mechanism for forwarding the
>>>> messages to a web page?
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12533367
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by ttmdev <jo...@ttmsolutions.com>.
You use the http: scheme to connect your client to a remote or external
broker. You also have available other schemes like https:, tcp:, and ssl: to
connect to a remote broker. Just depends what protocol you want to use. 

The vm: scheme is used to start an intra-JVM or embedded broker. So if you
use vm://bobert, you will launch and intra-JVM broker called "bobert". 

Joe


Zanderfax wrote:
> 
> So if my broker is running on server bob, I would change the value to
> vm://bob:1234 or would it be http://bob:1234?
> 
> J
> 
> 
> 
> chago wrote:
>> 
>> If you download ActiveMQ, the web demo module contains a few demos that
>> use Jetty with an embedded broker talking to web pages using the amq.js
>> script file. The embedded broker is configured in the web.xml file by
>> specifying the vm://localhost value. If you want to use an external
>> broker, you can just change this URL.
>> 
>> Be sure to use Jetty 6.1.4. I had problems using Jetty 6.1.5.
>> 
>> Please, point out any specific problems you run into.
>> 
>> -- jim
>> 
>> 
>> Zanderfax wrote:
>>> 
>>> So my question is this:  Is there any resource available that offers
>>> step by step instructions on how to configure Jetty to talk with an
>>> external broker and can use the amq.js mechanism for forwarding the
>>> messages to a web page?
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12533171
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by Zanderfax <jd...@pearldf.org>.
So if my broker is running on server bob, I would change the value to
vm://bob:1234 or would it be http://bob:1234?

J



chago wrote:
> 
> If you download ActiveMQ, the web demo module contains a few demos that
> use Jetty with an embedded broker talking to web pages using the amq.js
> script file. The embedded broker is configured in the web.xml file by
> specifying the vm://localhost value. If you want to use an external
> broker, you can just change this URL.
> 
> Be sure to use Jetty 6.1.4. I had problems using Jetty 6.1.5.
> 
> Please, point out any specific problems you run into.
> 
> -- jim
> 
> 
> Zanderfax wrote:
>> 
>> So my question is this:  Is there any resource available that offers step
>> by step instructions on how to configure Jetty to talk with an external
>> broker and can use the amq.js mechanism for forwarding the messages to a
>> web page?
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12533017
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Looking for Help ActiveMQ and Jetty

Posted by chago <na...@visualxs.com>.
If you download ActiveMQ, the web demo module contains a few demos that use
Jetty with an embedded broker talking to web pages using the amq.js script
file. The embedded broker is configured in the web.xml file by specifying
the vm://localhost value. If you want to use an external broker, you can
just change this URL.

Be sure to use Jetty 6.1.4. I had problems using Jetty 6.1.5.

Please, point out any specific problems you run into.

-- jim


Zanderfax wrote:
> 
> So my question is this:  Is there any resource available that offers step
> by step instructions on how to configure Jetty to talk with an external
> broker and can use the amq.js mechanism for forwarding the messages to a
> web page?
> 

-- 
View this message in context: http://www.nabble.com/Looking-for-Help-ActiveMQ-and-Jetty-tf4379195s2354.html#a12490950
Sent from the ActiveMQ - User mailing list archive at Nabble.com.