You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Brent Baxter <bb...@chariotsolutions.com> on 2008/02/29 19:08:30 UTC

AjaxServlet questions

Okay, so I have read nearly everything I can find on the ActiveMQ web site
and the various forums and I am still left with questions regarding how I
can use the AjaxServlet in my application.  Specifically what I seem to be
missing is how do I configure the AjaxServlet to use my ActiveMQ topics?

Specifically what I have in mind is this:

- Ajax-enabled web application using the AMQ amq.js and AjaxServlet (Jetty /
Tomcat)
- ActiveMQ running stand-alone
- Spring JMS stand-alone application

My desire is to have my Ajax-enabled web clients use the AMQ AjaxServlet to
subscribe to topics in my stand-alone AMQ broker.  Then, my Spring JMS
application will be publishing messages into the AMQ broker that I need
published out to my Ajax-enable web clients via the AMQ AjaxServlet.  From
what I have read it appears that I should be able to do this, but the devil
is in the details.

So, my questions are:

1. How do I configure the AjaxServlet to find my AMQ and related topics?
2. Or, is this just "auto-magically" done for me?
3. Or, do I need to be running AMQ embedded in the same servlet container as
my web application in order for this to work?
4. Or, and is is my worst fear, is none of this possible since the AMQ
AjaxServlet simply creates topics / queues on the fly for your web app and
does not integrate at all with the full AMQ broker?

Thanks in advance.
Brent


-- 
Brent Baxter
Chariot Solutions
bbaxter@chariotsolutions.com
Tel: 215-358-1780
Fax: 215-358-1781

Re: AjaxServlet questions

Posted by Eric Rodriguez <to...@gmail.com>.

Eric Rodriguez wrote:

>     function listenersInit() {
>         amq.addListener("anyID","topic://my_topic",myHandler.rcvDiff);
>     }

To make it clear:
"amq.addListener("anyID","topic://my_topic",myHandler.rcvDiff);"

does not need to be inside listenersInit(), that's just how I do it.



Re: AjaxServlet questions

Posted by Eric Rodriguez <to...@gmail.com>.
1. On the web.xml of your AjaxServlet make sure you have:
<context-param>
	<param-name>org.apache.activemq.brokerURL</param-name>
	<param-value>tcp://url.to.amqBroker:61616</param-value>
	<description>
		The URL of the Message Broker to connect to
	</description>
</context-param>

Now your servlet knows where the broker is.
2. On your HTML/JSP/Javascript subscribe to the topic/queue where your 
JMS app is publishing messages:
var myHandler =
	{
	 rcvDiff: function(message)
	 {
	   doSomething();
	 }
	};
	
	function listenersInit() {
		amq.addListener("anyID","topic://my_topic",myHandler.rcvDiff);
	}
3. You're ready to go. You don't need to embed AMQ (but you could if you 
want). if you want to send message or create a new topic/queue just do:
amq.sendMessage("my_queue",msg);

Regards,
Eric

Brent Baxter wrote:
> 
> So, my questions are:
> 
> 1. How do I configure the AjaxServlet to find my AMQ and related topics?
> 2. Or, is this just "auto-magically" done for me?
> 3. Or, do I need to be running AMQ embedded in the same servlet container as
> my web application in order for this to work?
> 4. Or, and is is my worst fear, is none of this possible since the AMQ
> AjaxServlet simply creates topics / queues on the fly for your web app and
> does not integrate at all with the full AMQ broker?
> 
> Thanks in advance.
> Brent
> 
>