You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by yesnid <ns...@pelco.com> on 2008/09/04 22:14:26 UTC
Re: REST: eternal HTTP status 204
I am having the same issue, what is the solution?
sv75 wrote:
>
> I'm trying simple python program to using ActiveMQ via HTTP.
> I managed to send message via HTTP/POST, but have problems getting them
> via GET (or DELETE). While first request receive message (with HTTP status
> 200), all other requests has status 204 (not modified?) and no body after
> long delay (~5 seconds). It start working after restaring amq - but only
> one message again. What I'm doing wrong? Any advices, please? I see the
> same behavior with web browser when using "send/recieve message" in demo
> so i don't think it is my program.
>
> I tried 4.1.1 and 5.0 snapshots - same behavior. And using web browser JDK
> 1.6, Ubuntu 7.04. amq working under root.
>
> =====
> #!/usr/bin/python
> import httplib2
> import urllib
> from time import *
>
> BASE = "http://localhost:8161/demo/" # AMQ 5.0
> # BASE = "http://localhost:8080/activemq-web-demo/" # AMQ 4.1
> client = httplib2.Http()
> dtype = "queue"
>
> def SendMessage(queue, body):
> url = BASE + "message/" + queue
> print "[%s] -> %s" % (body, url) # "destination": queue,
> body = urllib.urlencode({"type": dtype, "body" : body})
> return client.request(url, "POST", body,
> headers={"Content-type": "application/x-www-form-urlencoded"})
>
> def GetMessage(queue, method):
> url = BASE + "message/" + queue + "?" + urllib.urlencode({"type":
> dtype, "timeout": 1})
> print url,'->'
> headers, body = client.request(url, method, None, None)
> print 'STATUS:',headers["status"]
> return body
>
> queue = "queue22"
> SendMessage(queue, "test message2")
> SendMessage(queue, "test message3")
> SendMessage(queue, "test message4")
> sleep(1)
> print GetMessage(queue, "GET")
> print GetMessage(queue, "GET")
> print GetMessage(queue, "GET")
>
>
--
View this message in context: http://www.nabble.com/REST%3A-eternal-HTTP-status-204-tp13269025p19319033.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: REST: eternal HTTP status 204
Posted by Dejan Bosanac <de...@ttmsolutions.com>.
Unfortunately no,
the web client that do all the work is tied to a HTTP session.
Cheers
--
Dejan Bosanac
http://www.ttmsolutions.com - get a free ActiveMQ user guide
ActiveMQ in Action - http://www.manning.com/snyder/
Scripting in Java - http://www.scriptinginjava.net
yesnid wrote:
> Hello Dejan,
>
> Thank you for the direction on this issue, is there a way to make this
> connection sessionless?
>
> Thank you,
>
>
>
> Dejan Bosanac-3 wrote:
>
>> The problem is that you have to keep your HTTP session between your GET
>> requests. So, try something like
>>
>> wget --save-cookies cookies.txt --load-cookies cookies.txt
>> --keep-session-cookies
>> http://localhost:8161/demo/message/TEST1?type=queue
>>
>> if you're playing with wget, or something similar in your scripting code
>> (or just use Stomp ;))
>>
>> Cheers
>>
>> --
>> Dejan Bosanac
>>
>>
>> http://www.ttmsolutions.com - get a free ActiveMQ user guide
>>
>> ActiveMQ in Action - http://www.manning.com/snyder/
>> Scripting in Java - http://www.scriptinginjava.net
>>
>>
>>
>>
>> yesnid wrote:
>>
>>> I am having the same issue, what is the solution?
>>>
>>> sv75 wrote:
>>>
>>>
>>>> I'm trying simple python program to using ActiveMQ via HTTP.
>>>> I managed to send message via HTTP/POST, but have problems getting them
>>>> via GET (or DELETE). While first request receive message (with HTTP
>>>> status
>>>> 200), all other requests has status 204 (not modified?) and no body
>>>> after
>>>> long delay (~5 seconds). It start working after restaring amq - but only
>>>> one message again. What I'm doing wrong? Any advices, please? I see the
>>>> same behavior with web browser when using "send/recieve message" in demo
>>>> so i don't think it is my program.
>>>>
>>>> I tried 4.1.1 and 5.0 snapshots - same behavior. And using web browser
>>>> JDK
>>>> 1.6, Ubuntu 7.04. amq working under root.
>>>>
>>>> =====
>>>> #!/usr/bin/python
>>>> import httplib2
>>>> import urllib
>>>> from time import *
>>>>
>>>> BASE = "http://localhost:8161/demo/" # AMQ 5.0
>>>> # BASE = "http://localhost:8080/activemq-web-demo/" # AMQ 4.1
>>>> client = httplib2.Http()
>>>> dtype = "queue"
>>>>
>>>> def SendMessage(queue, body):
>>>> url = BASE + "message/" + queue
>>>> print "[%s] -> %s" % (body, url) # "destination": queue,
>>>> body = urllib.urlencode({"type": dtype, "body" : body})
>>>> return client.request(url, "POST", body,
>>>> headers={"Content-type": "application/x-www-form-urlencoded"})
>>>>
>>>> def GetMessage(queue, method):
>>>> url = BASE + "message/" + queue + "?" + urllib.urlencode({"type":
>>>> dtype, "timeout": 1})
>>>> print url,'->'
>>>> headers, body = client.request(url, method, None, None)
>>>> print 'STATUS:',headers["status"]
>>>> return body
>>>>
>>>> queue = "queue22"
>>>> SendMessage(queue, "test message2")
>>>> SendMessage(queue, "test message3")
>>>> SendMessage(queue, "test message4")
>>>> sleep(1)
>>>> print GetMessage(queue, "GET")
>>>> print GetMessage(queue, "GET")
>>>> print GetMessage(queue, "GET")
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>
Re: REST: eternal HTTP status 204
Posted by yesnid <ns...@pelco.com>.
Hello Dejan,
Thank you for the direction on this issue, is there a way to make this
connection sessionless?
Thank you,
Dejan Bosanac-3 wrote:
>
> The problem is that you have to keep your HTTP session between your GET
> requests. So, try something like
>
> wget --save-cookies cookies.txt --load-cookies cookies.txt
> --keep-session-cookies
> http://localhost:8161/demo/message/TEST1?type=queue
>
> if you're playing with wget, or something similar in your scripting code
> (or just use Stomp ;))
>
> Cheers
>
> --
> Dejan Bosanac
>
>
> http://www.ttmsolutions.com - get a free ActiveMQ user guide
>
> ActiveMQ in Action - http://www.manning.com/snyder/
> Scripting in Java - http://www.scriptinginjava.net
>
>
>
>
> yesnid wrote:
>> I am having the same issue, what is the solution?
>>
>> sv75 wrote:
>>
>>> I'm trying simple python program to using ActiveMQ via HTTP.
>>> I managed to send message via HTTP/POST, but have problems getting them
>>> via GET (or DELETE). While first request receive message (with HTTP
>>> status
>>> 200), all other requests has status 204 (not modified?) and no body
>>> after
>>> long delay (~5 seconds). It start working after restaring amq - but only
>>> one message again. What I'm doing wrong? Any advices, please? I see the
>>> same behavior with web browser when using "send/recieve message" in demo
>>> so i don't think it is my program.
>>>
>>> I tried 4.1.1 and 5.0 snapshots - same behavior. And using web browser
>>> JDK
>>> 1.6, Ubuntu 7.04. amq working under root.
>>>
>>> =====
>>> #!/usr/bin/python
>>> import httplib2
>>> import urllib
>>> from time import *
>>>
>>> BASE = "http://localhost:8161/demo/" # AMQ 5.0
>>> # BASE = "http://localhost:8080/activemq-web-demo/" # AMQ 4.1
>>> client = httplib2.Http()
>>> dtype = "queue"
>>>
>>> def SendMessage(queue, body):
>>> url = BASE + "message/" + queue
>>> print "[%s] -> %s" % (body, url) # "destination": queue,
>>> body = urllib.urlencode({"type": dtype, "body" : body})
>>> return client.request(url, "POST", body,
>>> headers={"Content-type": "application/x-www-form-urlencoded"})
>>>
>>> def GetMessage(queue, method):
>>> url = BASE + "message/" + queue + "?" + urllib.urlencode({"type":
>>> dtype, "timeout": 1})
>>> print url,'->'
>>> headers, body = client.request(url, method, None, None)
>>> print 'STATUS:',headers["status"]
>>> return body
>>>
>>> queue = "queue22"
>>> SendMessage(queue, "test message2")
>>> SendMessage(queue, "test message3")
>>> SendMessage(queue, "test message4")
>>> sleep(1)
>>> print GetMessage(queue, "GET")
>>> print GetMessage(queue, "GET")
>>> print GetMessage(queue, "GET")
>>>
>>>
>>>
>>
>>
>
>
>
>
--
View this message in context: http://www.nabble.com/REST%3A-eternal-HTTP-status-204-tp13269025p19333298.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: REST: eternal HTTP status 204
Posted by Dejan Bosanac <de...@ttmsolutions.com>.
The problem is that you have to keep your HTTP session between your GET
requests. So, try something like
wget --save-cookies cookies.txt --load-cookies cookies.txt
--keep-session-cookies http://localhost:8161/demo/message/TEST1?type=queue
if you're playing with wget, or something similar in your scripting code
(or just use Stomp ;))
Cheers
--
Dejan Bosanac
http://www.ttmsolutions.com - get a free ActiveMQ user guide
ActiveMQ in Action - http://www.manning.com/snyder/
Scripting in Java - http://www.scriptinginjava.net
yesnid wrote:
> I am having the same issue, what is the solution?
>
> sv75 wrote:
>
>> I'm trying simple python program to using ActiveMQ via HTTP.
>> I managed to send message via HTTP/POST, but have problems getting them
>> via GET (or DELETE). While first request receive message (with HTTP status
>> 200), all other requests has status 204 (not modified?) and no body after
>> long delay (~5 seconds). It start working after restaring amq - but only
>> one message again. What I'm doing wrong? Any advices, please? I see the
>> same behavior with web browser when using "send/recieve message" in demo
>> so i don't think it is my program.
>>
>> I tried 4.1.1 and 5.0 snapshots - same behavior. And using web browser JDK
>> 1.6, Ubuntu 7.04. amq working under root.
>>
>> =====
>> #!/usr/bin/python
>> import httplib2
>> import urllib
>> from time import *
>>
>> BASE = "http://localhost:8161/demo/" # AMQ 5.0
>> # BASE = "http://localhost:8080/activemq-web-demo/" # AMQ 4.1
>> client = httplib2.Http()
>> dtype = "queue"
>>
>> def SendMessage(queue, body):
>> url = BASE + "message/" + queue
>> print "[%s] -> %s" % (body, url) # "destination": queue,
>> body = urllib.urlencode({"type": dtype, "body" : body})
>> return client.request(url, "POST", body,
>> headers={"Content-type": "application/x-www-form-urlencoded"})
>>
>> def GetMessage(queue, method):
>> url = BASE + "message/" + queue + "?" + urllib.urlencode({"type":
>> dtype, "timeout": 1})
>> print url,'->'
>> headers, body = client.request(url, method, None, None)
>> print 'STATUS:',headers["status"]
>> return body
>>
>> queue = "queue22"
>> SendMessage(queue, "test message2")
>> SendMessage(queue, "test message3")
>> SendMessage(queue, "test message4")
>> sleep(1)
>> print GetMessage(queue, "GET")
>> print GetMessage(queue, "GET")
>> print GetMessage(queue, "GET")
>>
>>
>>
>
>