0

I followed the examples of the activemq site to start an embedded broker:

BrokerService broker = new BrokerService();
broker.addConnector("tcp://localhost:8161");
broker.start();

Then I perform some posts to the following URL to use the REST capabilities of ActiveMQ:

"http://localhost:8161/api/message/EventQueue?type=queue"

When I send the post using a standalone broker it all works fine, but when I use the embedded broker it hangs the process.

I am using active mq version 5.8.0

What I am missing?

Thanks

Clifford
  • 88,407
  • 13
  • 85
  • 165
Marcelo Flores
  • 114
  • 1
  • 13

1 Answers1

0

You are adding a TCP connector which uses the openwire protocol but you are sending post requests as if it's an HTTP connector. You need to add an HTTP transport based connector and use that one to do your posts.

You must of course ensure that you have the classes on the classpath for http, which is in the activemq-http bundle.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42
  • I already tried to use broker.addConnector( "http ://localhost:8161" ); but it gives me the following exception: Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.HandlerContainer. I already tried to add the package in Maven but still got the exception. Do you know how can I include the class? – Marcelo Flores Dec 30 '13 at 14:00
  • You need to bring in all the correct jars, http is not in activemq broker, its in activemq-http – Tim Bish Dec 30 '13 at 20:54
  • I thought that all the activemq libs were contained inside activemq-all – Marcelo Flores Jan 06 '14 at 12:33
  • I think it was left out by accident on the latest version as the module was renamed. Try it and see, won't hurt. – Tim Bish Jan 06 '14 at 20:07
  • 1
    Thanks it runs now. But when I try to send a post to the embedded broker with a Json string it gives me the following error:com.thoughtworks.xstream.io.StreamException: : only whitespace content allowed before start tag and not s (position: START_DOCUMENT seen s... @1:1). I think there is some configuration missing for the broker to accept the Json message. Do you know where I can find information about that? I tried to look inside the activemq site but could not find something related. Thanks! – Marcelo Flores Jan 08 '14 at 10:57
  • @MarceloFlores Did you get any further with this? – DagR Dec 30 '14 at 12:38
  • @DagR, The problem was solved by adding all the libraries by hand, as the activemq-all was missing the activemq-http inside it. The StreamException was being thrown because I passed the wrong parameters to the post method, instead of passing the json text, I was passing the path of the file. thus raising a malformated exception – Marcelo Flores Jul 11 '15 at 15:44