activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geurt Schimmel <GSchim...@schubergphilis.com>
Subject Re: need example for Perl STOMP access to ActiveMQ.Statistics.Broker
Date Fri, 02 Nov 2012 08:15:32 GMT
Looked into AnyEvent::STOMP, but think it's rather obscure. Would recommend JMX instead. Using
just one Jython (no JMX for Perl I'm afraid) script to monitor all objects (broker, queues,
topics). Start with enabling JMX (/etc/default/activemq on Unix) and use (eg) jconsole to
browse through all JMX exposed objects. And more than happy to share my Jython script.

Geurt

Sent from my iPhone

On 1 nov. 2012, at 19:28, "Fulko Hew" <fulko.hew@gmail.com> wrote:

> I'm new to ActiveMQ and STOMP and am trying to get a simple example to
> work in order to retrieve system and queue information from a running
> server.
> 
> I have read the information on: Apache
> ActiveMQ > Connectivity > Protocols > Stomp
> and I have enabled STOMP inside ActiveMQ.  I know this works because I was
> able to use
> the STOMP example provide in ActiveMQ.
> 
> I have also read Apache
> ActiveMQ > Features > Interceptors > StatisticsPlugin and
> tested it using a version of the (non-STOMP) code I found at:
> 
> http://rajdavies.blogspot.ca/2009/10/query-statistics-for-apache-activemq.html
> 
> So I know STOMP works, and I know the stats works,
> but I haven't gotten a Java based STOMP app (retrieving stats) to work yet,
> or (my ultimate goad) a Perl (AnyEvent::Stomp) based app either.
> 
> So far, below is my best attempt at a Perl example
> and below that is my non-working Java attempt.
> 
> Does anyone have a working example of either language that I can start from
> and learn from; or can anyone tell me what I'm missing or doing wrong?
> 
> TIA
> Fulko
> 
> 
>  use AnyEvent;
> use AnyEvent::STOMP;
> 
> my $host        = 'localhost';
> my $port        = undef;
> my $ack         = undef;
> my $destination = '/queue/ActiveMQ.Statistics.Broker';
> my $replyto     = '/queue/statsresults';
> my $once        = 0;
> 
> my $client = AnyEvent::STOMP->connect(
>                $host, $port, $ssl, $replyto, $ack,
>                undef,
>                {
>                    receipt         => '',
>                    transformation  => 'jms-map-json',
>                }
>            );
> 
> $client->reg_cb(MESSAGE => sub {
>    my (undef, $body, $headers) = @_;
>    print "received something, body:\n$body\n";
> });
> 
> $client->reg_cb(frame => sub {
>    my (undef, $type, $body, $headers) = @_;
> 
>    print "received anything, type: $type\nbody:\n";
>    if ($type eq 'RECEIPT') {
>        unless ($once) {
>            $client->send('', $destination, { replyTo => $replyto, receipt
> => ''} );  # trigger an exchange
>            $once = 1;
>        }
>    }
> });
> 
> AnyEvent->condvar->recv;                        # start the event loop
> 
> 
> import org.apache.activemq.transport.stomp.Stomp;
> import org.apache.activemq.transport.stomp.StompConnection;
> import org.apache.activemq.transport.stomp.StompFrame;
> import org.apache.activemq.transport.stomp.Stomp.Headers.Subscribe;
> import java.util.HashMap;
> 
> public class StompStats {
> 
>    public static void main(String args[]) throws Exception {
> 
>        HashMap<String, String> headers = new HashMap<String, String>();
>        headers.put("replyTo", "/queue/statsresults");
> 
>        StompConnection connection = new StompConnection();
>        connection.open("localhost", 61613);
>        connection.connect("system", "manager");
> 
>        connection.subscribe("/queue/statsresults");
> 
>        connection.send("/queue/ActiveMQ.Statistics.Broker", "", "",
> headers);
> 
>        StompFrame message = connection.receive();
>        System.out.println(message.getBody());
> 
>        connection.disconnect();
>    }
> 
> }

Mime
View raw message