activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sandeep Chayapathi <sand...@wssource.com>
Subject ActiveMQ and REST
Date Thu, 28 Jun 2007 18:47:47 GMT

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.


Mime
View raw message