Author: mcpierce
Date: Thu Nov 29 21:15:53 2012
New Revision: 1415385

URL: http://svn.apache.org/viewvc?rev=1415385&view=rev
Log:
PROTON-94: Provide Perl language examples for send and recv.

This version of the files uses the qpid::proton::Message and
qpid::proton::Messenger classes.

Added:
    qpid/proton/trunk/examples/
    qpid/proton/trunk/examples/perl/
    qpid/proton/trunk/examples/perl/recv.pl
    qpid/proton/trunk/examples/perl/send.pl   (with props)
Modified:
    qpid/proton/trunk/proton-c/bindings/perl/ChangeLog

Added: qpid/proton/trunk/examples/perl/recv.pl
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/examples/perl/recv.pl?rev=1415385&view=auto
==============================================================================
--- qpid/proton/trunk/examples/perl/recv.pl (added)
+++ qpid/proton/trunk/examples/perl/recv.pl Thu Nov 29 21:15:53 2012
@@ -0,0 +1,57 @@
+#!/usr/bin/env perl
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+use strict;
+use warnings;
+
+use qpid_proton;
+
+sub usage {
+    exit(0);
+}
+
+my @addresses = @ARGV;
+@addresses = ("~0.0.0.0") unless $addresses[0];
+
+my $messenger = new qpid::proton::Messenger();
+my $msg = new qpid::proton::Message();
+
+$messenger->start();
+
+foreach (@addresses)
+{
+    print "Subscribing to $_\n";
+    $messenger->subscribe($_);
+}
+
+for(;;)
+{
+    $messenger->receive(10);
+
+    while ($messenger->incoming() > 0)
+    {
+        $messenger->get($msg);
+        print "Address: " . $msg->get_address() . "\n";
+        print "Subject: " . $msg->get_subject() . "\n";
+        print "Content: " . $msg->get_content() . "\n";
+    }
+}
+
+die $@ if ($@);

Added: qpid/proton/trunk/examples/perl/send.pl
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/examples/perl/send.pl?rev=1415385&view=auto
==============================================================================
--- qpid/proton/trunk/examples/perl/send.pl (added)
+++ qpid/proton/trunk/examples/perl/send.pl Thu Nov 29 21:15:53 2012
@@ -0,0 +1,57 @@
+#!/usr/bin/env perl
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+use strict;
+use warnings;
+use Getopt::Std;
+
+use qpid_proton;
+
+sub usage {
+    exit(0);
+}
+
+my $address = "0.0.0.0";
+
+my %options = ();
+getopts("ha:", \%options) or usage();
+usage if $options{h};
+
+$address = $options{a} if defined $options{a};
+
+my $msg  = new qpid::proton::Message();
+my $messenger = new qpid::proton::Messenger();
+
+$messenger->start();
+
+my @messages = @ARGV;
+@messages = ("This is a test. " . localtime(time)) unless $messages[0];
+
+foreach (@messages)
+{
+    $msg->set_address($address);
+    $msg->set_content($_);
+    $messenger->put($msg);
+}
+
+$messenger->send();
+$messenger->stop();
+
+die $@ if ($@);

Propchange: qpid/proton/trunk/examples/perl/send.pl
------------------------------------------------------------------------------
    svn:executable = *

Modified: qpid/proton/trunk/proton-c/bindings/perl/ChangeLog
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/ChangeLog?rev=1415385&r1=1415384&r2=1415385&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/ChangeLog (original)
+++ qpid/proton/trunk/proton-c/bindings/perl/ChangeLog Thu Nov 29 21:15:53 2012
@@ -2,3 +2,4 @@ version 0.2: (TBA)
        * First implementation of the stable APIs on top of swig.
        * Provides the qpid::proton::Message class.
        * Provides the qpid::proton::Messenger class.
+       * Provides a send and recv example for the Perl bindings.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to