activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Configuring REST/HTTP
Date Sat, 13 Jan 2007 06:39:19 GMT
I'm using activemq-4.1.0 (binary distribution) on a Debian/Linux AMD64. I'm
running amq as a standalone server by calling:


with the standard configuration available in the binary download. All went
quite right. It's possible to connect to the server via jconsole (JMX) and I'm
able to run your example applications (the ruby examples via STOMP are really
nice). But now I want to experiment with REST and there are some basic

My usage scenario: Using amq as a standalone message broker, connecting a bunch
of php-clients (consumer) to a server application (ruby) over amq message
queues. Therby I want to use the REST functionality of amq by communicationg to
amq through a http or https connection.

How do I have to configure amq to be able to do REST processing ? I know
from your documentation, that I have to configure and map the
"MessageServlet".  But where in the "conf/activemq.xml" I have to place
the mapping ? How does the mapping looks like ? And how can I consume a
posted message i.e. from jconsole through a simple http client like curl
? Following my activemq.xml with which I tried to do the thing:

  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
  <broker brokerName="localhost" useJmx="true" xmlns="">
    <!-- In ActiveMQ 4, you can setup destination policies -->
          <policyEntry topic="FOO.>">
              <strictOrderDispatchPolicy />
              <lastImageSubscriptionRecoveryPolicy />
        <journaledJDBC journalLogFiles="5" dataDirectory="${activemq.base}/activemq-data"/>
       <transportConnector name="openwire" uri="tcp://localhost:61616" discoveryUri="multicast://default"/>
       <transportConnector name="ssl"     uri="ssl://localhost:61617"/>
       <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
       <transportConnector name="http"   uri="http://localhost:8080"/>
      <networkConnector name="default-nc" uri="multicast://default"/>

Starting the amq (bin/activemq) amq shows all configured transport connectors
comming up correctly. After that I'm running jconsole and connect to the
running amq. There I add a message queue named "web" via the "Broker Operations"
"addQueue" command and produce a new textmessage on the newly created "web"
queue using its "sendTextMessage" command to queue the string "hello". All this
went quite well (I checked the message being there via the "browse" command of 
the "web" queue). Now I tried to consume the message via curl:

   curl http://localhost:8080/queue/web  

and get following response:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 400 </title>
<body><h2>HTTP ERROR: 400</h2><pre>No clientID header specified</pre>
<p>RequestURI=/queue/web</p><p><i><small><a href="">
Powered by Jetty://</a></small></i></p><br/>

Additionally the amd logs: "WARN  HttpTunnelServlet    - No clientID header specified"

After that I controlled the status of my "web" queue, but nothing happens. All
attribute values keep its state (i.e.  EnqueueCount 1 DequeueCount 0). Second
try I called curl like this:

   curl -H "clientID: id67"  http://localhost:8080/queue/web

to submit a "clientID". After that curl gives no output at all but amd logs following:

   WARN  HttpTunnelServlet  - The clientID header specified is invalid. Client 
                              sesion has not yet been established for it: id67

How do I receive a valid clientID or how can I initiate a client session respectivily ?

At that time I give up because there are too many possibilities in being wrong.
I hope you can tell me what's going wrong.


PS: I'm using activemq for the first time and I'm not very familiar with all
that xml configuration stuff in the java world. Using ruby and or ruby/rails
make configuration tons lighter. But nevertheless your message passing system
is quite well and so I do really want to use it in my projects.  

View raw message