r58444 - in /branches/upstream/libnet-stomp-perl/current: CHANGES MANIFEST MANIFEST.SKIP META.yml Makefile.PL README examples/ examples/send.pl examples/subscribe.pl lib/Net/Stomp.pm lib/Net/Stomp/Frame.pm

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Wed May 26 10:55:29 UTC 2010


Author: ansgar-guest
Date: Wed May 26 10:55:09 2010
New Revision: 58444

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=58444
Log:
[svn-upgrade] Integrating new upstream version, libnet-stomp-perl (0.35)

Added:
    branches/upstream/libnet-stomp-perl/current/MANIFEST.SKIP
    branches/upstream/libnet-stomp-perl/current/examples/
    branches/upstream/libnet-stomp-perl/current/examples/send.pl
    branches/upstream/libnet-stomp-perl/current/examples/subscribe.pl
Modified:
    branches/upstream/libnet-stomp-perl/current/CHANGES
    branches/upstream/libnet-stomp-perl/current/MANIFEST
    branches/upstream/libnet-stomp-perl/current/META.yml
    branches/upstream/libnet-stomp-perl/current/Makefile.PL
    branches/upstream/libnet-stomp-perl/current/README
    branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm
    branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm

Modified: branches/upstream/libnet-stomp-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/CHANGES?rev=58444&op=diff
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/CHANGES (original)
+++ branches/upstream/libnet-stomp-perl/current/CHANGES Wed May 26 10:55:09 2010
@@ -1,4 +1,15 @@
 Revision history for Perl module Net::Stomp:
+
+0.35 Tue May 25 15:55:36 BST 2010
+  - add some examples
+  - add support for SSL (thanks to Aleksandar Ivanisevic)
+  - add send_transactional (based on Net::Stomp::Receipt, thanks
+    to Hugo Salgado)
+  - add some convenience methods for accessing headers in a frame
+    (thanks to Claes Jakobsson)
+  - receive_frame now accepts a {timeout=>1} option
+  - failover support (thanks to Thom May and Ash Berlin)
+  - reconnect and resubscribe when connection failes (Thom May)
 
 0.34 Fri Jun 27 09:29:13 BST 2008
   - revert to 0.32's code, as the last release broke things that
@@ -30,4 +41,4 @@
   - add can_read() method
 
 0.30 Sat Oct  7 09:47:57 BST 2006
-  - initial release
+  - initial release

Modified: branches/upstream/libnet-stomp-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/MANIFEST?rev=58444&op=diff
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/MANIFEST (original)
+++ branches/upstream/libnet-stomp-perl/current/MANIFEST Wed May 26 10:55:09 2010
@@ -1,10 +1,13 @@
 Build.PL
 CHANGES
+examples/send.pl
+examples/subscribe.pl
 lib/Net/Stomp.pm
 lib/Net/Stomp/Frame.pm
-Makefile.PL
 MANIFEST			This list of files
+MANIFEST.SKIP
+META.yml
 README
 t/pod.t
 t/pod_coverage.t
-META.yml
+Makefile.PL

Added: branches/upstream/libnet-stomp-perl/current/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/MANIFEST.SKIP?rev=58444&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/MANIFEST.SKIP (added)
+++ branches/upstream/libnet-stomp-perl/current/MANIFEST.SKIP Wed May 26 10:55:09 2010
@@ -1,0 +1,10 @@
+^MYMETA.yml$
+^MANIFEST.bak$
+^Build$
+^Makefile
+
+\.tar\.gz$
+^\.git
+\.swp$
+^_build/
+^blib/

Modified: branches/upstream/libnet-stomp-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/META.yml?rev=58444&op=diff
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/META.yml (original)
+++ branches/upstream/libnet-stomp-perl/current/META.yml Wed May 26 10:55:09 2010
@@ -1,23 +1,25 @@
 ---
+abstract: 'A Streaming Text Orientated Messaging Protocol Client'
+author:
+  - "Leon Brocard <acme at astray.com>.\nThom May <thom.may at betfair.com>.\nAsh Berlin <ash_github at firemirror.com>."
+configure_requires:
+  Module::Build: 0.36
+generated_by: 'Module::Build version 0.3603'
+license: perl
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
 name: Net-Stomp
-version: 0.34
-author:
-  - Leon Brocard <acme at astray.com>.
-abstract: A Streaming Text Orientated Messaging Protocol Client
-license: perl
-resources:
-  license: http://dev.perl.org/licenses/
+provides:
+  Net::Stomp:
+    file: lib/Net/Stomp.pm
+    version: 0.35
+  Net::Stomp::Frame:
+    file: lib/Net/Stomp/Frame.pm
 requires:
   Class::Accessor::Fast: 0
   IO::Select: 0
   IO::Socket::INET: 0
-provides:
-  Net::Stomp:
-    file: lib/Net/Stomp.pm
-    version: 0.34
-  Net::Stomp::Frame:
-    file: lib/Net/Stomp/Frame.pm
-generated_by: Module::Build version 0.280801
-meta-spec:
-  url: http://module-build.sourceforge.net/META-spec-v1.2.html
-  version: 1.2
+resources:
+  license: http://dev.perl.org/licenses/
+version: 0.35

Modified: branches/upstream/libnet-stomp-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/Makefile.PL?rev=58444&op=diff
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/Makefile.PL (original)
+++ branches/upstream/libnet-stomp-perl/current/Makefile.PL Wed May 26 10:55:09 2010
@@ -1,16 +1,16 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.2808_01
+# Note: this file was auto-generated by Module::Build::Compat version 0.3603
 use ExtUtils::MakeMaker;
 WriteMakefile
 (
-          'PL_FILES' => {},
-          'INSTALLDIRS' => 'site',
           'NAME' => 'Net::Stomp',
-          'EXE_FILES' => [],
           'VERSION_FROM' => 'lib/Net/Stomp.pm',
           'PREREQ_PM' => {
+                           'Class::Accessor::Fast' => '0',
                            'IO::Select' => '0',
-                           'IO::Socket::INET' => '0',
-                           'Class::Accessor::Fast' => '0'
-                         }
+                           'IO::Socket::INET' => '0'
+                         },
+          'INSTALLDIRS' => 'site',
+          'EXE_FILES' => [],
+          'PL_FILES' => {}
         )
 ;

Modified: branches/upstream/libnet-stomp-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/README?rev=58444&op=diff
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/README (original)
+++ branches/upstream/libnet-stomp-perl/current/README Wed May 26 10:55:09 2010
@@ -47,14 +47,17 @@
     For details on the protocol see <http://stomp.codehaus.org/Protocol>.
 
     To enable the ActiveMQ Broker for Stomp add the following to the
-    activemq.xml configuration:
-
-      <connector>
-          <serverTransport uri="stomp://localhost:61613"/>
-      </connector>
+    activemq.xml configuration inside the <transportConnectors> section:
+
+      <transportConnector name="stomp" uri="stomp://localhost:61613"/>
+
+    To enable the ActiveMQ Broker for Stomp and SSL add the following inside
+    the <transportConnectors> section:
+
+      <transportConnector name="stomp+ssl" uri="stomp+ssl://localhost:61612"/>
 
     For details on Stomp in ActiveMQ See
-    <http://www.activemq.org/site/stomp.html>.
+    <http://activemq.apache.org/stomp.html>.
 
 METHODS
   new
@@ -63,6 +66,24 @@
 
       my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
 
+    If you want to use SSL, make sure you have IO::Socket::SSL and pass in
+    the SSL flag:
+
+      my $stomp = Net::Stomp->new( {
+        hostname => 'localhost',
+        port     => '61612',
+        ssl      => 1,
+      } );
+
+    If you want to pass in IO::Socket::SSL options:
+
+      my $stomp = Net::Stomp->new( {
+        hostname    => 'localhost',
+        port        => '61612',
+        ssl         => 1,
+        ssl_options => { SSL_cipher_list => 'ALL:!EXPORT' },
+      } );
+
   connect
     This connects to the Stomp server. You must pass in a login and
     passcode.
@@ -81,6 +102,20 @@
           { destination => '/queue/foo', body => 'test message' } );
 
     To send a BytesMessage, you should set the field 'bytes_message' to 1.
+
+  send_transactional
+    This sends a message in transactional mode and fails if the receipt of
+    the message is not acknowledged by the server:
+
+      $stomp->send_transactional(
+          { destination => '/queue/foo', body => 'test message' }
+      ) or die "Couldn't send the message!";
+
+    If using ActiveMQ, you might also want to make the message persistent:
+
+      $stomp->send_transactional(
+          { destination => '/queue/foo', body => 'test message', persistent => 'true' }
+      ) or die "Couldn't send the message!";
 
   disconnect
     This disconnects from the Stomp server:
@@ -185,7 +220,7 @@
     Leon Brocard <acme at astray.com>.
 
 COPYRIGHT
-    Copyright (C) 2006, Leon Brocard
+    Copyright (C) 2006-9, Leon Brocard
 
     This module is free software; you can redistribute it or modify it under
     the same terms as Perl itself.

Added: branches/upstream/libnet-stomp-perl/current/examples/send.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/examples/send.pl?rev=58444&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/examples/send.pl (added)
+++ branches/upstream/libnet-stomp-perl/current/examples/send.pl Wed May 26 10:55:09 2010
@@ -1,0 +1,23 @@
+#!perl
+use strict;
+use warnings;
+use lib 'lib';
+use DateTime;
+use Net::Stomp;
+
+my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
+$stomp->connect( { login => 'hello', passcode => 'there' } );
+
+my $count = shift || 1;
+
+foreach my $i ( 1 .. $count ) {
+    warn $i;
+    $stomp->send(
+        {   destination   => '/queue/foo',
+            body          => DateTime->now . " $i",
+            bytes_message => 1,
+        }
+    );
+}
+
+$stomp->disconnect;

Added: branches/upstream/libnet-stomp-perl/current/examples/subscribe.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/examples/subscribe.pl?rev=58444&op=file
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/examples/subscribe.pl (added)
+++ branches/upstream/libnet-stomp-perl/current/examples/subscribe.pl Wed May 26 10:55:09 2010
@@ -1,0 +1,23 @@
+#!perl
+use strict;
+use warnings;
+use lib 'lib';
+use Net::Stomp;
+
+my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
+$stomp->connect( { login => 'hello', passcode => 'there' } );
+$stomp->subscribe(
+    {   destination             => '/queue/foo',
+        'ack'                   => 'client',
+        'activemq.prefetchSize' => 1,
+    }
+);
+
+while ( $stomp->can_read( { timeout => 1 } ) ) {
+    my $frame = $stomp->receive_frame;
+    $stomp->ack( { frame => $frame } );
+    warn $frame->command . ': >' . substr( $frame->body, 0, 80 ) . "<\n";
+}
+
+$stomp->disconnect;
+

Modified: branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm?rev=58444&op=diff
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm (original)
+++ branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp.pm Wed May 26 10:55:09 2010
@@ -4,48 +4,132 @@
 use IO::Socket::INET;
 use IO::Select;
 use Net::Stomp::Frame;
+use Carp;
 use base 'Class::Accessor::Fast';
-__PACKAGE__->mk_accessors(qw(hostname port select socket));
-our $VERSION = '0.34';
+our $VERSION = '0.35';
+__PACKAGE__->mk_accessors( qw(
+    _cur_host failover hostname hosts port select serial session_id socket ssl
+    ssl_options subscriptions _connect_headers
+) );
 
 sub new {
-    my $class  = shift;
-    my $self   = $class->SUPER::new(@_);
-    my $socket = IO::Socket::INET->new(
+    my $class = shift;
+    my $self  = $class->SUPER::new(@_);
+
+    # We are not subscribed to anything at the start
+    $self->subscriptions( {} );
+
+    $self->select( IO::Select->new );
+    my @hosts = ();
+
+    # failover://tcp://primary:61616
+    # failover:(tcp://primary:61616,tcp://secondary:61616)?randomize=false
+
+    if ($self->failover) {
+        my ($uris, $opts) = $self->failover =~ m{^failover:(?://)? \(? (.*?) \)? (?: \? (.*?) ) ?$}ix;
+
+        confess "Unable to parse failover uri: " . $self->failover
+                unless $uris;
+
+        foreach my $host (split(/,/,$uris)) {
+            my ($hostname, $port) = ($host =~ m{^\w+://([a-zA-Z0-9\-./]+):([0-9]+)$})
+              || confess "Unable to parse failover component: '$host'";
+            push(@hosts, {hostname => $hostname, port => $port});
+        }
+    }
+    $self->hosts(@hosts);
+
+    eval { $self->_get_connection};
+    while($@) {
+        sleep(5);
+        eval { $self->_get_connection};
+    }
+    return $self;
+}
+
+sub _get_connection {
+    my $self = shift;
+    if (my $hosts = $self->hosts) {
+        if (defined $self->_cur_host && ($self->_cur_host < $#{$hosts} ) ) {
+            $self->_cur_host($self->_cur_host+1);
+        } else {
+            $self->_cur_host(0);
+        }
+        $self->hostname($hosts->[$self->_cur_host]->{hostname});
+        $self->port($hosts->[$self->_cur_host]->{port});
+    }
+    my ($socket);
+    my %sockopts = (
         PeerAddr => $self->hostname,
         PeerPort => $self->port,
-        Proto    => 'tcp'
+        Proto    => 'tcp',
+        Timeout  => 5
     );
+    if ( $self->ssl ) {
+        eval { require IO::Socket::SSL };
+        die
+            "You should install the IO::Socket::SSL module for SSL support in Net::Stomp"
+            if $@;
+        %sockopts = ( %sockopts, %{ $self->ssl_options || {} } );
+        $socket = IO::Socket::SSL->new(%sockopts);
+    } else {
+        $socket = IO::Socket::INET->new(%sockopts);
+        binmode($socket);
+    }
     die "Error connecting to " . $self->hostname . ':' . $self->port . ": $!"
         unless $socket;
-    binmode($socket);
+
+    $self->select->remove($self->socket) if $self->socket;
+
+    $self->select->add($socket);
     $self->socket($socket);
-    my $select = IO::Select->new();
-    $select->add($socket);
-    $self->select($select);
-
-    return $self;
+
 }
 
 sub connect {
     my ( $self, $conf ) = @_;
+
     my $frame = Net::Stomp::Frame->new(
         { command => 'CONNECT', headers => $conf } );
     $self->send_frame($frame);
     $frame = $self->receive_frame;
+
+    # Setting initial values for session id, as given from
+    # the stomp server
+    $self->session_id( $frame->headers->{session} );
+    $self->_connect_headers( $conf );
+
     return $frame;
 }
 
 sub disconnect {
     my $self = shift;
-    my $frame = Net::Stomp::Frame->new( { command => 'DISCONNECT', } );
+    my $frame = Net::Stomp::Frame->new( { command => 'DISCONNECT' } );
     $self->send_frame($frame);
     $self->socket->close;
+    $self->select->remove($self->socket);
+}
+
+sub _reconnect {
+    my $self = shift;
+    if ($self->socket) {
+        $self->socket->close;
+    }
+    eval { $self->_get_connection };
+    while ($@) { 
+        sleep(5);
+        eval { $self->_get_connection };
+    }
+    $self->connect( $self->_connect_headers );
+    for my $sub(keys %{$self->subscriptions}) {
+        $self->subscribe($self->subscriptions->{$sub});
+    }
 }
 
 sub can_read {
     my ( $self, $conf ) = @_;
-    my $timeout = $conf->{timeout} || 0;
+    $conf ||= {};
+    my $timeout = exists $conf->{timeout} ? $conf->{timeout} : 0;
     return $self->select->can_read($timeout) || 0;
 }
 
@@ -58,11 +142,59 @@
     $self->send_frame($frame);
 }
 
+sub send_transactional {
+    my ( $self, $conf ) = @_;
+    my $body = $conf->{body};
+    delete $conf->{body};
+
+    # begin the transaction
+    my $transaction_id = $self->_get_next_transaction;
+    my $begin_frame
+        = Net::Stomp::Frame->new(
+        { command => 'BEGIN', headers => { transaction => $transaction_id } }
+        );
+    $self->send_frame($begin_frame);
+
+    # send the message
+    my $receipt_id = $self->_get_next_transaction;
+    $conf->{receipt} = $receipt_id;
+    my $message_frame = Net::Stomp::Frame->new(
+        { command => 'SEND', headers => $conf, body => $body } );
+    $self->send_frame($message_frame);
+
+    # check the receipt
+    my $receipt_frame = $self->receive_frame;
+    if (   $receipt_frame->command eq 'RECEIPT'
+        && $receipt_frame->headers->{'receipt-id'} eq $receipt_id )
+    {
+
+        # success, commit the transaction
+        my $frame_commit = Net::Stomp::Frame->new(
+            {   command => 'COMMIT',
+                headers => { transaction => $transaction_id }
+            }
+        );
+        return $self->send_frame($frame_commit);
+    } else {
+
+        # some failure, abort transaction
+        my $frame_abort = Net::Stomp::Frame->new(
+            {   command => 'ABORT',
+                headers => { transaction => $transaction_id }
+            }
+        );
+        $self->send_frame($frame_abort);
+        return 0;
+    }
+}
+
 sub subscribe {
     my ( $self, $conf ) = @_;
     my $frame = Net::Stomp::Frame->new(
         { command => 'SUBSCRIBE', headers => $conf } );
     $self->send_frame($frame);
+    my $subs = $self->subscriptions;
+    $subs->{$conf->{'destination'}} = $conf;
 }
 
 sub unsubscribe {
@@ -70,6 +202,8 @@
     my $frame = Net::Stomp::Frame->new(
         { command => 'UNSUBSCRIBE', headers => $conf } );
     $self->send_frame($frame);
+    my $subs = $self->subscriptions;
+    delete $subs->{$conf->{'destination'}};
 }
 
 sub ack {
@@ -85,15 +219,49 @@
 
     #     warn "send [" . $frame->as_string . "]\n";
     $self->socket->print( $frame->as_string );
+    my $connected = $self->socket->connected;
+    unless (defined $connected) {
+        $self->_reconnect;
+        $self->send_frame($frame);
+    }
 }
 
 sub receive_frame {
-    my $self = shift;
-
-    my $frame = Net::Stomp::Frame->parse( $self->socket );
-
+    my ($self, $conf) = @_;
+
+    # default is to block until we can read something.
+    $conf ||= { timeout => undef };
+
+    my $frame;
+    while (!$frame) {
+
+        # If the user passed in { timeout => 1 } then we wait for up to a
+        # second to read something. If we get no data in that time, then return
+        # undef.
+
+        # But if we get an error (cos we aren't connected) then we should
+        # reconnect and try again.
+        if ( $self->can_read($conf) ) {
+            eval {
+                $frame = Net::Stomp::Frame->parse( $self->socket );
+                1;
+            } or $self->_reconnect;
+        }
+        else {
+            return;
+        }
+    }
     #     warn "receive [" . $frame->as_string . "]\n";
     return $frame;
+}
+
+sub _get_next_transaction {
+    my $self = shift;
+    my $serial = $self->serial || 0;
+    $serial++;
+    $self->serial($serial);
+
+    return $self->session_id . '-' . $serial;
 }
 
 1;
@@ -132,9 +300,20 @@
   $stomp->disconnect;
 
   # write your own frame
-   my $frame = Net::Stomp::Frame->new(
+  my $frame = Net::Stomp::Frame->new(
        { command => $command, headers => $conf, body => $body } );
   $self->send_frame($frame);
+
+  # connect with failover supporting similar URI to ActiveMQ
+  $stomp = Net::Stomp->new({ failover => "failover://tcp://primary:61616" })
+  # "?randomize=..." and other parameters are ignored currently
+  $stomp = Net::Stomp->new({ failover => "failover:(tcp://primary:61616,tcp://secondary:61616)?randomize=false" })
+
+  # Or in a more natural perl way
+  $stomp = Net::Stomp->new({ hosts => [
+    { hostname => 'primary', port => 61616 },
+    { hostname => 'secondary', port => 61616 },
+  ] });
 
 =head1 DESCRIPTION
 
@@ -152,42 +331,90 @@
 For details on the protocol see L<http://stomp.codehaus.org/Protocol>.
 
 To enable the ActiveMQ Broker for Stomp add the following to the
-activemq.xml configuration:
-
-  <connector>
-      <serverTransport uri="stomp://localhost:61613"/>
-  </connector>
-
-For details on Stomp in ActiveMQ See L<http://www.activemq.org/site/stomp.html>.
+activemq.xml configuration inside the <transportConnectors> section:
+
+  <transportConnector name="stomp" uri="stomp://localhost:61613"/>
+
+To enable the ActiveMQ Broker for Stomp and SSL add the following
+inside the <transportConnectors> section:
+
+  <transportConnector name="stomp+ssl" uri="stomp+ssl://localhost:61612"/>
+
+For details on Stomp in ActiveMQ See L<http://activemq.apache.org/stomp.html>.
 
 =head1 METHODS
 
 =head2 new
 
 The constructor creates a new object. You must pass in a hostname and
-a port:
+a port or set a failover configuration:
 
   my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '61613' } );
 
+If you want to use SSL, make sure you have L<IO::Socket::SSL> and
+pass in the SSL flag:
+
+  my $stomp = Net::Stomp->new( {
+    hostname => 'localhost',
+    port     => '61612',
+    ssl      => 1,
+  } );
+
+If you want to pass in L<IO::Socket::SSL> options:
+
+  my $stomp = Net::Stomp->new( {
+    hostname    => 'localhost',
+    port        => '61612',
+    ssl         => 1,
+    ssl_options => { SSL_cipher_list => 'ALL:!EXPORT' },
+  } );
+
+=head3 Failover
+
+There is experiemental failover support in Net::Stomp. You can specify failover
+in a similar maner to ActiveMQ
+(L<http://activemq.apache.org/failover-transport-reference.html>) for
+similarity with Java configs or using a more natural method to perl of passing
+in an array-of-hashrefs in the C<hosts> parameter.
+
+Currently when ever Net::Stomp connects or reconnects it will simply try the
+next host in the list.
+
 =head2 connect
 
-This connects to the Stomp server. You must pass in a login and
-passcode.
-
-You may pass in 'client-id', which specifies the JMS Client ID which
-is used in combination to the activemqq.subscriptionName to denote a
-durable subscriber.
+This connects to the Stomp server. You may pass in a C<login> and
+C<passcode> options.
+
+You may also pass in 'client-id', which specifies the JMS Client ID which is
+used in combination to the activemqq.subscriptionName to denote a durable
+subscriber.
   
   $stomp->connect( { login => 'hello', passcode => 'there' } );
 
 =head2 send
 
-This sends a message to a queue or topic. You must pass in a destination and a body.
+This sends a message to a queue or topic. You must pass in a destination and a
+body.
 
   $stomp->send(
       { destination => '/queue/foo', body => 'test message' } );
 
 To send a BytesMessage, you should set the field 'bytes_message' to 1.
+
+=head2 send_transactional
+
+This sends a message in transactional mode and fails if the receipt of the
+message is not acknowledged by the server:
+
+  $stomp->send_transactional(
+      { destination => '/queue/foo', body => 'test message' }
+  ) or die "Couldn't send the message!";
+
+If using ActiveMQ, you might also want to make the message persistent:
+
+  $stomp->send_transactional(
+      { destination => '/queue/foo', body => 'test message', persistent => 'true' }
+  ) or die "Couldn't send the message!";
 
 =head2 disconnect
 
@@ -265,6 +492,12 @@
 
 The header bytes_message is 1 if the message was a BytesMessage.
 
+By default this method will block until a frame can be returned. If you wish to
+wait for a specified time pass a C<timeout> argument:
+
+  # Wait half a second for a frame, else return undef
+  $stomp->receive_frame({ timeout => 0.5 })
+
 =head2 can_read
 
 This returns whether a frame is waiting to be read. Optionally takes a
@@ -298,10 +531,14 @@
 =head1 AUTHOR
 
 Leon Brocard <acme at astray.com>.
+Thom May <thom.may at betfair.com>.
+Ash Berlin <ash_github at firemirror.com>.
 
 =head1 COPYRIGHT
 
-Copyright (C) 2006, Leon Brocard
+Copyright (C) 2006-9, Leon Brocard
+Copyright (C) 2009, Thom May, Betfair.com
+Copyright (C) 2010, Ash Berlin, Net-a-Porter.com
 
 This module is free software; you can redistribute it or modify it
 under the same terms as Perl itself.

Modified: branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm?rev=58444&op=diff
==============================================================================
--- branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm (original)
+++ branches/upstream/libnet-stomp-perl/current/lib/Net/Stomp/Frame.pm Wed May 26 10:55:09 2010
@@ -3,6 +3,21 @@
 use warnings;
 use base 'Class::Accessor::Fast';
 __PACKAGE__->mk_accessors(qw(command headers body));
+
+BEGIN {
+    for my $header (
+        qw(destination exchange content-type content-length message-id))
+    {
+        my $method = $header;
+        $method =~ s/-/_/g;
+        no strict 'refs';
+        *$method = sub {
+            my $self = shift;
+            $self->headers->{$header} = shift if @_;
+            $self->headers->{$header};
+            }
+    }
+}
 
 sub as_string {
     my $self    = shift;
@@ -127,6 +142,26 @@
 
   my $string = $frame->as_string;
 
+=head2 destination
+
+Get or set the C<destination> header.
+
+=head2 content_type
+
+Get or set the C<content-type> header.
+
+=head2 content_length
+
+Get or set the C<content-length> header.
+
+=head2 exchange
+
+Get or set the C<exchange> header.
+
+=head2 message_id
+
+Get or set the C<message-id> header.
+
 =head1 SEE ALSO
 
 L<Net::Stomp>.




More information about the Pkg-perl-cvs-commits mailing list