activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerald Weber <gerald.we...@besharp.at>
Subject Embedded Broker / AJAXServlet / Jetty
Date Tue, 20 Mar 2012 07:27:40 GMT
Hi all,
i'm using activemq 5.4.3 together with Jetty 8.1.2.

I built a java program using an embedded broker in a thread. The thread creates a topic, reads
messages from ZeroMQ and sends them to the topic.
In the program, i enabled a jetty embedded server using the AJAXServlet in a ServletContextHandler
(addServlet).

After that, a HTML/JS page using amq.js is connecting to the jetty with the uri in the amq.init
call.
My problem:
"Error occurred in poll. HTTP result: 0, status: parsererror". in the Firefox console.

Facts:
- I wrote a java test program subscribing to the topic and printing the messages to the console.
The topic exists and the messages are displayed correctly.
- The messages are text containing JSON format.
- If i connect with the browser to the jetty url / port (http://127.0.0.1:8080/amq), nothing
happens. After a timeout (25s),
"<ajax-response></ajax-response>" is displayed although messages were available
during that time.

So i guess my Jetty setup is wrong, ..somewhere.

The code initializing Jetty is here:
                        QueuedThreadPool threadPool = new QueuedThreadPool();
                        threadPool.setMaxThreads(30);

                Server server = new Server(8080);
            server.setSendDateHeader(true);
            server.setThreadPool(threadPool);
            server.setSendServerVersion(true);

                ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
                context.setContextPath("/");
                context.setInitParameter("org.apache.activemq.brokerURL", brokerURL);
                context.setInitParameter("org.apache.activemq.embeddedBroker", "true");

                server.setHandler(context);

                context.addServlet(new ServletHolder(new  AjaxServlet()),"/amq/*");
                context.addServlet(new ServletHolder(new  HelloServlet()),"/hello");

                server.start();
                server.join();

Jetty basically works, a GET http://127.0.0.1:8080/hello works.


Can anyone give me a hint or tell me what i did wrong ?

regards,
gw

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message