You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Sandeep Chayapathi <sa...@wssource.com> on 2007/06/28 20:47:47 UTC

ActiveMQ and REST

Hi all,
 Recently I started trying out accessing messages via the REST protocol. I
have successfully setup a network transport for http on port 8080 and I can
see the jetty webserver responding to queries.

 However I have hit a roadblock with accessing the messages itself. The 
http://activemq.apache.org/rest-protocols.html REST  documentation is very
sparse and most of the posts in the user forum isn't encouraging either. 

 Using the script given below, all I get is the following xml response:

------
<org.apache.activemq.command.BrokerInfo>
  <brokerId>
    <value>ID:localhost-55384-1182955702539-1:0</value>
  </brokerId>
  <brokerURL>http://localhost:8080</brokerURL>
  <slaveBroker>false</slaveBroker>
  <masterBroker>false</masterBroker>
  <faultTolerantConfiguration>false</faultTolerantConfiguration>
  <networkConnection>false</networkConnection>
  <duplexConnection>false</duplexConnection>
  <peerBrokerInfos/>
  <brokerName>localhost</brokerName>
  <connectionId>0</connectionId>
------

 The questions are:

1. has anyone successfully used the REST api, if so how ?
2. any links to a working code (other than using the AjaxServlet) ?

Thanks.

Here is a simple perl script that tries to subscribe to a queue and get
messages:

--------
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use HTTP::Request;

my $client_id = "foo4";
my $amq_server = "http://localhost:8080";
my $queue = "queue/test";

my $ua = LWP::UserAgent->new();
$ua->agent("Firefox");

my $req = HTTP::Request->new(HEAD=> "$amq_server");
$req->header( clientID => $client_id);

print "HEAD request\n";

&get_data($req);

$req = HTTP::Request->new(POST=> "$amq_server/subscribe/$client_id/$queue");
$req->header( clientID => $client_id);

print "SUBSCRIBE request\n";

&get_data($req);

print "GET request\n";

$req = HTTP::Request->new(GET => "$amq_server/$queue");
$req->header( clientID => $client_id);

&get_data($req);

sub get_data(){
    my $req = shift;

    my $res = $ua->request($req);
    
    # Check the outcome of the response
    if ($res->is_success) {
        print $res->content;
    }else {
        print $res->status_line, "\n";
    }    
}
----------
-- 
View this message in context: http://www.nabble.com/ActiveMQ-and-REST-tf3996071s2354.html#a11348716
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ and REST

Posted by Sandeep Chayapathi <sa...@wssource.com>.
Hi,
 I have tried out the web samples. Is there anyway to configure the bundled
jetty server to support REST, as described 
http://activemq.apache.org/rest.html here  ? I mean, do I just add a web.xml
into the activemq/conf ?

 Actually the confusion was that we were trying to implement a mod_perl
handler to do what the REST servlets are doing, hence the usage of the
http-tunnel. Thanks,

- Sandeep


James.Strachan wrote:
> 
> Have you tried using the web samples? Its got some simple HTML links
> so your web browser using HTML forms can post a message to a queue and
> receive one from a queue etc? Maybe best to start there?
> 
> On 6/28/07, Sandeep Chayapathi <sa...@wssource.com> wrote:
>>
>> sure, I would like to contribute to the community by documenting the REST
>> api.
>>
>> However I don't know where to start on the REST stuff. I have tried to
>> follow the code but I can't figure out how to subscribe and get messages
>> via
>> REST. I have looked at the  http://activemq.apache.org/rest.html REST
>> document, does that mean I have to have a web.xml with the mapping ?
>>
>> Thanks.
>>
>>
>> James.Strachan wrote:
>> >
>> >
>> >>  However I have hit a roadblock with accessing the messages itself.
>> The
>> >> http://activemq.apache.org/rest-protocols.html REST  documentation is
>> >> very
>> >> sparse and most of the posts in the user forum isn't encouraging
>> either.
>> >
>> > Fancy helping to fix up the documentation? :)
>> >
>> > Have you tried this page
>> > http://activemq.apache.org/rest.html
>> >
>> > and tried working with the web demos?
>> >
>> > (They come included in the 5.x build btw, just boot up the broker and
>> > look at http://localhost/demos/)
>> >
>> >
>> >
>> >>  Using the script given below, all I get is the following xml
>> response:
>> >>
>> >> ------
>> >> <org.apache.activemq.command.BrokerInfo>
>> >
>> > [snip]
>> >
>> > That looks like you are accessing the http-transport (used to tunnel
>> > an ActiveMQ JMS client over HTTP) rather than the REST API
>> >
>> >> 1. has anyone successfully used the REST api, if so how ?
>> >> 2. any links to a working code (other than using the AjaxServlet) ?
>> >
>> > try the samples.
>> >
>> > http://activemq.apache.org/web-samples.html
>> >
>> > Note I'm sure we could improve the REST API somewhat to make it easier
>> > for folks to use - plus we could use some better documentation;
>> > contributions always welcome...
>> >
>> > http://activemq.apache.org/contributing.html
>> > http://activemq.apache.org/how-do-i-edit-the-website.html
>> > --
>> > James
>> > -------
>> > http://macstrac.blogspot.com/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ActiveMQ-and-REST-tf3996071s2354.html#a11349159
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/ActiveMQ-and-REST-tf3996071s2354.html#a11350433
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ and REST

Posted by James Strachan <ja...@gmail.com>.
Have you tried using the web samples? Its got some simple HTML links
so your web browser using HTML forms can post a message to a queue and
receive one from a queue etc? Maybe best to start there?

On 6/28/07, Sandeep Chayapathi <sa...@wssource.com> wrote:
>
> sure, I would like to contribute to the community by documenting the REST
> api.
>
> However I don't know where to start on the REST stuff. I have tried to
> follow the code but I can't figure out how to subscribe and get messages via
> REST. I have looked at the  http://activemq.apache.org/rest.html REST
> document, does that mean I have to have a web.xml with the mapping ?
>
> Thanks.
>
>
> James.Strachan wrote:
> >
> >
> >>  However I have hit a roadblock with accessing the messages itself. The
> >> http://activemq.apache.org/rest-protocols.html REST  documentation is
> >> very
> >> sparse and most of the posts in the user forum isn't encouraging either.
> >
> > Fancy helping to fix up the documentation? :)
> >
> > Have you tried this page
> > http://activemq.apache.org/rest.html
> >
> > and tried working with the web demos?
> >
> > (They come included in the 5.x build btw, just boot up the broker and
> > look at http://localhost/demos/)
> >
> >
> >
> >>  Using the script given below, all I get is the following xml response:
> >>
> >> ------
> >> <org.apache.activemq.command.BrokerInfo>
> >
> > [snip]
> >
> > That looks like you are accessing the http-transport (used to tunnel
> > an ActiveMQ JMS client over HTTP) rather than the REST API
> >
> >> 1. has anyone successfully used the REST api, if so how ?
> >> 2. any links to a working code (other than using the AjaxServlet) ?
> >
> > try the samples.
> >
> > http://activemq.apache.org/web-samples.html
> >
> > Note I'm sure we could improve the REST API somewhat to make it easier
> > for folks to use - plus we could use some better documentation;
> > contributions always welcome...
> >
> > http://activemq.apache.org/contributing.html
> > http://activemq.apache.org/how-do-i-edit-the-website.html
> > --
> > James
> > -------
> > http://macstrac.blogspot.com/
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ActiveMQ-and-REST-tf3996071s2354.html#a11349159
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
James
-------
http://macstrac.blogspot.com/

Re: ActiveMQ and REST

Posted by Sandeep Chayapathi <sa...@wssource.com>.
sure, I would like to contribute to the community by documenting the REST
api. 

However I don't know where to start on the REST stuff. I have tried to
follow the code but I can't figure out how to subscribe and get messages via
REST. I have looked at the  http://activemq.apache.org/rest.html REST 
document, does that mean I have to have a web.xml with the mapping ? 

Thanks.


James.Strachan wrote:
> 
> 
>>  However I have hit a roadblock with accessing the messages itself. The
>> http://activemq.apache.org/rest-protocols.html REST  documentation is
>> very
>> sparse and most of the posts in the user forum isn't encouraging either.
> 
> Fancy helping to fix up the documentation? :)
> 
> Have you tried this page
> http://activemq.apache.org/rest.html
> 
> and tried working with the web demos?
> 
> (They come included in the 5.x build btw, just boot up the broker and
> look at http://localhost/demos/)
> 
> 
> 
>>  Using the script given below, all I get is the following xml response:
>>
>> ------
>> <org.apache.activemq.command.BrokerInfo>
> 
> [snip]
> 
> That looks like you are accessing the http-transport (used to tunnel
> an ActiveMQ JMS client over HTTP) rather than the REST API
> 
>> 1. has anyone successfully used the REST api, if so how ?
>> 2. any links to a working code (other than using the AjaxServlet) ?
> 
> try the samples.
> 
> http://activemq.apache.org/web-samples.html
> 
> Note I'm sure we could improve the REST API somewhat to make it easier
> for folks to use - plus we could use some better documentation;
> contributions always welcome...
> 
> http://activemq.apache.org/contributing.html
> http://activemq.apache.org/how-do-i-edit-the-website.html
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/ActiveMQ-and-REST-tf3996071s2354.html#a11349159
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ and REST

Posted by James Strachan <ja...@gmail.com>.
On 6/28/07, Sandeep Chayapathi <sa...@wssource.com> wrote:
>
> Hi all,
>  Recently I started trying out accessing messages via the REST protocol. I
> have successfully setup a network transport for http on port 8080 and I can
> see the jetty webserver responding to queries.
>
>  However I have hit a roadblock with accessing the messages itself. The
> http://activemq.apache.org/rest-protocols.html REST  documentation is very
> sparse and most of the posts in the user forum isn't encouraging either.

Fancy helping to fix up the documentation? :)

Have you tried this page
http://activemq.apache.org/rest.html

and tried working with the web demos?

(They come included in the 5.x build btw, just boot up the broker and
look at http://localhost/demos/)



>  Using the script given below, all I get is the following xml response:
>
> ------
> <org.apache.activemq.command.BrokerInfo>

[snip]

That looks like you are accessing the http-transport (used to tunnel
an ActiveMQ JMS client over HTTP) rather than the REST API

> 1. has anyone successfully used the REST api, if so how ?
> 2. any links to a working code (other than using the AjaxServlet) ?

try the samples.

http://activemq.apache.org/web-samples.html

Note I'm sure we could improve the REST API somewhat to make it easier
for folks to use - plus we could use some better documentation;
contributions always welcome...

http://activemq.apache.org/contributing.html
http://activemq.apache.org/how-do-i-edit-the-website.html
-- 
James
-------
http://macstrac.blogspot.com/