activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmontrasio <pa...@paolomontrasio.com>
Subject A novice's experience
Date Mon, 18 Sep 2006 15:27:29 GMT

I'm posting this to help polishing the documentation and provide some hints
to other newcomers like me.
This post is a little long, so I start telling you that there is an happy
ending: at the (very) end of the day I managed to make everything work, keep
reading on to see how I did it :-)

I discovered only yesterday that new technology called Comet (I happened to
think "how does meebo.com work?" and googled for it). I read some articles
in various blogs and quickly find out about ActiveMQ which looked perfect as
the messaging system for the demo I wanted to set up. 

I downloaded ActiveMQ 4.0.1 and Jetty 6.0.0 on my Linux box (Debian 3),
installed them and started them up.
I tested the Javascript interface to ActiveMQ using the demos bundled with
Jetty (the ajax activemq-web-demo applications) and then I wrote one myself.
Being totally new to Jetty (I'm a Tomcat user) and to JMS or any similar
technology I failed to realized that Jetty was using an internal instance of
the messaging system. That cost me time when I repeatedly tried and failed
to send messages to those web clients from a Java program running from the
console of my box.

Hower before reaching that point I had to figure out how to write the Java
program. I modeled it on the ActiveMQ Hello World application listed at
http://www.activemq.org/site/hello-world.html
That has been immensely useful, but there are a few things to fix in the
code:

1) All the references to org.activemq classes should be changed to
org.apache.activemq
2) The line with org.activemq.broker.impl.Main.main(args); fails to compile.
That class doesn't exist anymore in any jar file included in the
distribution. I found a substitute in
org.apache.activemq.console.Main.main(args). I really don't know if this is
the right class, but the application compiled, started and connected to
ActiveMQ.

Actually, when the application starts I get a strange error message:

ERROR: java.lang.RuntimeException: Failed to execute start task. Reason:
java.io.IOException: Could load xbean factory:java.lang.NoClassDefFoundError

I wrote that it is strange because that error doesn't prevent my application
from working. Furthermore being able to load something hardly seems an
error, hower I'm sure there is a good reason for that choice of words.

Anyway, I run into big troubles now. It took me a lot of time to realize
that my web clients were connecting to the messaging system running inside
Jetty while the Java application was connecting to the standalone instance
of ActiveMQ. When I realized it I modified the web.xml file of
activemq-web-demo as follows:

<param-name>org.apache.activemq.brokerURL</param-name>
<param-value>tcp://localhost:61616</param-value>

and

<param-name>org.apache.activemq.embeddedBroker</param-name>
<param-value>false</param-value>

That shut down the internal instance and made Jetty connect to the
standalone ActiveMQ.

I spent another hour before figuring out the correct argument for the
createTopic method. The first thing I tried was topic://FOO.BAR, which is
what the Javascript interface uses. The Java binding requires only the name
so the right line of code was

Destination destination = session.createTopic("FOO.BAR")

That fixed the application and, joy!, I was able to see the messages sent by
my web clients and send messages to them.

At the end of the day I had my demo working, and some questions. Maybe
somebody can answer them

1) The ajax demos in activemq-web-demo define two variables, topic and
membership, and set them to the same value. For instance the chat demo use
the value "topic://CHAT.DEMO" for both. The topic is used in

amq.addListener('chat', chatTopic, room._chat) and
amq.removeListener('chat', chatTopic)

and the membership is used in

amq.sendMessage(chatMembership, messageText)

The question is: the argument of sendMessage is the topic name and it's only
a bad design that it uses a different variable?

2) The org.apache.activemq.console.Main class is really what I should use?
Is it linked in some way to the error message I'm getting at run time?

A final consideration. I lost some time due to some glitches in the
documentation, but the fact that I got my demo working in a day being
totally new to this technologies is an indicator of the good quality of the
software and the community around it (wiki, blogs, etc.), so thanks
everybody and I hope to have contributed my 2 cents.


-- 
View this message in context: http://www.nabble.com/A-novice%27s-experience-tf2292008.html#a6366058
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message