Hi, I've added some material regarding consuming messages with REST
http://activemq.apache.org/rest.html#REST-Consuming Basically, you have to keep session alive between your GET requests and set prefetch size to 1 if you want to have multiple consumers. 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 GFranxman wrote: > I'm trying to use the rest interface that comes as part of the web demo and > running into an issue reading from queues. > > Before I go too far, here are some clues as to my environment: > > $ java -version > java version "1.5.0_15" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04) > Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_15-b04, mixed mode) > > $ uname -a > Linux kwlx99 2.6.9-11.ELsmp #1 SMP Fri May 20 18:25:30 EDT 2005 x86_64 > x86_64 x86_64 GNU/Linux > > > Starting from a scratch install of 5.1.0, I changed the log level to include > DEBUG, then start her up. > > >From the browser, writing to the queue ( FOO.BAR ) seems to work fine. The > admin acknowledges that the queue is filling. But the 'receive a message' > tool returns nothing. Not trusting the weirdness that browsers can > introduce, I thought I'd demonstrate the issue from the command line: > > # putting a message into the FOO.BAR queue > curl -i -d destination=FOO.BAR -d type=queue -d timeout=100 -d > body=\<p\>somejunk\</p\> http://localhost:8161/demo/message > > # which responds: > HTTP/1.1 200 OK > Expires: Thu, 01 Jan 1970 00:00:00 GMT > Set-Cookie: JSESSIONID=sxf3y08bbzp3;Path=/demo > messageID: ID:localhost-51855-1222380098613-2:15:1:1:1 > Content-Length: 0 > Server: Jetty(6.1.9) > > That seems to go pretty fast. I can run that a couple times to put a few > messages in FOO.BAR The admin confirms the messages are in the queue. But > then to fetch the messages: > > # fetch the first message > curl -i http://localhost:8161/demo/message/FOO.BAR?timeout=1000\&type=queue > > That works the first time, and pulls the first item in the queue. > > HTTP/1.1 200 OK > Expires: Thu, 01 Jan 1970 00:00:00 GMT > Set-Cookie: JSESSIONID=1etfu1q27p2vm;Path=/demo > Content-Type: text/xml; charset=iso-8859-1 > destination: queue://FOO.BAR > id: ID:localhost-51855-1222380098613-2:15:1:1:1 > Content-Length: 16 > Server: Jetty(6.1.9) > > <p>somejunk</p> > But then any further requests return nothing. > > # fetch next first message > curl -i http://localhost:8161/demo/message/FOO.BAR?timeout=1000\&type=queue > > # which responds after significant waiting: > HTTP/1.1 204 No Content > Expires: Thu, 01 Jan 1970 00:00:00 GMT > Set-Cookie: JSESSIONID=1a0o5fs121jh3;Path=/demo > Content-Type: text/xml; charset=iso-8859-1 > Server: Jetty(6.1.9) > > And the admin confirms that the message has not been delivered. Other > variations I have tried include: > > curl -i > http://localhost:8161/demo/message?destination=FOO.BAR\&timeout=1000\&type=queue > and > curl -i > http://localhost:8161/demo/message/FOO.BAR?destination=FOO.BAR\&timeout=1000\&type=queue > > But nothing works. > The log file during one of these requests goes something to the tune of: > > DEBUG InactivityMonitor - 10001 ms elapsed since last write > check. > DEBUG log - REQUEST /demo/message on > [EMAIL PROTECTED] > DEBUG log - > [EMAIL PROTECTED] > DEBUG log - session=null > DEBUG log - servlet=MessageServlet > DEBUG log - chain=session->MessageServlet > DEBUG log - servlet holder=MessageServlet > DEBUG log - call filter session > DEBUG log - call servlet MessageServlet > DEBUG TransportConnection - Setting up new connection: > vm://localhost#32 > DEBUG AbstractRegion - Adding consumer: > ID:localhost-51855-1222380098613-2:17:-1:1 > DEBUG MessageServlet - Receiving message(s) from: > queue://FOO.BAR with timeout: 20000 > DEBUG AbstractRegion - Adding consumer: > ID:localhost-51855-1222380098613-2:17:1:1 > DEBUG MessageServlet - Received 0 message(s) > DEBUG log - continuation > [EMAIL PROTECTED],pending > DEBUG InactivityMonitor - 10000 ms elapsed since last write > check. > DEBUG InactivityMonitor - 9999 ms elapsed since last write > check. > DEBUG AbstractRegion - Removing consumer: > ID:localhost-51855-1222380098613-2:5:1:1 > DEBUG AbstractRegion - Removing consumer: > ID:localhost-51855-1222380098613-2:5:-1:1 > DEBUG TransportConnection - Stopping connection: vm://localhost#8 > DEBUG TransportConnection - Stopped connection: vm://localhost#8 > DEBUG TransportConnection - Connection Stopped: vm://localhost#8 > DEBUG InactivityMonitor - 10000 ms elapsed since last write > check. > DEBUG InactivityMonitor - 10000 ms elapsed since last write > check. > DEBUG log - resume continuation > [EMAIL PROTECTED],pending,expired > DEBUG log - REQUEST /demo/message on > [EMAIL PROTECTED] > DEBUG log - > [EMAIL PROTECTED] > DEBUG log - > session=org.mortbay.jetty.servlet.HashSessionManager$Session:[EMAIL PROTECTED] > DEBUG log - servlet=MessageServlet > DEBUG log - chain=session->MessageServlet > DEBUG log - servlet holder=MessageServlet > DEBUG log - call filter session > DEBUG log - call servlet MessageServlet > DEBUG MessageServlet - Receiving message(s) from: > queue://FOO.BAR with timeout: 20000 > DEBUG MessageServlet - Received 0 message(s) > DEBUG log - RESPONSE /demo/message 204 > DEBUG log - continuation still pending null > DEBUG log - EOF > DEBUG log - continuation > [EMAIL PROTECTED] > > > > Somethings broken, but perusing the source to MessageServlet and > MessageServletHelper, I don't see where things are going off of the tracks. > Can anyone spot it? > > > >