http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/perl/examples/server.pl.html ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/perl/examples/server.pl.html b/content/releases/qpid-proton-0.17.0/messenger/perl/examples/server.pl.html new file mode 100644 index 0000000..973f947 --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/perl/examples/server.pl.html @@ -0,0 +1,252 @@ +<!DOCTYPE html> +<!-- + - + - 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. + - +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>server.pl - Apache Qpid™</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <link rel="stylesheet" href="/site.css" type="text/css" async="async"/> + <link rel="stylesheet" href="/deferred.css" type="text/css" defer="defer"/> + <script type="text/javascript">var _deferredFunctions = [];</script> + <script type="text/javascript" src="/deferred.js" defer="defer"></script> + <!--[if lte IE 8]> + <link rel="stylesheet" href="/ie.css" type="text/css"/> + <script type="text/javascript" src="/html5shiv.js"></script> + <![endif]--> + + <!-- Redirects for `go get` and godoc.org --> + <meta name="go-import" + content="qpid.apache.org git https://git-wip-us.apache.org/repos/asf/qpid-proton.git"/> + <meta name="go-source" + content="qpid.apache.org +https://github.com/apache/qpid-proton/blob/go1/README.md +https://github.com/apache/qpid-proton/tree/go1{/dir} +https://github.com/apache/qpid-proton/blob/go1{/dir}/{file}#L{line}"/> + </head> + <body> + <div id="-content"> + <div id="-top" class="panel"> + <a id="-menu-link"><img width="16" height="16" src="" alt="Menu"/></a> + + <a id="-search-link"><img width="22" height="16" src="" alt="Search"/></a> + + <ul id="-global-navigation"> + <li><a id="-logotype" href="/index.html">Apache Qpid<sup>™</sup></a></li> + <li><a href="/documentation.html">Documentation</a></li> + <li><a href="/download.html">Download</a></li> + <li><a href="/discussion.html">Discussion</a></li> + </ul> + </div> + + <div id="-menu" class="panel" style="display: none;"> + <div class="flex"> + <section> + <h3>Project</h3> + + <ul> + <li><a href="/overview.html">Overview</a></li> + <li><a href="/components/index.html">Components</a></li> + <li><a href="/releases/index.html">Releases</a></li> + </ul> + </section> + + <section> + <h3>Messaging APIs</h3> + + <ul> + <li><a href="/proton/index.html">Qpid Proton</a></li> + <li><a href="/components/jms/index.html">Qpid JMS</a></li> + <li><a href="/components/messaging-api/index.html">Qpid Messaging API</a></li> + </ul> + </section> + + <section> + <h3>Servers and tools</h3> + + <ul> + <li><a href="/components/java-broker/index.html">Broker for Java</a></li> + <li><a href="/components/cpp-broker/index.html">C++ broker</a></li> + <li><a href="/components/dispatch-router/index.html">Dispatch router</a></li> + </ul> + </section> + + <section> + <h3>Resources</h3> + + <ul> + <li><a href="/dashboard.html">Dashboard</a></li> + <li><a href="https://cwiki.apache.org/confluence/display/qpid/Index">Wiki</a></li> + <li><a href="/resources.html">More resources</a></li> + </ul> + </section> + </div> + </div> + + <div id="-search" class="panel" style="display: none;"> + <form action="http://www.google.com/search" method="get"> + <input type="hidden" name="sitesearch" value="qpid.apache.org"/> + <input type="text" name="q" maxlength="255" autofocus="autofocus" tabindex="1"/> + <button type="submit">Search</button> + <a href="/search.html">More ways to search</a> + </form> + </div> + + <div id="-middle" class="panel"> + <ul id="-path-navigation"><li><a href="/index.html">Home</a></li><li><a href="/releases/index.html">Releases</a></li><li><a href="/releases/qpid-proton-0.17.0/index.html">Qpid Proton 0.17.0</a></li><li><a href="/releases/qpid-proton-0.17.0/messenger/perl/examples/index.html">Perl AMQP Messenger Examples</a></li><li>server.pl</li></ul> + + <div id="-middle-content"> + +<h1>server.pl</h1> +<div class="highlight"><pre><span class="k">use</span> <span class="n">strict</span><span class="p">;</span> +<span class="k">use</span> <span class="n">warnings</span><span class="p">;</span> +<span class="k">use</span> <span class="nn">Getopt::</span><span class="n">Long</span><span class="p">;</span> +<span class="k">use</span> <span class="nn">Pod::</span><span class="n">Usage</span><span class="p">;</span> + +<span class="k">use</span> <span class="n">qpid_proton</span><span class="p">;</span> + +<span class="k">my</span> <span class="nv">$help</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> +<span class="k">my</span> <span class="nv">$man</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> + +<span class="n">GetOptions</span><span class="p">(</span> + <span class="n">man</span> <span class="o">=></span> <span class="o">\</span><span class="nv">$man</span><span class="p">,</span> + <span class="s">"help|?"</span> <span class="o">=></span> <span class="o">\</span><span class="nv">$help</span> + <span class="p">)</span> <span class="ow">or</span> <span class="n">pod2usage</span><span class="p">(</span><span class="mi">2</span><span class="p">);</span> + +<span class="n">pod2usage</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="k">if</span> <span class="nv">$help</span><span class="p">;</span> +<span class="n">pod2usage</span><span class="p">(</span><span class="o">-</span><span class="n">exitval</span> <span class="o">=></span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="n">verbose</span> <span class="o">=></span> <span class="mi">2</span><span class="p">)</span> <span class="k">if</span> <span class="nv">$man</span><span class="p">;</span> + +<span class="n">pod2usage</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="k">unless</span> <span class="nb">scalar</span><span class="p">(</span><span class="nv">@ARGV</span><span class="p">);</span> + +<span class="c1"># create a messenger for receiving and holding</span> +<span class="c1"># incoming messages</span> +<span class="k">our</span> <span class="nv">$messenger</span> <span class="o">=</span> <span class="k">new</span> <span class="nn">qpid::proton::</span><span class="n">Messenger</span><span class="p">;</span> +<span class="nv">$messenger</span><span class="o">-></span><span class="n">start</span><span class="p">;</span> + +<span class="c1"># subscribe the messenger to all addresses specified sources</span> +<span class="k">foreach</span> <span class="p">(</span><span class="nv">@ARGV</span><span class="p">)</span> <span class="p">{</span> + <span class="nv">$messenger</span><span class="o">-></span><span class="n">subscribe</span><span class="p">(</span><span class="nv">$_</span><span class="p">);</span> +<span class="p">}</span> + +<span class="k">sub </span><span class="nf">dispatch</span> <span class="p">{</span> + <span class="k">my</span> <span class="nv">$request</span> <span class="o">=</span> <span class="nv">$_</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span> + <span class="k">my</span> <span class="nv">$reply</span> <span class="o">=</span> <span class="nv">$_</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span> + + <span class="k">if</span> <span class="p">(</span><span class="nv">$request</span><span class="o">-></span><span class="n">get_subject</span><span class="p">)</span> <span class="p">{</span> + <span class="nv">$reply</span><span class="o">-></span><span class="n">set_subject</span><span class="p">(</span><span class="s">"Re: "</span> <span class="o">.</span> <span class="nv">$request</span><span class="o">-></span><span class="n">get_subject</span><span class="p">);</span> + <span class="p">}</span> + + <span class="nv">$reply</span><span class="o">-></span><span class="n">set_properties</span><span class="p">(</span><span class="nv">$request</span><span class="o">-></span><span class="n">get_properties</span><span class="p">);</span> + <span class="k">print</span> <span class="s">"Dispatched "</span> <span class="o">.</span> <span class="nv">$request</span><span class="o">-></span><span class="n">get_subject</span> <span class="o">.</span> <span class="s">"\n"</span><span class="p">;</span> + <span class="k">my</span> <span class="nv">$properties</span> <span class="o">=</span> <span class="nv">$request</span><span class="o">-></span><span class="n">get_properties</span><span class="p">;</span> + <span class="k">foreach</span> <span class="p">(</span><span class="nb">keys</span> <span class="nv">%</span><span class="p">{</span><span class="nv">$properties</span><span class="p">})</span> <span class="p">{</span> + <span class="k">my</span> <span class="nv">$value</span> <span class="o">=</span> <span class="nv">$properties</span><span class="o">-></span><span class="p">{</span><span class="nv">%_</span><span class="p">};</span> + <span class="k">print</span> <span class="s">"\t$_: $value\n"</span><span class="p">;</span> + <span class="p">}</span> +<span class="p">}</span> + +<span class="k">our</span> <span class="nv">$message</span> <span class="o">=</span> <span class="k">new</span> <span class="nn">qpid::proton::</span><span class="n">Message</span><span class="p">;</span> +<span class="k">our</span> <span class="nv">$reply</span> <span class="o">=</span> <span class="k">new</span> <span class="nn">qpid::proton::</span><span class="n">Message</span><span class="p">;</span> + +<span class="k">while</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span> + <span class="nv">$messenger</span><span class="o">-></span><span class="n">receive</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="k">if</span> <span class="nv">$messenger</span><span class="o">-></span><span class="n">incoming</span> <span class="o"><</span> <span class="mi">10</span><span class="p">;</span> + + <span class="k">if</span> <span class="p">(</span><span class="nv">$messenger</span><span class="o">-></span><span class="n">incoming</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> + <span class="nv">$messenger</span><span class="o">-></span><span class="n">get</span><span class="p">(</span><span class="nv">$message</span><span class="p">);</span> + + <span class="k">if</span> <span class="p">(</span><span class="nv">$message</span><span class="o">-></span><span class="n">get_reply_to</span><span class="p">)</span> <span class="p">{</span> + <span class="k">print</span> <span class="nv">$message</span><span class="o">-></span><span class="n">get_reply_to</span> <span class="o">.</span> <span class="s">"\n"</span><span class="p">;</span> + <span class="nv">$reply</span><span class="o">-></span><span class="n">set_address</span><span class="p">(</span><span class="nv">$message</span><span class="o">-></span><span class="n">get_reply_to</span><span class="p">);</span> + <span class="nv">$reply</span><span class="o">-></span><span class="n">set_correlation_id</span><span class="p">(</span><span class="nv">$message</span><span class="o">-></span><span class="n">get_correlation_id</span><span class="p">);</span> + <span class="nv">$reply</span><span class="o">-></span><span class="n">set_body</span><span class="p">(</span><span class="nv">$message</span><span class="o">-></span><span class="n">get_body</span><span class="p">);</span> + <span class="p">}</span> + <span class="n">dispatch</span><span class="p">(</span><span class="nv">$message</span><span class="p">,</span> <span class="nv">$reply</span><span class="p">);</span> + <span class="nv">$messenger</span><span class="o">-></span><span class="n">put</span><span class="p">(</span><span class="nv">$reply</span><span class="p">);</span> + <span class="nv">$messenger</span><span class="o">-></span><span class="nb">send</span><span class="p">;</span> + <span class="p">}</span> +<span class="p">}</span> + +<span class="nv">$message</span><span class="o">-></span><span class="n">stop</span><span class="p">;</span> + +<span class="cp">__END__</span> + +<span class="cp">=head1 NAME</span> + +<span class="cp">server - Proton example server application for Perl.</span> + +<span class="cp">=head1 SYNOPSIS</span> + +<span class="cp">server.pl [OPTIONS] <addr1> ... <addrn></span> + +<span class="cp"> Options:</span> +<span class="cp"> --help - This help message.</span> +<span class="cp"> --man - Show the full documentation.</span> + +<span class="cp">=over 8</span> + +<span class="cp">=item B<--help></span> + +<span class="cp">Prints a brief help message and exits.</span> + +<span class="cp">=item B<--man></span> + +<span class="cp">Prints the man page and exits.</span> + +<span class="cp">=back</span> + +<span class="cp">=head2 ADDRESS</span> + +<span class="cp">The form an address takes is:</span> + +<span class="cp">[amqp://]<domain>[/name]</span> + +<span class="cp">=cut</span> +</pre></div> + +<p><a href="server.pl">Download this file</a></p> + + + <hr/> + + <ul id="-apache-navigation"> + <li><a href="http://www.apache.org/">Apache</a></li> + <li><a href="http://www.apache.org/licenses/">License</a></li> + <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> + <li><a href="http://www.apache.org/foundation/thanks.html">Thanks!</a></li> + <li><a href="/security.html">Security</a></li> + <li><a href="http://www.apache.org/"><img id="-apache-feather" width="48" height="14" src="" alt="Apache"/></a></li> + </ul> + + <p id="-legal"> + Apache Qpid, Messaging built on AMQP; Copyright © 2015 + The Apache Software Foundation; Licensed under + the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache + License, Version 2.0</a>; Apache Qpid, Qpid, Qpid Proton, + Proton, Apache, the Apache feather logo, and the Apache Qpid + project logo are trademarks of The Apache Software + Foundation; All other marks mentioned may be trademarks or + registered trademarks of their respective owners + </p> + </div> + </div> + </div> + </body> +</html>
http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/php/examples/index.html ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/php/examples/index.html b/content/releases/qpid-proton-0.17.0/messenger/php/examples/index.html new file mode 100644 index 0000000..2242734 --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/php/examples/index.html @@ -0,0 +1,158 @@ +<!DOCTYPE html> +<!-- + - + - 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. + - +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>PHP AMQP Messenger Examples - Apache Qpid™</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <link rel="stylesheet" href="/site.css" type="text/css" async="async"/> + <link rel="stylesheet" href="/deferred.css" type="text/css" defer="defer"/> + <script type="text/javascript">var _deferredFunctions = [];</script> + <script type="text/javascript" src="/deferred.js" defer="defer"></script> + <!--[if lte IE 8]> + <link rel="stylesheet" href="/ie.css" type="text/css"/> + <script type="text/javascript" src="/html5shiv.js"></script> + <![endif]--> + + <!-- Redirects for `go get` and godoc.org --> + <meta name="go-import" + content="qpid.apache.org git https://git-wip-us.apache.org/repos/asf/qpid-proton.git"/> + <meta name="go-source" + content="qpid.apache.org +https://github.com/apache/qpid-proton/blob/go1/README.md +https://github.com/apache/qpid-proton/tree/go1{/dir} +https://github.com/apache/qpid-proton/blob/go1{/dir}/{file}#L{line}"/> + </head> + <body> + <div id="-content"> + <div id="-top" class="panel"> + <a id="-menu-link"><img width="16" height="16" src="" alt="Menu"/></a> + + <a id="-search-link"><img width="22" height="16" src="" alt="Search"/></a> + + <ul id="-global-navigation"> + <li><a id="-logotype" href="/index.html">Apache Qpid<sup>™</sup></a></li> + <li><a href="/documentation.html">Documentation</a></li> + <li><a href="/download.html">Download</a></li> + <li><a href="/discussion.html">Discussion</a></li> + </ul> + </div> + + <div id="-menu" class="panel" style="display: none;"> + <div class="flex"> + <section> + <h3>Project</h3> + + <ul> + <li><a href="/overview.html">Overview</a></li> + <li><a href="/components/index.html">Components</a></li> + <li><a href="/releases/index.html">Releases</a></li> + </ul> + </section> + + <section> + <h3>Messaging APIs</h3> + + <ul> + <li><a href="/proton/index.html">Qpid Proton</a></li> + <li><a href="/components/jms/index.html">Qpid JMS</a></li> + <li><a href="/components/messaging-api/index.html">Qpid Messaging API</a></li> + </ul> + </section> + + <section> + <h3>Servers and tools</h3> + + <ul> + <li><a href="/components/java-broker/index.html">Broker for Java</a></li> + <li><a href="/components/cpp-broker/index.html">C++ broker</a></li> + <li><a href="/components/dispatch-router/index.html">Dispatch router</a></li> + </ul> + </section> + + <section> + <h3>Resources</h3> + + <ul> + <li><a href="/dashboard.html">Dashboard</a></li> + <li><a href="https://cwiki.apache.org/confluence/display/qpid/Index">Wiki</a></li> + <li><a href="/resources.html">More resources</a></li> + </ul> + </section> + </div> + </div> + + <div id="-search" class="panel" style="display: none;"> + <form action="http://www.google.com/search" method="get"> + <input type="hidden" name="sitesearch" value="qpid.apache.org"/> + <input type="text" name="q" maxlength="255" autofocus="autofocus" tabindex="1"/> + <button type="submit">Search</button> + <a href="/search.html">More ways to search</a> + </form> + </div> + + <div id="-middle" class="panel"> + <ul id="-path-navigation"><li><a href="/index.html">Home</a></li><li><a href="/releases/index.html">Releases</a></li><li><a href="/releases/qpid-proton-0.17.0/index.html">Qpid Proton 0.17.0</a></li><li>PHP AMQP Messenger Examples</li></ul> + + <div id="-middle-content"> + <h1 id="php-amqp-messenger-examples">PHP AMQP Messenger Examples</h1> + +<h2 id="example-files">Example files</h2> + +<ul> +<li><a href="recv.php.html">recv.php</a></li> +<li><a href="send.php.html">send.php</a></li> +</ul> + +<h2 id="more-information">More information</h2> + +<ul> +<li><a href="https://github.com/apache/qpid-proton/tree/0.17.0/examples/php/messenger">Source location</a></li> +</ul> + + + <hr/> + + <ul id="-apache-navigation"> + <li><a href="http://www.apache.org/">Apache</a></li> + <li><a href="http://www.apache.org/licenses/">License</a></li> + <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> + <li><a href="http://www.apache.org/foundation/thanks.html">Thanks!</a></li> + <li><a href="/security.html">Security</a></li> + <li><a href="http://www.apache.org/"><img id="-apache-feather" width="48" height="14" src="" alt="Apache"/></a></li> + </ul> + + <p id="-legal"> + Apache Qpid, Messaging built on AMQP; Copyright © 2015 + The Apache Software Foundation; Licensed under + the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache + License, Version 2.0</a>; Apache Qpid, Qpid, Qpid Proton, + Proton, Apache, the Apache feather logo, and the Apache Qpid + project logo are trademarks of The Apache Software + Foundation; All other marks mentioned may be trademarks or + registered trademarks of their respective owners + </p> + </div> + </div> + </div> + </body> +</html> http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/php/examples/recv.php ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/php/examples/recv.php b/content/releases/qpid-proton-0.17.0/messenger/php/examples/recv.php new file mode 100755 index 0000000..05ece80 --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/php/examples/recv.php @@ -0,0 +1,49 @@ +<?php + +/** + * 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. + **/ + +include("proton.php"); + +$mess = new Messenger(); +$mess->start(); + +if ($argv[1]) { + $mess->subscribe($argv[1]); +} else { + $mess->subscribe("amqp://~0.0.0.0"); +} + +$msg = new Message(); +while (true) { + $mess->recv(10); + while ($mess->incoming) { + try { + $mess->get($msg); + } catch (Exception $e) { + print "$e\n"; + continue; + } + + print "$msg->address, $msg->subject, $msg->body\n"; + } +} + +$mess->stop(); +?> http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/php/examples/recv.php.html ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/php/examples/recv.php.html b/content/releases/qpid-proton-0.17.0/messenger/php/examples/recv.php.html new file mode 100644 index 0000000..5341666 --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/php/examples/recv.php.html @@ -0,0 +1,181 @@ +<!DOCTYPE html> +<!-- + - + - 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. + - +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>recv.php - Apache Qpid™</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <link rel="stylesheet" href="/site.css" type="text/css" async="async"/> + <link rel="stylesheet" href="/deferred.css" type="text/css" defer="defer"/> + <script type="text/javascript">var _deferredFunctions = [];</script> + <script type="text/javascript" src="/deferred.js" defer="defer"></script> + <!--[if lte IE 8]> + <link rel="stylesheet" href="/ie.css" type="text/css"/> + <script type="text/javascript" src="/html5shiv.js"></script> + <![endif]--> + + <!-- Redirects for `go get` and godoc.org --> + <meta name="go-import" + content="qpid.apache.org git https://git-wip-us.apache.org/repos/asf/qpid-proton.git"/> + <meta name="go-source" + content="qpid.apache.org +https://github.com/apache/qpid-proton/blob/go1/README.md +https://github.com/apache/qpid-proton/tree/go1{/dir} +https://github.com/apache/qpid-proton/blob/go1{/dir}/{file}#L{line}"/> + </head> + <body> + <div id="-content"> + <div id="-top" class="panel"> + <a id="-menu-link"><img width="16" height="16" src="" alt="Menu"/></a> + + <a id="-search-link"><img width="22" height="16" src="" alt="Search"/></a> + + <ul id="-global-navigation"> + <li><a id="-logotype" href="/index.html">Apache Qpid<sup>™</sup></a></li> + <li><a href="/documentation.html">Documentation</a></li> + <li><a href="/download.html">Download</a></li> + <li><a href="/discussion.html">Discussion</a></li> + </ul> + </div> + + <div id="-menu" class="panel" style="display: none;"> + <div class="flex"> + <section> + <h3>Project</h3> + + <ul> + <li><a href="/overview.html">Overview</a></li> + <li><a href="/components/index.html">Components</a></li> + <li><a href="/releases/index.html">Releases</a></li> + </ul> + </section> + + <section> + <h3>Messaging APIs</h3> + + <ul> + <li><a href="/proton/index.html">Qpid Proton</a></li> + <li><a href="/components/jms/index.html">Qpid JMS</a></li> + <li><a href="/components/messaging-api/index.html">Qpid Messaging API</a></li> + </ul> + </section> + + <section> + <h3>Servers and tools</h3> + + <ul> + <li><a href="/components/java-broker/index.html">Broker for Java</a></li> + <li><a href="/components/cpp-broker/index.html">C++ broker</a></li> + <li><a href="/components/dispatch-router/index.html">Dispatch router</a></li> + </ul> + </section> + + <section> + <h3>Resources</h3> + + <ul> + <li><a href="/dashboard.html">Dashboard</a></li> + <li><a href="https://cwiki.apache.org/confluence/display/qpid/Index">Wiki</a></li> + <li><a href="/resources.html">More resources</a></li> + </ul> + </section> + </div> + </div> + + <div id="-search" class="panel" style="display: none;"> + <form action="http://www.google.com/search" method="get"> + <input type="hidden" name="sitesearch" value="qpid.apache.org"/> + <input type="text" name="q" maxlength="255" autofocus="autofocus" tabindex="1"/> + <button type="submit">Search</button> + <a href="/search.html">More ways to search</a> + </form> + </div> + + <div id="-middle" class="panel"> + <ul id="-path-navigation"><li><a href="/index.html">Home</a></li><li><a href="/releases/index.html">Releases</a></li><li><a href="/releases/qpid-proton-0.17.0/index.html">Qpid Proton 0.17.0</a></li><li><a href="/releases/qpid-proton-0.17.0/messenger/php/examples/index.html">PHP AMQP Messenger Examples</a></li><li>recv.php</li></ul> + + <div id="-middle-content"> + +<h1>recv.php</h1> +<div class="highlight"><pre><span class="cp"><?php</span> + + + +<span class="k">include</span><span class="p">(</span><span class="s2">"proton.php"</span><span class="p">);</span> + +<span class="nv">$mess</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Messenger</span><span class="p">();</span> +<span class="nv">$mess</span><span class="o">-></span><span class="na">start</span><span class="p">();</span> + +<span class="k">if</span> <span class="p">(</span><span class="nv">$argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="p">{</span> + <span class="nv">$mess</span><span class="o">-></span><span class="na">subscribe</span><span class="p">(</span><span class="nv">$argv</span><span class="p">[</span><span class="mi">1</span><span class="p">]);</span> +<span class="p">}</span> <span class="k">else</span> <span class="p">{</span> + <span class="nv">$mess</span><span class="o">-></span><span class="na">subscribe</span><span class="p">(</span><span class="s2">"amqp://~0.0.0.0"</span><span class="p">);</span> +<span class="p">}</span> + +<span class="nv">$msg</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Message</span><span class="p">();</span> +<span class="k">while</span> <span class="p">(</span><span class="k">true</span><span class="p">)</span> <span class="p">{</span> + <span class="nv">$mess</span><span class="o">-></span><span class="na">recv</span><span class="p">(</span><span class="mi">10</span><span class="p">);</span> + <span class="k">while</span> <span class="p">(</span><span class="nv">$mess</span><span class="o">-></span><span class="na">incoming</span><span class="p">)</span> <span class="p">{</span> + <span class="k">try</span> <span class="p">{</span> + <span class="nv">$mess</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="nv">$msg</span><span class="p">);</span> + <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">Exception</span> <span class="nv">$e</span><span class="p">)</span> <span class="p">{</span> + <span class="k">print</span> <span class="s2">"</span><span class="si">$e</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span> + <span class="k">continue</span><span class="p">;</span> + <span class="p">}</span> + + <span class="k">print</span> <span class="s2">"</span><span class="si">$msg->address</span><span class="s2">, </span><span class="si">$msg->subject</span><span class="s2">, </span><span class="si">$msg->body</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span> + <span class="p">}</span> +<span class="p">}</span> + +<span class="nv">$mess</span><span class="o">-></span><span class="na">stop</span><span class="p">();</span> +<span class="cp">?></span><span class="x"></span> +</pre></div> + +<p><a href="recv.php">Download this file</a></p> + + + <hr/> + + <ul id="-apache-navigation"> + <li><a href="http://www.apache.org/">Apache</a></li> + <li><a href="http://www.apache.org/licenses/">License</a></li> + <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> + <li><a href="http://www.apache.org/foundation/thanks.html">Thanks!</a></li> + <li><a href="/security.html">Security</a></li> + <li><a href="http://www.apache.org/"><img id="-apache-feather" width="48" height="14" src="" alt="Apache"/></a></li> + </ul> + + <p id="-legal"> + Apache Qpid, Messaging built on AMQP; Copyright © 2015 + The Apache Software Foundation; Licensed under + the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache + License, Version 2.0</a>; Apache Qpid, Qpid, Qpid Proton, + Proton, Apache, the Apache feather logo, and the Apache Qpid + project logo are trademarks of The Apache Software + Foundation; All other marks mentioned may be trademarks or + registered trademarks of their respective owners + </p> + </div> + </div> + </div> + </body> +</html> http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/php/examples/send.php ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/php/examples/send.php b/content/releases/qpid-proton-0.17.0/messenger/php/examples/send.php new file mode 100755 index 0000000..599f7eb --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/php/examples/send.php @@ -0,0 +1,41 @@ +<?php + +/** + * 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. + **/ + +include("proton.php"); + +$mess = new Messenger(); +$mess->start(); + +$msg = new Message(); +if ($argv[1]) { + $msg->address = $argv[1]; +} else { + $msg->address = "amqp://0.0.0.0"; +} +$msg->subject = "Hello World!"; +$msg->body = "this is a test"; + +$mess->put($msg); +$mess->send(); +print "sent: $msg->subject\n"; + +$mess->stop(); +?> http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/php/examples/send.php.html ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/php/examples/send.php.html b/content/releases/qpid-proton-0.17.0/messenger/php/examples/send.php.html new file mode 100644 index 0000000..efa0b9a --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/php/examples/send.php.html @@ -0,0 +1,173 @@ +<!DOCTYPE html> +<!-- + - + - 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. + - +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>send.php - Apache Qpid™</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <link rel="stylesheet" href="/site.css" type="text/css" async="async"/> + <link rel="stylesheet" href="/deferred.css" type="text/css" defer="defer"/> + <script type="text/javascript">var _deferredFunctions = [];</script> + <script type="text/javascript" src="/deferred.js" defer="defer"></script> + <!--[if lte IE 8]> + <link rel="stylesheet" href="/ie.css" type="text/css"/> + <script type="text/javascript" src="/html5shiv.js"></script> + <![endif]--> + + <!-- Redirects for `go get` and godoc.org --> + <meta name="go-import" + content="qpid.apache.org git https://git-wip-us.apache.org/repos/asf/qpid-proton.git"/> + <meta name="go-source" + content="qpid.apache.org +https://github.com/apache/qpid-proton/blob/go1/README.md +https://github.com/apache/qpid-proton/tree/go1{/dir} +https://github.com/apache/qpid-proton/blob/go1{/dir}/{file}#L{line}"/> + </head> + <body> + <div id="-content"> + <div id="-top" class="panel"> + <a id="-menu-link"><img width="16" height="16" src="" alt="Menu"/></a> + + <a id="-search-link"><img width="22" height="16" src="" alt="Search"/></a> + + <ul id="-global-navigation"> + <li><a id="-logotype" href="/index.html">Apache Qpid<sup>™</sup></a></li> + <li><a href="/documentation.html">Documentation</a></li> + <li><a href="/download.html">Download</a></li> + <li><a href="/discussion.html">Discussion</a></li> + </ul> + </div> + + <div id="-menu" class="panel" style="display: none;"> + <div class="flex"> + <section> + <h3>Project</h3> + + <ul> + <li><a href="/overview.html">Overview</a></li> + <li><a href="/components/index.html">Components</a></li> + <li><a href="/releases/index.html">Releases</a></li> + </ul> + </section> + + <section> + <h3>Messaging APIs</h3> + + <ul> + <li><a href="/proton/index.html">Qpid Proton</a></li> + <li><a href="/components/jms/index.html">Qpid JMS</a></li> + <li><a href="/components/messaging-api/index.html">Qpid Messaging API</a></li> + </ul> + </section> + + <section> + <h3>Servers and tools</h3> + + <ul> + <li><a href="/components/java-broker/index.html">Broker for Java</a></li> + <li><a href="/components/cpp-broker/index.html">C++ broker</a></li> + <li><a href="/components/dispatch-router/index.html">Dispatch router</a></li> + </ul> + </section> + + <section> + <h3>Resources</h3> + + <ul> + <li><a href="/dashboard.html">Dashboard</a></li> + <li><a href="https://cwiki.apache.org/confluence/display/qpid/Index">Wiki</a></li> + <li><a href="/resources.html">More resources</a></li> + </ul> + </section> + </div> + </div> + + <div id="-search" class="panel" style="display: none;"> + <form action="http://www.google.com/search" method="get"> + <input type="hidden" name="sitesearch" value="qpid.apache.org"/> + <input type="text" name="q" maxlength="255" autofocus="autofocus" tabindex="1"/> + <button type="submit">Search</button> + <a href="/search.html">More ways to search</a> + </form> + </div> + + <div id="-middle" class="panel"> + <ul id="-path-navigation"><li><a href="/index.html">Home</a></li><li><a href="/releases/index.html">Releases</a></li><li><a href="/releases/qpid-proton-0.17.0/index.html">Qpid Proton 0.17.0</a></li><li><a href="/releases/qpid-proton-0.17.0/messenger/php/examples/index.html">PHP AMQP Messenger Examples</a></li><li>send.php</li></ul> + + <div id="-middle-content"> + +<h1>send.php</h1> +<div class="highlight"><pre><span class="cp"><?php</span> + + + +<span class="k">include</span><span class="p">(</span><span class="s2">"proton.php"</span><span class="p">);</span> + +<span class="nv">$mess</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Messenger</span><span class="p">();</span> +<span class="nv">$mess</span><span class="o">-></span><span class="na">start</span><span class="p">();</span> + +<span class="nv">$msg</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Message</span><span class="p">();</span> +<span class="k">if</span> <span class="p">(</span><span class="nv">$argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="p">{</span> + <span class="nv">$msg</span><span class="o">-></span><span class="na">address</span> <span class="o">=</span> <span class="nv">$argv</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span> +<span class="p">}</span> <span class="k">else</span> <span class="p">{</span> + <span class="nv">$msg</span><span class="o">-></span><span class="na">address</span> <span class="o">=</span> <span class="s2">"amqp://0.0.0.0"</span><span class="p">;</span> +<span class="p">}</span> +<span class="nv">$msg</span><span class="o">-></span><span class="na">subject</span> <span class="o">=</span> <span class="s2">"Hello World!"</span><span class="p">;</span> +<span class="nv">$msg</span><span class="o">-></span><span class="na">body</span> <span class="o">=</span> <span class="s2">"this is a test"</span><span class="p">;</span> + +<span class="nv">$mess</span><span class="o">-></span><span class="na">put</span><span class="p">(</span><span class="nv">$msg</span><span class="p">);</span> +<span class="nv">$mess</span><span class="o">-></span><span class="na">send</span><span class="p">();</span> +<span class="k">print</span> <span class="s2">"sent: </span><span class="si">$msg->subject</span><span class="se">\n</span><span class="s2">"</span><span class="p">;</span> + +<span class="nv">$mess</span><span class="o">-></span><span class="na">stop</span><span class="p">();</span> +<span class="cp">?></span><span class="x"></span> +</pre></div> + +<p><a href="send.php">Download this file</a></p> + + + <hr/> + + <ul id="-apache-navigation"> + <li><a href="http://www.apache.org/">Apache</a></li> + <li><a href="http://www.apache.org/licenses/">License</a></li> + <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> + <li><a href="http://www.apache.org/foundation/thanks.html">Thanks!</a></li> + <li><a href="/security.html">Security</a></li> + <li><a href="http://www.apache.org/"><img id="-apache-feather" width="48" height="14" src="" alt="Apache"/></a></li> + </ul> + + <p id="-legal"> + Apache Qpid, Messaging built on AMQP; Copyright © 2015 + The Apache Software Foundation; Licensed under + the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache + License, Version 2.0</a>; Apache Qpid, Qpid, Qpid Proton, + Proton, Apache, the Apache feather logo, and the Apache Qpid + project logo are trademarks of The Apache Software + Foundation; All other marks mentioned may be trademarks or + registered trademarks of their respective owners + </p> + </div> + </div> + </div> + </body> +</html> http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/python/examples/async.py ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/python/examples/async.py b/content/releases/qpid-proton-0.17.0/messenger/python/examples/async.py new file mode 100755 index 0000000..a1b0292 --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/python/examples/async.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# +# 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. +# +from __future__ import print_function +import sys +from proton import * + +class CallbackAdapter: + + def __init__(self, messenger): + self.messenger = messenger + self.messenger.blocking = False + self.messenger.outgoing_window = 1024 + self.messenger.incoming_window = 1024 + # for application use + self.message = Message() + self._incoming_message = Message() + self.tracked = {} + + def run(self): + self.running = True + self.messenger.start() + self.on_start() + + while self.running: + self.messenger.work() + self._process() + + self.messenger.stop() + + while not self.messenger.stopped: + self.messenger.work() + self._process() + + self.on_stop() + + def stop(self): + self.running = False + + def _process(self): + self._process_outgoing() + self._process_incoming() + + def _process_outgoing(self): + for t, on_status in list(self.tracked.items()): + status = self.messenger.status(t) + if status != PENDING: + on_status(status) + self.messenger.settle(t) + del self.tracked[t] + + def _process_incoming(self): + while self.messenger.incoming: + t = self.messenger.get(self._incoming_message) + try: + self.on_recv(self._incoming_message) + self.messenger.accept(t) + except: + ex = sys.exc_info()[1] + print("Exception:", ex) + self.messenger.reject(t) + + def send(self, message, on_status=None): + t = self.messenger.put(message) + if on_status: + self.tracked[t] = on_status http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/python/examples/async.py.html ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/python/examples/async.py.html b/content/releases/qpid-proton-0.17.0/messenger/python/examples/async.py.html new file mode 100644 index 0000000..48284e7 --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/python/examples/async.py.html @@ -0,0 +1,212 @@ +<!DOCTYPE html> +<!-- + - + - 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. + - +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>async.py - Apache Qpid™</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <link rel="stylesheet" href="/site.css" type="text/css" async="async"/> + <link rel="stylesheet" href="/deferred.css" type="text/css" defer="defer"/> + <script type="text/javascript">var _deferredFunctions = [];</script> + <script type="text/javascript" src="/deferred.js" defer="defer"></script> + <!--[if lte IE 8]> + <link rel="stylesheet" href="/ie.css" type="text/css"/> + <script type="text/javascript" src="/html5shiv.js"></script> + <![endif]--> + + <!-- Redirects for `go get` and godoc.org --> + <meta name="go-import" + content="qpid.apache.org git https://git-wip-us.apache.org/repos/asf/qpid-proton.git"/> + <meta name="go-source" + content="qpid.apache.org +https://github.com/apache/qpid-proton/blob/go1/README.md +https://github.com/apache/qpid-proton/tree/go1{/dir} +https://github.com/apache/qpid-proton/blob/go1{/dir}/{file}#L{line}"/> + </head> + <body> + <div id="-content"> + <div id="-top" class="panel"> + <a id="-menu-link"><img width="16" height="16" src="" alt="Menu"/></a> + + <a id="-search-link"><img width="22" height="16" src="" alt="Search"/></a> + + <ul id="-global-navigation"> + <li><a id="-logotype" href="/index.html">Apache Qpid<sup>™</sup></a></li> + <li><a href="/documentation.html">Documentation</a></li> + <li><a href="/download.html">Download</a></li> + <li><a href="/discussion.html">Discussion</a></li> + </ul> + </div> + + <div id="-menu" class="panel" style="display: none;"> + <div class="flex"> + <section> + <h3>Project</h3> + + <ul> + <li><a href="/overview.html">Overview</a></li> + <li><a href="/components/index.html">Components</a></li> + <li><a href="/releases/index.html">Releases</a></li> + </ul> + </section> + + <section> + <h3>Messaging APIs</h3> + + <ul> + <li><a href="/proton/index.html">Qpid Proton</a></li> + <li><a href="/components/jms/index.html">Qpid JMS</a></li> + <li><a href="/components/messaging-api/index.html">Qpid Messaging API</a></li> + </ul> + </section> + + <section> + <h3>Servers and tools</h3> + + <ul> + <li><a href="/components/java-broker/index.html">Broker for Java</a></li> + <li><a href="/components/cpp-broker/index.html">C++ broker</a></li> + <li><a href="/components/dispatch-router/index.html">Dispatch router</a></li> + </ul> + </section> + + <section> + <h3>Resources</h3> + + <ul> + <li><a href="/dashboard.html">Dashboard</a></li> + <li><a href="https://cwiki.apache.org/confluence/display/qpid/Index">Wiki</a></li> + <li><a href="/resources.html">More resources</a></li> + </ul> + </section> + </div> + </div> + + <div id="-search" class="panel" style="display: none;"> + <form action="http://www.google.com/search" method="get"> + <input type="hidden" name="sitesearch" value="qpid.apache.org"/> + <input type="text" name="q" maxlength="255" autofocus="autofocus" tabindex="1"/> + <button type="submit">Search</button> + <a href="/search.html">More ways to search</a> + </form> + </div> + + <div id="-middle" class="panel"> + <ul id="-path-navigation"><li><a href="/index.html">Home</a></li><li><a href="/releases/index.html">Releases</a></li><li><a href="/releases/qpid-proton-0.17.0/index.html">Qpid Proton 0.17.0</a></li><li><a href="/releases/qpid-proton-0.17.0/messenger/python/examples/index.html">Python AMQP Messenger Examples</a></li><li>async.py</li></ul> + + <div id="-middle-content"> + +<h1>async.py</h1> +<div class="highlight"><pre><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">print_function</span> +<span class="kn">import</span> <span class="nn">sys</span> +<span class="kn">from</span> <span class="nn">proton</span> <span class="kn">import</span> <span class="o">*</span> + +<span class="k">class</span> <span class="nc">CallbackAdapter</span><span class="p">:</span> + + <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">messenger</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span> <span class="o">=</span> <span class="n">messenger</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">blocking</span> <span class="o">=</span> <span class="bp">False</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">outgoing_window</span> <span class="o">=</span> <span class="mi">1024</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">incoming_window</span> <span class="o">=</span> <span class="mi">1024</span> + <span class="c"># for application use</span> + <span class="bp">self</span><span class="o">.</span><span class="n">message</span> <span class="o">=</span> <span class="n">Message</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_incoming_message</span> <span class="o">=</span> <span class="n">Message</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">tracked</span> <span class="o">=</span> <span class="p">{}</span> + + <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">running</span> <span class="o">=</span> <span class="bp">True</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">start</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">on_start</span><span class="p">()</span> + + <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">running</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">work</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="p">()</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span> + + <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">stopped</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">work</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="p">()</span> + + <span class="bp">self</span><span class="o">.</span><span class="n">on_stop</span><span class="p">()</span> + + <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">running</span> <span class="o">=</span> <span class="bp">False</span> + + <span class="k">def</span> <span class="nf">_process</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_process_outgoing</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_process_incoming</span><span class="p">()</span> + + <span class="k">def</span> <span class="nf">_process_outgoing</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="k">for</span> <span class="n">t</span><span class="p">,</span> <span class="n">on_status</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tracked</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span> + <span class="n">status</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">status</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> + <span class="k">if</span> <span class="n">status</span> <span class="o">!=</span> <span class="n">PENDING</span><span class="p">:</span> + <span class="n">on_status</span><span class="p">(</span><span class="n">status</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">settle</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> + <span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">tracked</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> + + <span class="k">def</span> <span class="nf">_process_incoming</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">incoming</span><span class="p">:</span> + <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_incoming_message</span><span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">on_recv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_incoming_message</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">accept</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> + <span class="k">except</span><span class="p">:</span> + <span class="n">ex</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">1</span><span class="p">]</span> + <span class="k">print</span><span class="p">(</span><span class="s">"Exception:"</span><span class="p">,</span> <span class="n">ex</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">reject</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> + + <span class="k">def</span> <span class="nf">send</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="n">on_status</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> + <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">messenger</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> + <span class="k">if</span> <span class="n">on_status</span><span class="p">:</span> + <span class="bp">self</span><span class="o">.</span><span class="n">tracked</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">=</span> <span class="n">on_status</span> +</pre></div> + +<p><a href="async.py">Download this file</a></p> + + + <hr/> + + <ul id="-apache-navigation"> + <li><a href="http://www.apache.org/">Apache</a></li> + <li><a href="http://www.apache.org/licenses/">License</a></li> + <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> + <li><a href="http://www.apache.org/foundation/thanks.html">Thanks!</a></li> + <li><a href="/security.html">Security</a></li> + <li><a href="http://www.apache.org/"><img id="-apache-feather" width="48" height="14" src="" alt="Apache"/></a></li> + </ul> + + <p id="-legal"> + Apache Qpid, Messaging built on AMQP; Copyright © 2015 + The Apache Software Foundation; Licensed under + the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache + License, Version 2.0</a>; Apache Qpid, Qpid, Qpid Proton, + Proton, Apache, the Apache feather logo, and the Apache Qpid + project logo are trademarks of The Apache Software + Foundation; All other marks mentioned may be trademarks or + registered trademarks of their respective owners + </p> + </div> + </div> + </div> + </body> +</html> http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/python/examples/client.py ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/python/examples/client.py b/content/releases/qpid-proton-0.17.0/messenger/python/examples/client.py new file mode 100755 index 0000000..62fc16e --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/python/examples/client.py @@ -0,0 +1,56 @@ +#!/usr/bin/python +# +# 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. +# +from __future__ import print_function +import sys, optparse +from proton import * + +parser = optparse.OptionParser(usage="usage: %prog <addr> <subject>", + description="simple message server") + +parser.add_option("-r", "--reply_to", default="~/replies", + help="address: [amqp://]<domain>[/<name>] (default %default)") + +opts, args = parser.parse_args() + +if len(args) != 2: + parser.error("incorrect number of arguments") + +address, subject = args + +mng = Messenger() +mng.start() + +msg = Message() +msg.address = address +msg.subject = subject +msg.reply_to = opts.reply_to + +mng.put(msg) +mng.send() + +if opts.reply_to[:2] == "~/": + mng.recv(1) + try: + mng.get(msg) + print(msg.address, msg.subject) + except Exception as e: + print(e) + +mng.stop() http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/python/examples/client.py.html ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/python/examples/client.py.html b/content/releases/qpid-proton-0.17.0/messenger/python/examples/client.py.html new file mode 100644 index 0000000..a85c402 --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/python/examples/client.py.html @@ -0,0 +1,186 @@ +<!DOCTYPE html> +<!-- + - + - 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. + - +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>client.py - Apache Qpid™</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <link rel="stylesheet" href="/site.css" type="text/css" async="async"/> + <link rel="stylesheet" href="/deferred.css" type="text/css" defer="defer"/> + <script type="text/javascript">var _deferredFunctions = [];</script> + <script type="text/javascript" src="/deferred.js" defer="defer"></script> + <!--[if lte IE 8]> + <link rel="stylesheet" href="/ie.css" type="text/css"/> + <script type="text/javascript" src="/html5shiv.js"></script> + <![endif]--> + + <!-- Redirects for `go get` and godoc.org --> + <meta name="go-import" + content="qpid.apache.org git https://git-wip-us.apache.org/repos/asf/qpid-proton.git"/> + <meta name="go-source" + content="qpid.apache.org +https://github.com/apache/qpid-proton/blob/go1/README.md +https://github.com/apache/qpid-proton/tree/go1{/dir} +https://github.com/apache/qpid-proton/blob/go1{/dir}/{file}#L{line}"/> + </head> + <body> + <div id="-content"> + <div id="-top" class="panel"> + <a id="-menu-link"><img width="16" height="16" src="" alt="Menu"/></a> + + <a id="-search-link"><img width="22" height="16" src="" alt="Search"/></a> + + <ul id="-global-navigation"> + <li><a id="-logotype" href="/index.html">Apache Qpid<sup>™</sup></a></li> + <li><a href="/documentation.html">Documentation</a></li> + <li><a href="/download.html">Download</a></li> + <li><a href="/discussion.html">Discussion</a></li> + </ul> + </div> + + <div id="-menu" class="panel" style="display: none;"> + <div class="flex"> + <section> + <h3>Project</h3> + + <ul> + <li><a href="/overview.html">Overview</a></li> + <li><a href="/components/index.html">Components</a></li> + <li><a href="/releases/index.html">Releases</a></li> + </ul> + </section> + + <section> + <h3>Messaging APIs</h3> + + <ul> + <li><a href="/proton/index.html">Qpid Proton</a></li> + <li><a href="/components/jms/index.html">Qpid JMS</a></li> + <li><a href="/components/messaging-api/index.html">Qpid Messaging API</a></li> + </ul> + </section> + + <section> + <h3>Servers and tools</h3> + + <ul> + <li><a href="/components/java-broker/index.html">Broker for Java</a></li> + <li><a href="/components/cpp-broker/index.html">C++ broker</a></li> + <li><a href="/components/dispatch-router/index.html">Dispatch router</a></li> + </ul> + </section> + + <section> + <h3>Resources</h3> + + <ul> + <li><a href="/dashboard.html">Dashboard</a></li> + <li><a href="https://cwiki.apache.org/confluence/display/qpid/Index">Wiki</a></li> + <li><a href="/resources.html">More resources</a></li> + </ul> + </section> + </div> + </div> + + <div id="-search" class="panel" style="display: none;"> + <form action="http://www.google.com/search" method="get"> + <input type="hidden" name="sitesearch" value="qpid.apache.org"/> + <input type="text" name="q" maxlength="255" autofocus="autofocus" tabindex="1"/> + <button type="submit">Search</button> + <a href="/search.html">More ways to search</a> + </form> + </div> + + <div id="-middle" class="panel"> + <ul id="-path-navigation"><li><a href="/index.html">Home</a></li><li><a href="/releases/index.html">Releases</a></li><li><a href="/releases/qpid-proton-0.17.0/index.html">Qpid Proton 0.17.0</a></li><li><a href="/releases/qpid-proton-0.17.0/messenger/python/examples/index.html">Python AMQP Messenger Examples</a></li><li>client.py</li></ul> + + <div id="-middle-content"> + +<h1>client.py</h1> +<div class="highlight"><pre><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">print_function</span> +<span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">optparse</span> +<span class="kn">from</span> <span class="nn">proton</span> <span class="kn">import</span> <span class="o">*</span> + +<span class="n">parser</span> <span class="o">=</span> <span class="n">optparse</span><span class="o">.</span><span class="n">OptionParser</span><span class="p">(</span><span class="n">usage</span><span class="o">=</span><span class="s">"usage: %prog <addr> <subject>"</span><span class="p">,</span> + <span class="n">description</span><span class="o">=</span><span class="s">"simple message server"</span><span class="p">)</span> + +<span class="n">parser</span><span class="o">.</span><span class="n">add_option</span><span class="p">(</span><span class="s">"-r"</span><span class="p">,</span> <span class="s">"--reply_to"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s">"~/replies"</span><span class="p">,</span> + <span class="n">help</span><span class="o">=</span><span class="s">"address: [amqp://]<domain>[/<name>] (default </span><span class="si">%d</span><span class="s">efault)"</span><span class="p">)</span> + +<span class="n">opts</span><span class="p">,</span> <span class="n">args</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">()</span> + +<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">2</span><span class="p">:</span> + <span class="n">parser</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s">"incorrect number of arguments"</span><span class="p">)</span> + +<span class="n">address</span><span class="p">,</span> <span class="n">subject</span> <span class="o">=</span> <span class="n">args</span> + +<span class="n">mng</span> <span class="o">=</span> <span class="n">Messenger</span><span class="p">()</span> +<span class="n">mng</span><span class="o">.</span><span class="n">start</span><span class="p">()</span> + +<span class="n">msg</span> <span class="o">=</span> <span class="n">Message</span><span class="p">()</span> +<span class="n">msg</span><span class="o">.</span><span class="n">address</span> <span class="o">=</span> <span class="n">address</span> +<span class="n">msg</span><span class="o">.</span><span class="n">subject</span> <span class="o">=</span> <span class="n">subject</span> +<span class="n">msg</span><span class="o">.</span><span class="n">reply_to</span> <span class="o">=</span> <span class="n">opts</span><span class="o">.</span><span class="n">reply_to</span> + +<span class="n">mng</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> +<span class="n">mng</span><span class="o">.</span><span class="n">send</span><span class="p">()</span> + +<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">reply_to</span><span class="p">[:</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">"~/"</span><span class="p">:</span> + <span class="n">mng</span><span class="o">.</span><span class="n">recv</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> + <span class="k">try</span><span class="p">:</span> + <span class="n">mng</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> + <span class="k">print</span><span class="p">(</span><span class="n">msg</span><span class="o">.</span><span class="n">address</span><span class="p">,</span> <span class="n">msg</span><span class="o">.</span><span class="n">subject</span><span class="p">)</span> + <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> + <span class="k">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> + +<span class="n">mng</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span> +</pre></div> + +<p><a href="client.py">Download this file</a></p> + + + <hr/> + + <ul id="-apache-navigation"> + <li><a href="http://www.apache.org/">Apache</a></li> + <li><a href="http://www.apache.org/licenses/">License</a></li> + <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> + <li><a href="http://www.apache.org/foundation/thanks.html">Thanks!</a></li> + <li><a href="/security.html">Security</a></li> + <li><a href="http://www.apache.org/"><img id="-apache-feather" width="48" height="14" src="" alt="Apache"/></a></li> + </ul> + + <p id="-legal"> + Apache Qpid, Messaging built on AMQP; Copyright © 2015 + The Apache Software Foundation; Licensed under + the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache + License, Version 2.0</a>; Apache Qpid, Qpid, Qpid Proton, + Proton, Apache, the Apache feather logo, and the Apache Qpid + project logo are trademarks of The Apache Software + Foundation; All other marks mentioned may be trademarks or + registered trademarks of their respective owners + </p> + </div> + </div> + </div> + </body> +</html> http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/python/examples/index.html ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/python/examples/index.html b/content/releases/qpid-proton-0.17.0/messenger/python/examples/index.html new file mode 100644 index 0000000..fb076a2 --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/python/examples/index.html @@ -0,0 +1,164 @@ +<!DOCTYPE html> +<!-- + - + - 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. + - +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>Python AMQP Messenger Examples - Apache Qpid™</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <link rel="stylesheet" href="/site.css" type="text/css" async="async"/> + <link rel="stylesheet" href="/deferred.css" type="text/css" defer="defer"/> + <script type="text/javascript">var _deferredFunctions = [];</script> + <script type="text/javascript" src="/deferred.js" defer="defer"></script> + <!--[if lte IE 8]> + <link rel="stylesheet" href="/ie.css" type="text/css"/> + <script type="text/javascript" src="/html5shiv.js"></script> + <![endif]--> + + <!-- Redirects for `go get` and godoc.org --> + <meta name="go-import" + content="qpid.apache.org git https://git-wip-us.apache.org/repos/asf/qpid-proton.git"/> + <meta name="go-source" + content="qpid.apache.org +https://github.com/apache/qpid-proton/blob/go1/README.md +https://github.com/apache/qpid-proton/tree/go1{/dir} +https://github.com/apache/qpid-proton/blob/go1{/dir}/{file}#L{line}"/> + </head> + <body> + <div id="-content"> + <div id="-top" class="panel"> + <a id="-menu-link"><img width="16" height="16" src="" alt="Menu"/></a> + + <a id="-search-link"><img width="22" height="16" src="" alt="Search"/></a> + + <ul id="-global-navigation"> + <li><a id="-logotype" href="/index.html">Apache Qpid<sup>™</sup></a></li> + <li><a href="/documentation.html">Documentation</a></li> + <li><a href="/download.html">Download</a></li> + <li><a href="/discussion.html">Discussion</a></li> + </ul> + </div> + + <div id="-menu" class="panel" style="display: none;"> + <div class="flex"> + <section> + <h3>Project</h3> + + <ul> + <li><a href="/overview.html">Overview</a></li> + <li><a href="/components/index.html">Components</a></li> + <li><a href="/releases/index.html">Releases</a></li> + </ul> + </section> + + <section> + <h3>Messaging APIs</h3> + + <ul> + <li><a href="/proton/index.html">Qpid Proton</a></li> + <li><a href="/components/jms/index.html">Qpid JMS</a></li> + <li><a href="/components/messaging-api/index.html">Qpid Messaging API</a></li> + </ul> + </section> + + <section> + <h3>Servers and tools</h3> + + <ul> + <li><a href="/components/java-broker/index.html">Broker for Java</a></li> + <li><a href="/components/cpp-broker/index.html">C++ broker</a></li> + <li><a href="/components/dispatch-router/index.html">Dispatch router</a></li> + </ul> + </section> + + <section> + <h3>Resources</h3> + + <ul> + <li><a href="/dashboard.html">Dashboard</a></li> + <li><a href="https://cwiki.apache.org/confluence/display/qpid/Index">Wiki</a></li> + <li><a href="/resources.html">More resources</a></li> + </ul> + </section> + </div> + </div> + + <div id="-search" class="panel" style="display: none;"> + <form action="http://www.google.com/search" method="get"> + <input type="hidden" name="sitesearch" value="qpid.apache.org"/> + <input type="text" name="q" maxlength="255" autofocus="autofocus" tabindex="1"/> + <button type="submit">Search</button> + <a href="/search.html">More ways to search</a> + </form> + </div> + + <div id="-middle" class="panel"> + <ul id="-path-navigation"><li><a href="/index.html">Home</a></li><li><a href="/releases/index.html">Releases</a></li><li><a href="/releases/qpid-proton-0.17.0/index.html">Qpid Proton 0.17.0</a></li><li>Python AMQP Messenger Examples</li></ul> + + <div id="-middle-content"> + <h1 id="python-amqp-messenger-examples">Python AMQP Messenger Examples</h1> + +<h2 id="example-files">Example files</h2> + +<ul> +<li><a href="async.py.html">async.py</a></li> +<li><a href="client.py.html">client.py</a></li> +<li><a href="recv.py.html">recv.py</a></li> +<li><a href="recv_async.py.html">recv_async.py</a></li> +<li><a href="send.py.html">send.py</a></li> +<li><a href="send_async.py.html">send_async.py</a></li> +<li><a href="server.py.html">server.py</a></li> +</ul> + +<h2 id="more-information">More information</h2> + +<ul> +<li><a href="https://github.com/apache/qpid-proton/tree/0.17.0/examples/python/messenger/README.txt">README</a></li> +<li><a href="https://github.com/apache/qpid-proton/tree/0.17.0/examples/python/messenger">Source location</a></li> +</ul> + + + <hr/> + + <ul id="-apache-navigation"> + <li><a href="http://www.apache.org/">Apache</a></li> + <li><a href="http://www.apache.org/licenses/">License</a></li> + <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> + <li><a href="http://www.apache.org/foundation/thanks.html">Thanks!</a></li> + <li><a href="/security.html">Security</a></li> + <li><a href="http://www.apache.org/"><img id="-apache-feather" width="48" height="14" src="" alt="Apache"/></a></li> + </ul> + + <p id="-legal"> + Apache Qpid, Messaging built on AMQP; Copyright © 2015 + The Apache Software Foundation; Licensed under + the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache + License, Version 2.0</a>; Apache Qpid, Qpid, Qpid Proton, + Proton, Apache, the Apache feather logo, and the Apache Qpid + project logo are trademarks of The Apache Software + Foundation; All other marks mentioned may be trademarks or + registered trademarks of their respective owners + </p> + </div> + </div> + </div> + </body> +</html> http://git-wip-us.apache.org/repos/asf/qpid-site/blob/1859e58c/content/releases/qpid-proton-0.17.0/messenger/python/examples/recv.py ---------------------------------------------------------------------- diff --git a/content/releases/qpid-proton-0.17.0/messenger/python/examples/recv.py b/content/releases/qpid-proton-0.17.0/messenger/python/examples/recv.py new file mode 100755 index 0000000..5771bd7 --- /dev/null +++ b/content/releases/qpid-proton-0.17.0/messenger/python/examples/recv.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +# +# 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. +# +from __future__ import print_function +import sys, optparse +from proton import * + +parser = optparse.OptionParser(usage="usage: %prog [options] <addr_1> ... <addr_n>", + description="simple message receiver") +parser.add_option("-c", "--certificate", help="path to certificate file") +parser.add_option("-k", "--private-key", help="path to private key file") +parser.add_option("-p", "--password", help="password for private key file") + +opts, args = parser.parse_args() + +if not args: + args = ["amqp://~0.0.0.0"] + +mng = Messenger() +mng.certificate=opts.certificate +mng.private_key=opts.private_key +mng.password=opts.password +mng.start() + +for a in args: + mng.subscribe(a) + +msg = Message() +while True: + mng.recv() + while mng.incoming: + try: + mng.get(msg) + except Exception as e: + print(e) + else: + print(msg.address, msg.subject or "(no subject)", msg.properties, msg.body) + +mng.stop() --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
