activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sv75 <>
Subject Problem with HTTP/REST
Date Fri, 09 May 2008 18:07:04 GMT

I'm playng with AMQ 5.1 and HTTP/REST in demo application works strange  :(

Posting to http://localhost:8161/demo/message/myQueue works fine, but I have
problems with GET.
It works first time, but then I always get HTTP status 204 and empty body,
with lots of pending message in queues. The following problems is always
reproduced. After restarting AMQ:

$ wget
HTTP request sent, awaiting response... 200 OK
Length: 21 [text/xml]
(works fine, next message)

$ wget
HTTP request sent, awaiting response... 204 No Content
(and no body)

And then I get status 204 until AMQ is restarted. So, I can GET only single
message. I'm very confused. 
I think I make some very basic error :(( 

I also wrote simple client in Python that handle cookie -- same result.


import httplib2
import urllib
from time import sleep

BASE = "http://localhost:8161/demo/message/"
client = httplib2.Http(".cache")
cookie = None

def SendMessage(queue, body):
    url = BASE + queue
    print "[%s] -> %s" % (body, url)
    body = urllib.urlencode({"type": "queue", "body" : body})
    headers, body = client.request(url, "POST", body,
    headers={"Content-type": "application/x-www-form-urlencoded"})        
    print headers

def GetMessage(queue):
    global cookie
    url = BASE +  queue + "?" + urllib.urlencode({"type": "queue",
"readTimeout": 1000})
    print url,'->'
    headers = {}
    if cookie:
       headers['Cookie'] = cookie
    print headers   
    response, body = client.request(url, "GET", None, headers)
    print response
       cookie = response['set-cookie'] 
    return body

queue = "myQueue"
SendMessage(queue, "test message1")
SendMessage(queue, "test message2")
SendMessage(queue, "test message3")
print GetMessage(queue)
print GetMessage(queue)
print GetMessage(queue)

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message