You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2014/08/12 16:01:01 UTC
svn commit: r1617478 - in /qpid/proton/branches/examples/tutorial: ./
_build/doctrees/ _build/html/ _build/html/_sources/
Author: gsim
Date: Tue Aug 12 14:01:00 2014
New Revision: 1617478
URL: http://svn.apache.org/r1617478
Log:
Updates following feedback from Alan Conway
Added:
qpid/proton/branches/examples/tutorial/proton_events.py
- copied, changed from r1616829, qpid/proton/branches/examples/tutorial/proton_utils.py
Removed:
qpid/proton/branches/examples/tutorial/proton_utils.py
qpid/proton/branches/examples/tutorial/simple_send_2.py
Modified:
qpid/proton/branches/examples/tutorial/_build/doctrees/environment.pickle
qpid/proton/branches/examples/tutorial/_build/doctrees/tutorial.doctree
qpid/proton/branches/examples/tutorial/_build/html/_sources/tutorial.txt
qpid/proton/branches/examples/tutorial/_build/html/searchindex.js
qpid/proton/branches/examples/tutorial/_build/html/tutorial.html
qpid/proton/branches/examples/tutorial/client.py
qpid/proton/branches/examples/tutorial/helloworld.py
qpid/proton/branches/examples/tutorial/helloworld_alt.py
qpid/proton/branches/examples/tutorial/helloworld_direct.py
qpid/proton/branches/examples/tutorial/helloworld_direct_alt.py
qpid/proton/branches/examples/tutorial/server.py
qpid/proton/branches/examples/tutorial/simple_recv.py
qpid/proton/branches/examples/tutorial/simple_recv_2.py
qpid/proton/branches/examples/tutorial/simple_send.py
qpid/proton/branches/examples/tutorial/tutorial.rst
Modified: qpid/proton/branches/examples/tutorial/_build/doctrees/environment.pickle
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/_build/doctrees/environment.pickle?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
Binary files - no diff available.
Modified: qpid/proton/branches/examples/tutorial/_build/doctrees/tutorial.doctree
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/_build/doctrees/tutorial.doctree?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
Binary files - no diff available.
Modified: qpid/proton/branches/examples/tutorial/_build/html/_sources/tutorial.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/_build/html/_sources/tutorial.txt?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/_build/html/_sources/tutorial.txt (original)
+++ qpid/proton/branches/examples/tutorial/_build/html/_sources/tutorial.txt Tue Aug 12 14:01:00 2014
@@ -5,13 +5,13 @@ Hello World!
Tradition dictates that we start with hello world! However rather than
simply striving for the shortest program possible, we'll aim for a
more illustrative example while still restricting the functionality to
-simply sending and receiving a single message.
+sending and receiving a single message.
.. literalinclude:: helloworld.py
:lines: 21-
:linenos:
-You can see the import of ``Container`` from ``proton_utils`` on the
+You can see the import of ``EventLoop`` from ``proton_events`` on the
second line. This is a helper class that makes programming with proton
a little easier for the common cases. It includes within it an event
loop, and programs written using this utility are generally structured
@@ -20,7 +20,7 @@ to messaging applications.
To be notified of a particular event, you define a class with the
appropriately name method on it. That method is then called by the
-container when the event occurs.
+event loop when the event occurs.
The first class we define, ``HelloWorldReceiver``, handles the event
where a message is received and so implements a ``on_message()``
@@ -37,14 +37,14 @@ message, which we do on line 11, so we c
link on line 12.
The ``HelloWorld`` class ties everything together. It's constructor
-takes the instance of the container to use, a url to connect to, and
+takes the instance of the event loop to use, a url to connect to, and
an address through which the message will be sent. To run the example
you will need to have a broker (or similar) accepting connections on
that url either with a queue (or topic) matching the given address or
else configured to create such a queue (or topic) dynamically.
On line 17 we request that a connection be made to the process this
-url refers to by calling ``connect()`` on the ``Container``. This call
+url refers to by calling ``connect()`` on the ``EventLoop``. This call
returns a ``MessagingContext`` object through which we can create
objects for sending and receiving messages to the process it is
connected to. However we will delay doing that until our connection is
@@ -64,9 +64,9 @@ and ``on_connection_remote_close()`` als
if the broker we are connected to closes either link or the connection
for any reason.
-Finally we actually enter the event loop the container to handle all
-the necessary IO and make all the necessary event callbacks, by
-calling ``run()`` on it.
+Finally we actually enter the event loop, to handle all the necessary
+IO and make all the necessary event callbacks, by calling ``run()`` on
+it.
====================
Hello World, Direct!
@@ -85,19 +85,19 @@ Let's modify our example to demonstrate
The first difference, on line 17, is that rather than creating a
receiver on the same connection as our sender, we listen for incoming
-connections by invoking the ``listen() method on the ``Container``
+connections by invoking the ``listen() method on the ``EventLoop``
instance.
-Another difference is that the ``Container`` instance we use is not
+Another difference is that the ``EventLoop`` instance we use is not
the default instance as was used in the original example, but one we
construct ourselves on line 38, passing in some event handlers. The
first of these is ``HelloWorldReceiver``, as used in the original
-example. We pass it to the container, because we aren't going to
+example. We pass it to the event loop, because we aren't going to
directly create the receiver here ourselves. Rather we will accept an
incoming connection on which the message will be received. This
handler would then be notified of any incoming message event on any of
-the connections the container controls. As well as our own handler, we
-specify a couple of useful handlers from the ``proton_utils``
+the connections the event loop controls. As well as our own handler, we
+specify a couple of useful handlers from the ``proton_events``
toolkit. The ``Handshaker`` handler will ensure our server follows the
basic handshaking rules laid down by the protocol. The
``FlowController`` will issue credit for incoming messages. We won't
@@ -124,14 +124,14 @@ requirements mentioned for the first hel
Often we want to be notified whether the messages we send arrive at
their intended destination. We can do that by specifying a handler for
-the sender we create with an ``accepted()`` method defined on it. This
+the sender we create with an ``on_message()`` method defined on it. This
will be called whenever a message sent by the sender is accepted by
the remote peer.
When sending a large number of messages, we need to consider whether
the remote peer is able to handle them all. AMQP has a powerful flow
control mechanism through which processes can limit the incoming flow
-of messages. If we implement a ``link_flow()`` method on our sender's
+of messages. If we implement a ``on_link_flow()`` method on our sender's
handler, this will be called whenever the sender is allowed to send
and will prevent messages building up due to the receivers inability
to process them.
@@ -192,8 +192,8 @@ receive our responses.
We need to use the address allocated by the broker as the reply_to
address of our requests. To be notified when the broker has sent us
-back the address to use, we add an ``opened()`` method to our
-receiver's handler, and use that as the trigger to send our first
+back the address to use, we add an ``on_link_remote_open()`` method to
+our receiver's handler, and use that as the trigger to send our first
request.
Modified: qpid/proton/branches/examples/tutorial/_build/html/searchindex.js
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/_build/html/searchindex.js?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/_build/html/searchindex.js (original)
+++ qpid/proton/branches/examples/tutorial/_build/html/searchindex.js Tue Aug 12 14:01:00 2014
@@ -1 +1 @@
-Search.setIndex({objects:{},terms:{all:1,concept:[],illustr:1,code:1,follow:1,incas:1,send:1,program:1,exit:[],sent:1,on_messag:1,util:1,mechan:1,veri:1,did:1,helloworld:1,"try":1,prevent:1,direct:[0,1],slithi:1,second:1,pass:1,further:1,port:[],rath:1,what:[],repli:1,abl:1,"while":1,"new":[],method:1,honour:[],gener:1,here:1,bodi:1,let:1,address:1,modifi:1,valu:[],acceptor:1,convert:1,sender:1,queue:1,credit:1,chang:[],ourselv:1,via:[],incomingmessagehandl:1,wit:1,total:1,establish:1,twa:1,from:1,describ:1,would:1,commun:1,two:1,handler:1,call:1,msg:1,scope:[],tell:1,more:1,sort:1,desir:1,relat:[],particular:1,send_msg:1,given:1,cach:1,must:[],dictat:1,none:1,endpoint:1,work:1,can:1,def:1,control:1,want:1,process:1,accept:1,topic:1,explor:1,listent:[],occur:1,delai:1,rather:1,anoth:1,conn:1,simpl:1,earlier:1,befor:[],associ:[],demonstr:1,alloc:1,issu:1,callback:1,allow:1,enter:1,volum:1,oper:1,over:1,remote_condit:1,becaus:1,through:1,reconnect:[0,1],still:1,dynam:1,paramet:[],conj
unct:1,disconnect:1,link_flow:1,borogrov:1,helloworldsend:1,might:1,easier:1,them:1,"return":1,handl:1,"break":1,mention:1,flowcontrol:1,now:1,mome:1,strive:1,stopper:[],name:1,separ:1,reactiv:1,fulli:1,ensur:1,gire:1,connect:1,our:1,helloworldreceiv:1,todo:1,event:1,special:1,out:1,accomplish:[],req:1,content:0,laid:1,print:1,after:[],differ:1,reason:1,recv:1,shortest:1,care:[],timer:1,messagingcontext:1,first:1,origin:1,rang:1,notifi:1,directli:1,upper:1,onc:1,number:1,restrict:1,instruct:[],done:[],messag:1,open:1,brillig:1,tove:1,construct:1,too:1,on_connection_remote_clos:1,"final":1,listen:1,option:1,specifi:1,provid:1,part:1,than:1,whenev:1,remot:1,structur:1,were:1,"function":1,ani:1,have:1,need:1,requisit:[],inform:[],self:1,client:1,note:1,also:1,without:1,take:1,which:1,singl:1,uppercas:1,gymbl:1,incorpor:1,though:1,object:1,react:1,on_disconnect:1,"class":1,tradit:1,don:1,url:1,later:[],flow:1,doe:1,runtim:[],gracefulli:[],recipi:1,show:1,particularli:1,involv:1,onli:1,c
onfigur:1,should:[],local:[],variou:1,get:1,stop:1,outgoingmessagehandl:1,remote_sourc:1,requir:1,enabl:1,cleanli:[],common:1,contain:1,where:1,on_connection_remote_open:1,respond:1,set:1,see:1,respons:[0,1],close:1,kei:[],pattern:1,written:1,won:1,"import":1,inabl:1,extend:1,style:1,last:1,howev:1,against:[],instanc:1,context:1,logic:1,simpli:1,arriv:1,pop:1,shutdown:[],respect:1,on_link_remote_open:1,coupl:1,connectionhandl:[],due:1,trigger:1,interest:[],basic:[0,1],next_request:1,togeth:1,unauthent:[],"case":1,look:1,servic:1,wabe:1,aim:1,defin:1,invok:1,error:1,loop:1,outgrab:1,helper:1,readi:1,toolkit:1,worri:1,destin:1,senderhandl:[],incom:1,"__init__":1,receiv:1,make:1,same:1,mimsi:1,finish:[],receiverhandl:[],hang:[],temporari:1,implement:1,drain:1,keyboardinterrupt:1,well:1,exampl:[0,1],thi:1,everyth:1,protocol:1,just:1,obtain:1,except:1,littl:1,add:1,els:1,match:1,build:1,applic:1,on_link_remote_clos:1,proton:[0,1],world:[0,1],specif:[],server:1,necessari:1,either:1,often:
1,acknowledg:1,some:[0,1],back:1,handshak:1,confirm:1,definit:1,outgo:[],larg:1,localhost:1,refer:1,run:1,on_link_flow:1,power:1,broker:1,on_accept:1,host:1,peer:1,about:1,actual:1,socket:[],most:[],constructor:1,own:1,within:1,automat:[],appropri:1,down:1,proton_util:1,your:[],wai:[],aren:1,support:1,start:1,much:1,interfac:[],includ:1,suit:1,deliveri:[],offer:1,link:1,line:1,"true":1,count:[],made:1,possibl:1,whether:1,until:1,limit:1,similar:1,expect:1,creat:1,request:[0,1],doesn:[],backoff:1,amqp:1,when:1,detail:1,"default":1,other:[],test:1,you:1,intend:1,sequenc:1,consid:1,rule:1,ignor:[],fact:[],time:[],reply_to:1,hello:[0,1]},objtypes:{},titles:["Some Proton Examples","Hello World!"],objnames:{},filenames:["index","tutorial"]})
\ No newline at end of file
+Search.setIndex({objects:{},terms:{all:1,concept:[],illustr:1,code:1,follow:1,incas:1,send:1,program:1,exit:[],sent:1,on_messag:1,util:1,mechan:1,veri:1,did:1,helloworld:1,"try":1,prevent:1,direct:[0,1],slithi:1,second:1,pass:1,further:1,port:[],rath:1,what:[],repli:1,abl:1,"while":1,"new":[],method:1,honour:[],gener:1,here:1,bodi:1,let:1,address:1,modifi:1,valu:[],acceptor:1,convert:1,sender:1,queue:1,credit:1,chang:[],ourselv:1,via:[],incomingmessagehandl:1,wit:1,total:1,establish:1,twa:1,from:1,describ:1,would:1,commun:1,two:1,handler:1,call:1,msg:1,scope:[],tell:1,more:1,sort:1,desir:1,relat:[],particular:1,send_msg:1,given:1,cach:1,must:[],dictat:1,none:1,endpoint:1,work:1,can:1,def:1,control:1,want:1,process:1,accept:1,topic:1,explor:1,listent:[],occur:1,delai:1,rather:1,anoth:1,conn:1,simpl:1,earlier:1,befor:[],associ:[],demonstr:1,alloc:1,issu:1,callback:1,allow:1,enter:1,volum:1,oper:1,over:1,remote_condit:1,becaus:1,through:1,reconnect:[0,1],still:1,dynam:1,paramet:[],conj
unct:1,disconnect:1,link_flow:[],borogrov:1,helloworldsend:1,might:1,easier:1,them:1,"return":1,handl:1,"break":1,mention:1,flowcontrol:1,now:1,mome:1,strive:1,stopper:[],name:1,separ:1,reactiv:1,fulli:1,ensur:1,gire:1,connect:1,our:1,helloworldreceiv:1,todo:1,event:1,special:1,out:1,accomplish:[],req:1,content:0,laid:1,print:1,after:[],differ:1,reason:1,recv:1,shortest:1,care:[],timer:1,messagingcontext:1,first:1,origin:1,rang:1,notifi:1,directli:1,upper:1,onc:1,number:1,restrict:1,instruct:[],done:[],messag:1,open:1,brillig:1,tove:1,construct:1,too:1,on_connection_remote_clos:1,"final":1,listen:1,option:1,specifi:1,provid:1,part:1,than:1,whenev:1,remot:1,structur:1,were:1,"function":1,ani:1,have:1,need:1,requisit:[],inform:[],self:1,client:1,note:1,also:1,without:1,take:1,which:1,singl:1,uppercas:1,gymbl:1,incorpor:1,though:1,object:1,react:1,on_disconnect:1,"class":1,tradit:1,don:1,url:1,later:[],flow:1,doe:1,runtim:[],gracefulli:[],recipi:1,show:1,particularli:1,involv:1,onli:1,
configur:1,should:[],local:[],variou:1,get:1,stop:1,outgoingmessagehandl:1,remote_sourc:1,requir:1,enabl:1,cleanli:[],common:1,contain:[],where:1,on_connection_remote_open:1,respond:1,set:1,see:1,respons:[0,1],close:1,kei:[],pattern:1,written:1,won:1,"import":1,inabl:1,extend:1,style:1,last:1,howev:1,against:[],instanc:1,context:1,logic:1,simpli:1,arriv:1,pop:1,shutdown:[],respect:1,on_link_remote_open:1,coupl:1,connectionhandl:[],due:1,trigger:1,interest:[],basic:[0,1],next_request:1,togeth:1,unauthent:[],"case":1,look:1,servic:1,wabe:1,aim:1,defin:1,invok:1,error:1,loop:1,outgrab:1,helper:1,readi:1,toolkit:1,worri:1,destin:1,senderhandl:[],incom:1,"__init__":1,receiv:1,make:1,same:1,mimsi:1,finish:[],receiverhandl:[],hang:[],temporari:1,implement:1,appropri:1,keyboardinterrupt:1,well:1,exampl:[0,1],thi:1,everyth:1,protocol:1,just:1,obtain:1,except:1,littl:1,add:1,els:1,match:1,build:1,applic:1,on_link_remote_clos:1,proton:[0,1],world:[0,1],specif:[],server:1,necessari:1,either:1,o
ften:1,acknowledg:1,eventloop:1,some:[0,1],back:1,handshak:1,confirm:1,definit:1,outgo:[],larg:1,localhost:1,refer:1,run:1,on_link_flow:1,power:1,broker:1,on_accept:1,host:1,peer:1,about:1,actual:1,socket:[],most:[],constructor:1,own:1,within:1,automat:[],drain:1,down:1,proton_util:[],your:[],wai:[],aren:1,support:1,start:1,much:1,interfac:[],includ:1,suit:1,deliveri:[],offer:1,link:1,line:1,"true":1,count:[],made:1,possibl:1,whether:1,until:1,limit:1,similar:1,expect:1,creat:1,request:[0,1],doesn:[],backoff:1,amqp:1,when:1,detail:1,proton_ev:1,"default":1,other:[],test:1,you:1,intend:1,sequenc:1,consid:1,rule:1,ignor:[],fact:[],time:[],reply_to:1,hello:[0,1]},objtypes:{},titles:["Some Proton Examples","Hello World!"],objnames:{},filenames:["index","tutorial"]})
\ No newline at end of file
Modified: qpid/proton/branches/examples/tutorial/_build/html/tutorial.html
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/_build/html/tutorial.html?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/_build/html/tutorial.html (original)
+++ qpid/proton/branches/examples/tutorial/_build/html/tutorial.html Tue Aug 12 14:01:00 2014
@@ -52,7 +52,7 @@
<p>Tradition dictates that we start with hello world! However rather than
simply striving for the shortest program possible, we’ll aim for a
more illustrative example while still restricting the functionality to
-simply sending and receiving a single message.</p>
+sending and receiving a single message.</p>
<div class="highlight-python"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
@@ -91,7 +91,7 @@ simply sending and receiving a single me
36
37
38</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">proton</span> <span class="kn">import</span> <span class="n">Message</span>
-<span class="kn">from</span> <span class="nn">proton_utils</span> <span class="kn">import</span> <span class="n">Container</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
+<span class="kn">from</span> <span class="nn">proton_events</span> <span class="kn">import</span> <span class="n">EventLoop</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
<span class="k">class</span> <span class="nc">HelloWorldReceiver</span><span class="p">(</span><span class="n">IncomingMessageHandler</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">on_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
@@ -104,9 +104,9 @@ simply sending and receiving a single me
<span class="n">event</span><span class="o">.</span><span class="n">link</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="k">class</span> <span class="nc">HelloWorld</span><span class="p">(</span><span class="nb">object</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">container</span><span class="p">,</span> <span class="n">url</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">container</span> <span class="o">=</span> <span class="n">container</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</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">eventloop</span><span class="p">,</span> <span class="n">url</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span> <span class="o">=</span> <span class="n">eventloop</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">eventloop</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">address</span> <span class="o">=</span> <span class="n">address</span>
<span class="k">def</span> <span class="nf">on_connection_remote_open</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
@@ -125,12 +125,12 @@ simply sending and receiving a single me
<span class="bp">self</span><span class="o">.</span><span class="n">conn</span><span class="o">.</span><span class="n">close</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">container</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
-<span class="n">HelloWorld</span><span class="p">(</span><span class="n">Container</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+<span class="n">HelloWorld</span><span class="p">(</span><span class="n">EventLoop</span><span class="p">(),</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
</pre></div>
</td></tr></table></div>
-<p>You can see the import of <tt class="docutils literal"><span class="pre">Container</span></tt> from <tt class="docutils literal"><span class="pre">proton_utils</span></tt> on the
+<p>You can see the import of <tt class="docutils literal"><span class="pre">EventLoop</span></tt> from <tt class="docutils literal"><span class="pre">proton_events</span></tt> on the
second line. This is a helper class that makes programming with proton
a little easier for the common cases. It includes within it an event
loop, and programs written using this utility are generally structured
@@ -138,7 +138,7 @@ to react to various events. This reactiv
to messaging applications.</p>
<p>To be notified of a particular event, you define a class with the
appropriately name method on it. That method is then called by the
-container when the event occurs.</p>
+event loop when the event occurs.</p>
<p>The first class we define, <tt class="docutils literal"><span class="pre">HelloWorldReceiver</span></tt>, handles the event
where a message is received and so implements a <tt class="docutils literal"><span class="pre">on_message()</span></tt>
method. Within that we simply print the body of the message (line 6)
@@ -152,13 +152,13 @@ messages might be large. In our case we
message, which we do on line 11, so we can then just close the sending
link on line 12.</p>
<p>The <tt class="docutils literal"><span class="pre">HelloWorld</span></tt> class ties everything together. It’s constructor
-takes the instance of the container to use, a url to connect to, and
+takes the instance of the event loop to use, a url to connect to, and
an address through which the message will be sent. To run the example
you will need to have a broker (or similar) accepting connections on
that url either with a queue (or topic) matching the given address or
else configured to create such a queue (or topic) dynamically.</p>
<p>On line 17 we request that a connection be made to the process this
-url refers to by calling <tt class="docutils literal"><span class="pre">connect()</span></tt> on the <tt class="docutils literal"><span class="pre">Container</span></tt>. This call
+url refers to by calling <tt class="docutils literal"><span class="pre">connect()</span></tt> on the <tt class="docutils literal"><span class="pre">EventLoop</span></tt>. This call
returns a <tt class="docutils literal"><span class="pre">MessagingContext</span></tt> object through which we can create
objects for sending and receiving messages to the process it is
connected to. However we will delay doing that until our connection is
@@ -175,9 +175,9 @@ and passing the handler implementations
and <tt class="docutils literal"><span class="pre">on_connection_remote_close()</span></tt> also, so that we can be notified
if the broker we are connected to closes either link or the connection
for any reason.</p>
-<p>Finally we actually enter the event loop the container to handle all
-the necessary IO and make all the necessary event callbacks, by
-calling <tt class="docutils literal"><span class="pre">run()</span></tt> on it.</p>
+<p>Finally we actually enter the event loop, to handle all the necessary
+IO and make all the necessary event callbacks, by calling <tt class="docutils literal"><span class="pre">run()</span></tt> on
+it.</p>
</div>
<div class="section" id="hello-world-direct">
<h1>Hello World, Direct!<a class="headerlink" href="#hello-world-direct" title="Permalink to this headline">¶</a></h1>
@@ -225,7 +225,7 @@ directly if desired.</p>
38
39
40</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">proton</span> <span class="kn">import</span> <span class="n">Message</span>
-<span class="kn">from</span> <span class="nn">proton_utils</span> <span class="kn">import</span> <span class="n">Container</span><span class="p">,</span> <span class="n">FlowController</span><span class="p">,</span> <span class="n">Handshaker</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
+<span class="kn">from</span> <span class="nn">proton_events</span> <span class="kn">import</span> <span class="n">EventLoop</span><span class="p">,</span> <span class="n">FlowController</span><span class="p">,</span> <span class="n">Handshaker</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
<span class="k">class</span> <span class="nc">HelloWorldReceiver</span><span class="p">(</span><span class="n">IncomingMessageHandler</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">on_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
@@ -238,10 +238,10 @@ directly if desired.</p>
<span class="n">event</span><span class="o">.</span><span class="n">link</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="k">class</span> <span class="nc">HelloWorld</span><span class="p">(</span><span class="nb">object</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">container</span><span class="p">,</span> <span class="n">url</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">container</span> <span class="o">=</span> <span class="n">container</span>
-<span class="hll"> <span class="bp">self</span><span class="o">.</span><span class="n">acceptor</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">listen</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
-</span> <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</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">eventloop</span><span class="p">,</span> <span class="n">url</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span> <span class="o">=</span> <span class="n">eventloop</span>
+<span class="hll"> <span class="bp">self</span><span class="o">.</span><span class="n">acceptor</span> <span class="o">=</span> <span class="n">eventloop</span><span class="o">.</span><span class="n">listen</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
+</span> <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">eventloop</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">address</span> <span class="o">=</span> <span class="n">address</span>
<span class="k">def</span> <span class="nf">on_connection_remote_open</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
@@ -260,26 +260,26 @@ directly if desired.</p>
</span> <span class="bp">self</span><span class="o">.</span><span class="n">acceptor</span><span class="o">.</span><span class="n">close</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">container</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="hll">
-</span><span class="n">container</span> <span class="o">=</span> <span class="n">Container</span><span class="p">(</span><span class="n">HelloWorldReceiver</span><span class="p">(),</span> <span class="n">Handshaker</span><span class="p">(),</span> <span class="n">FlowController</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
-<span class="n">HelloWorld</span><span class="p">(</span><span class="n">container</span><span class="p">,</span> <span class="s">"localhost:8888"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+</span><span class="n">eventloop</span> <span class="o">=</span> <span class="n">EventLoop</span><span class="p">(</span><span class="n">HelloWorldReceiver</span><span class="p">(),</span> <span class="n">Handshaker</span><span class="p">(),</span> <span class="n">FlowController</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
+<span class="n">HelloWorld</span><span class="p">(</span><span class="n">eventloop</span><span class="p">,</span> <span class="s">"localhost:8888"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
</pre></div>
</td></tr></table></div>
<p>The first difference, on line 17, is that rather than creating a
receiver on the same connection as our sender, we listen for incoming
-connections by invoking the <tt class="docutils literal"><span class="pre">listen()</span> <span class="pre">method</span> <span class="pre">on</span> <span class="pre">the</span> <span class="pre">``Container</span></tt>
+connections by invoking the <tt class="docutils literal"><span class="pre">listen()</span> <span class="pre">method</span> <span class="pre">on</span> <span class="pre">the</span> <span class="pre">``EventLoop</span></tt>
instance.</p>
-<p>Another difference is that the <tt class="docutils literal"><span class="pre">Container</span></tt> instance we use is not
+<p>Another difference is that the <tt class="docutils literal"><span class="pre">EventLoop</span></tt> instance we use is not
the default instance as was used in the original example, but one we
construct ourselves on line 38, passing in some event handlers. The
first of these is <tt class="docutils literal"><span class="pre">HelloWorldReceiver</span></tt>, as used in the original
-example. We pass it to the container, because we aren’t going to
+example. We pass it to the event loop, because we aren’t going to
directly create the receiver here ourselves. Rather we will accept an
incoming connection on which the message will be received. This
handler would then be notified of any incoming message event on any of
-the connections the container controls. As well as our own handler, we
-specify a couple of useful handlers from the <tt class="docutils literal"><span class="pre">proton_utils</span></tt>
+the connections the event loop controls. As well as our own handler, we
+specify a couple of useful handlers from the <tt class="docutils literal"><span class="pre">proton_events</span></tt>
toolkit. The <tt class="docutils literal"><span class="pre">Handshaker</span></tt> handler will ensure our server follows the
basic handshaking rules laid down by the protocol. The
<tt class="docutils literal"><span class="pre">FlowController</span></tt> will issue credit for incoming messages. We won’t
@@ -325,12 +325,12 @@ requirements mentioned for the first hel
28
29
30
-31</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">proton_utils</span> <span class="kn">import</span> <span class="n">Container</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
+31</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">proton_events</span> <span class="kn">import</span> <span class="n">EventLoop</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
<span class="k">class</span> <span class="nc">Recv</span><span class="p">(</span><span class="n">IncomingMessageHandler</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">container</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">container</span> <span class="o">=</span> <span class="n">container</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</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">eventloop</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span> <span class="o">=</span> <span class="n">eventloop</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">eventloop</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">address</span> <span class="o">=</span> <span class="n">address</span>
<span class="k">def</span> <span class="nf">on_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
@@ -351,22 +351,22 @@ requirements mentioned for the first hel
<span class="bp">self</span><span class="o">.</span><span class="n">conn</span><span class="o">.</span><span class="n">close</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">container</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">try</span><span class="p">:</span>
- <span class="n">Recv</span><span class="p">(</span><span class="n">Container</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="n">Recv</span><span class="p">(</span><span class="n">EventLoop</span><span class="p">(),</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span> <span class="k">pass</span>
</pre></div>
</td></tr></table></div>
<p>Often we want to be notified whether the messages we send arrive at
their intended destination. We can do that by specifying a handler for
-the sender we create with an <tt class="docutils literal"><span class="pre">accepted()</span></tt> method defined on it. This
+the sender we create with an <tt class="docutils literal"><span class="pre">on_message()</span></tt> method defined on it. This
will be called whenever a message sent by the sender is accepted by
the remote peer.</p>
<p>When sending a large number of messages, we need to consider whether
the remote peer is able to handle them all. AMQP has a powerful flow
control mechanism through which processes can limit the incoming flow
-of messages. If we implement a <tt class="docutils literal"><span class="pre">link_flow()</span></tt> method on our sender’s
+of messages. If we implement a <tt class="docutils literal"><span class="pre">on_link_flow()</span></tt> method on our sender’s
handler, this will be called whenever the sender is allowed to send
and will prevent messages building up due to the receivers inability
to process them.</p>
@@ -422,12 +422,12 @@ we get:</p>
47
48
49</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">proton</span> <span class="kn">import</span> <span class="n">Message</span>
-<span class="kn">from</span> <span class="nn">proton_utils</span> <span class="kn">import</span> <span class="n">OutgoingMessageHandler</span><span class="p">,</span> <span class="n">Container</span>
+<span class="kn">from</span> <span class="nn">proton_events</span> <span class="kn">import</span> <span class="n">OutgoingMessageHandler</span><span class="p">,</span> <span class="n">EventLoop</span>
<span class="k">class</span> <span class="nc">Send</span><span class="p">(</span><span class="n">OutgoingMessageHandler</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">container</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">,</span> <span class="n">messages</span><span class="p">):</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">container</span> <span class="o">=</span> <span class="n">container</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</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">eventloop</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">,</span> <span class="n">messages</span><span class="p">):</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span> <span class="o">=</span> <span class="n">eventloop</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">eventloop</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sent</span> <span class="o">=</span> <span class="mi">0</span>
<span class="bp">self</span><span class="o">.</span><span class="n">confirmed</span> <span class="o">=</span> <span class="mi">0</span>
<span class="bp">self</span><span class="o">.</span><span class="n">total</span> <span class="o">=</span> <span class="n">messages</span>
@@ -467,9 +467,9 @@ we get:</p>
<span class="bp">self</span><span class="o">.</span><span class="n">conn</span><span class="o">.</span><span class="n">close</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">container</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
-<span class="n">Send</span><span class="p">(</span><span class="n">Container</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">,</span> <span class="mi">1000</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+<span class="n">Send</span><span class="p">(</span><span class="n">EventLoop</span><span class="p">(),</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">,</span> <span class="mi">1000</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
</pre></div>
</td></tr></table></div>
</div>
@@ -516,17 +516,17 @@ loop.</p>
36
37
38
-39</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">proton_utils</span> <span class="kn">import</span> <span class="n">IncomingMessageHandler</span><span class="p">,</span> <span class="n">Container</span>
+39</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">proton_events</span> <span class="kn">import</span> <span class="n">IncomingMessageHandler</span><span class="p">,</span> <span class="n">EventLoop</span>
<span class="k">class</span> <span class="nc">Recv</span><span class="p">(</span><span class="n">IncomingMessageHandler</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">container</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">container</span> <span class="o">=</span> <span class="n">container</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">eventloop</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span> <span class="o">=</span> <span class="n">eventloop</span>
<span class="bp">self</span><span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="n">host</span>
<span class="bp">self</span><span class="o">.</span><span class="n">address</span> <span class="o">=</span> <span class="n">address</span>
<span class="bp">self</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">connect</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">conn</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">container</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">host</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">host</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">on_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
<span class="k">print</span> <span class="n">event</span><span class="o">.</span><span class="n">message</span><span class="o">.</span><span class="n">body</span>
@@ -550,10 +550,10 @@ loop.</p>
<span class="bp">self</span><span class="o">.</span><span class="n">connect</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">container</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">try</span><span class="p">:</span>
- <span class="n">Recv</span><span class="p">(</span><span class="n">Container</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="n">Recv</span><span class="p">(</span><span class="n">EventLoop</span><span class="p">(),</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span> <span class="k">pass</span>
</pre></div>
</td></tr></table></div>
@@ -594,12 +594,12 @@ the body of the request converted to upp
25
26
27</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">proton</span> <span class="kn">import</span> <span class="n">Message</span>
-<span class="kn">from</span> <span class="nn">proton_utils</span> <span class="kn">import</span> <span class="n">Container</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
+<span class="kn">from</span> <span class="nn">proton_events</span> <span class="kn">import</span> <span class="n">EventLoop</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
<span class="k">class</span> <span class="nc">Server</span><span class="p">(</span><span class="n">IncomingMessageHandler</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">container</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">container</span> <span class="o">=</span> <span class="n">container</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">host</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">eventloop</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">):</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span> <span class="o">=</span> <span class="n">eventloop</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">eventloop</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">receiver</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conn</span><span class="o">.</span><span class="n">receiver</span><span class="p">(</span><span class="n">address</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">senders</span> <span class="o">=</span> <span class="p">{}</span>
@@ -615,10 +615,10 @@ the body of the request converted to upp
<span class="bp">self</span><span class="o">.</span><span class="n">conn</span><span class="o">.</span><span class="n">close</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">container</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">try</span><span class="p">:</span>
- <span class="n">Server</span><span class="p">(</span><span class="n">Container</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="n">Server</span><span class="p">(</span><span class="n">EventLoop</span><span class="p">(),</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span> <span class="k">pass</span>
</pre></div>
</td></tr></table></div>
@@ -661,12 +661,12 @@ the senders incase we get further reques
32
33
34</pre></div></td><td class="code"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">proton</span> <span class="kn">import</span> <span class="n">Message</span>
-<span class="kn">from</span> <span class="nn">proton_utils</span> <span class="kn">import</span> <span class="n">Container</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
+<span class="kn">from</span> <span class="nn">proton_events</span> <span class="kn">import</span> <span class="n">EventLoop</span><span class="p">,</span> <span class="n">IncomingMessageHandler</span>
<span class="k">class</span> <span class="nc">Client</span><span class="p">(</span><span class="n">IncomingMessageHandler</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">container</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">,</span> <span class="n">requests</span><span class="p">):</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">container</span> <span class="o">=</span> <span class="n">container</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">host</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">eventloop</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">address</span><span class="p">,</span> <span class="n">requests</span><span class="p">):</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span> <span class="o">=</span> <span class="n">eventloop</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">conn</span> <span class="o">=</span> <span class="n">eventloop</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sender</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conn</span><span class="o">.</span><span class="n">sender</span><span class="p">(</span><span class="n">address</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">receiver</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conn</span><span class="o">.</span><span class="n">receiver</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="n">dynamic</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">handler</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">requests</span> <span class="o">=</span> <span class="n">requests</span>
@@ -686,14 +686,14 @@ the senders incase we get further reques
<span class="bp">self</span><span class="o">.</span><span class="n">conn</span><span class="o">.</span><span class="n">close</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">container</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">eventloop</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="n">REQUESTS</span><span class="o">=</span> <span class="p">[</span><span class="s">"Twas brillig, and the slithy toves"</span><span class="p">,</span>
<span class="s">"Did gire and gymble in the wabe."</span><span class="p">,</span>
<span class="s">"All mimsy were the borogroves,"</span><span class="p">,</span>
<span class="s">"And the mome raths outgrabe."</span><span class="p">]</span>
-<span class="n">Client</span><span class="p">(</span><span class="n">Container</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">,</span> <span class="n">REQUESTS</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
+<span class="n">Client</span><span class="p">(</span><span class="n">EventLoop</span><span class="p">(),</span> <span class="s">"localhost:5672"</span><span class="p">,</span> <span class="s">"examples"</span><span class="p">,</span> <span class="n">REQUESTS</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
</pre></div>
</td></tr></table></div>
<p>As well as sending requests, we need to be able to get back the
@@ -703,8 +703,8 @@ we are connected to to create a temporar
receive our responses.</p>
<p>We need to use the address allocated by the broker as the reply_to
address of our requests. To be notified when the broker has sent us
-back the address to use, we add an <tt class="docutils literal"><span class="pre">opened()</span></tt> method to our
-receiver’s handler, and use that as the trigger to send our first
+back the address to use, we add an <tt class="docutils literal"><span class="pre">on_link_remote_open()</span></tt> method to
+our receiver’s handler, and use that as the trigger to send our first
request.</p>
</div>
Modified: qpid/proton/branches/examples/tutorial/client.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/client.py?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/client.py (original)
+++ qpid/proton/branches/examples/tutorial/client.py Tue Aug 12 14:01:00 2014
@@ -19,12 +19,12 @@
#
from proton import Message
-from proton_utils import Container, IncomingMessageHandler
+from proton_events import EventLoop, IncomingMessageHandler
class Client(IncomingMessageHandler):
- def __init__(self, container, host, address, requests):
- self.container = container
- self.conn = container.connect(host)
+ def __init__(self, eventloop, host, address, requests):
+ self.eventloop = eventloop
+ self.conn = eventloop.connect(host)
self.sender = self.conn.sender(address)
self.receiver = self.conn.receiver(None, dynamic=True, handler=self)
self.requests = requests
@@ -44,12 +44,12 @@ class Client(IncomingMessageHandler):
self.conn.close()
def run(self):
- self.container.run()
+ self.eventloop.run()
REQUESTS= ["Twas brillig, and the slithy toves",
"Did gire and gymble in the wabe.",
"All mimsy were the borogroves,",
"And the mome raths outgrabe."]
-Client(Container.DEFAULT, "localhost:5672", "examples", REQUESTS).run()
+Client(EventLoop(), "localhost:5672", "examples", REQUESTS).run()
Modified: qpid/proton/branches/examples/tutorial/helloworld.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld.py?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/helloworld.py (original)
+++ qpid/proton/branches/examples/tutorial/helloworld.py Tue Aug 12 14:01:00 2014
@@ -19,7 +19,7 @@
#
from proton import Message
-from proton_utils import Container, IncomingMessageHandler
+from proton_events import EventLoop, IncomingMessageHandler
class HelloWorldReceiver(IncomingMessageHandler):
def on_message(self, event):
@@ -32,9 +32,9 @@ class HelloWorldSender(object):
event.link.close()
class HelloWorld(object):
- def __init__(self, container, url, address):
- self.container = container
- self.conn = container.connect(url, handler=self)
+ def __init__(self, eventloop, url, address):
+ self.eventloop = eventloop
+ self.conn = eventloop.connect(url, handler=self)
self.address = address
def on_connection_remote_open(self, event):
@@ -53,7 +53,7 @@ class HelloWorld(object):
self.conn.close()
def run(self):
- self.container.run()
+ self.eventloop.run()
-HelloWorld(Container.DEFAULT, "localhost:5672", "examples").run()
+HelloWorld(EventLoop(), "localhost:5672", "examples").run()
Modified: qpid/proton/branches/examples/tutorial/helloworld_alt.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld_alt.py?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/helloworld_alt.py (original)
+++ qpid/proton/branches/examples/tutorial/helloworld_alt.py Tue Aug 12 14:01:00 2014
@@ -19,12 +19,12 @@
#
from proton import Message
-from proton_utils import Container, IncomingMessageHandler
+from proton_events import EventLoop, IncomingMessageHandler
class HelloWorld(IncomingMessageHandler):
- def __init__(self, container, url, address):
- self.container = container
- self.conn = container.connect(url, handler=self)
+ def __init__(self, eventloop, url, address):
+ self.eventloop = eventloop
+ self.conn = eventloop.connect(url, handler=self)
self.address = address
def on_connection_remote_open(self, event):
@@ -51,7 +51,7 @@ class HelloWorld(IncomingMessageHandler)
self.conn.close()
def run(self):
- self.container.run()
+ self.eventloop.run()
-HelloWorld(Container.DEFAULT, "localhost:5672", "examples").run()
+HelloWorld(EventLoop(), "localhost:5672", "examples").run()
Modified: qpid/proton/branches/examples/tutorial/helloworld_direct.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld_direct.py?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/helloworld_direct.py (original)
+++ qpid/proton/branches/examples/tutorial/helloworld_direct.py Tue Aug 12 14:01:00 2014
@@ -19,7 +19,7 @@
#
from proton import Message
-from proton_utils import Container, FlowController, Handshaker, IncomingMessageHandler
+from proton_events import EventLoop, FlowController, Handshaker, IncomingMessageHandler
class HelloWorldReceiver(IncomingMessageHandler):
def on_message(self, event):
@@ -32,10 +32,10 @@ class HelloWorldSender(object):
event.link.close()
class HelloWorld(object):
- def __init__(self, container, url, address):
- self.container = container
- self.acceptor = container.listen(url)
- self.conn = container.connect(url, handler=self)
+ def __init__(self, eventloop, url, address):
+ self.eventloop = eventloop
+ self.acceptor = eventloop.listen(url)
+ self.conn = eventloop.connect(url, handler=self)
self.address = address
def on_connection_remote_open(self, event):
@@ -54,8 +54,8 @@ class HelloWorld(object):
self.acceptor.close()
def run(self):
- self.container.run()
+ self.eventloop.run()
-container = Container(HelloWorldReceiver(), Handshaker(), FlowController(1))
-HelloWorld(container, "localhost:8888", "examples").run()
+eventloop = EventLoop(HelloWorldReceiver(), Handshaker(), FlowController(1))
+HelloWorld(eventloop, "localhost:8888", "examples").run()
Modified: qpid/proton/branches/examples/tutorial/helloworld_direct_alt.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld_direct_alt.py?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/helloworld_direct_alt.py (original)
+++ qpid/proton/branches/examples/tutorial/helloworld_direct_alt.py Tue Aug 12 14:01:00 2014
@@ -19,7 +19,7 @@
#
from proton import Message
-from proton_utils import Container, FlowController, Handshaker, IncomingMessageHandler
+from proton_events import EventLoop, FlowController, Handshaker, IncomingMessageHandler
class HelloWorldReceiver(IncomingMessageHandler):
def on_message(self, event):
@@ -27,10 +27,10 @@ class HelloWorldReceiver(IncomingMessage
event.connection.close()
class HelloWorld(object):
- def __init__(self, container, url, address):
- self.container = container
- self.acceptor = container.listen(url)
- self.conn = container.connect(url, handler=self)
+ def __init__(self, eventloop, url, address):
+ self.eventloop = eventloop
+ self.acceptor = eventloop.listen(url)
+ self.conn = eventloop.connect(url, handler=self)
self.address = address
def on_connection_remote_open(self, event):
@@ -53,7 +53,7 @@ class HelloWorld(object):
self.acceptor.close()
def run(self):
- self.container.run()
+ self.eventloop.run()
-container = Container(HelloWorldReceiver(), Handshaker(), FlowController(1))
-HelloWorld(container, "localhost:8888", "examples").run()
+eventloop = EventLoop(HelloWorldReceiver(), Handshaker(), FlowController(1))
+HelloWorld(eventloop, "localhost:8888", "examples").run()
Copied: qpid/proton/branches/examples/tutorial/proton_events.py (from r1616829, qpid/proton/branches/examples/tutorial/proton_utils.py)
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/proton_events.py?p2=qpid/proton/branches/examples/tutorial/proton_events.py&p1=qpid/proton/branches/examples/tutorial/proton_utils.py&r1=1616829&r2=1617478&rev=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/proton_utils.py (original)
+++ qpid/proton/branches/examples/tutorial/proton_events.py Tue Aug 12 14:01:00 2014
@@ -16,9 +16,9 @@
# specific language governing permissions and limitations
# under the License.
#
-import os, random, types
-from proton import *
-import socket
+import os, socket, types
+from proton import Collector, Connection, Delivery, Endpoint, Event
+from proton import Message, ProtonException, Transport, TransportException
from select import select
class EventDispatcher(object):
@@ -528,9 +528,12 @@ class MessagingContext(object):
self.conn.close()
-class Container(object):
+class EventLoop(object):
def __init__(self, *handlers):
- self.loop = SelectLoop(Events(ScopedDispatcher(), *handlers))
+ l = [ScopedDispatcher()]
+ if handlers: l += handlers
+ else: l.append(FlowController(10))
+ self.loop = SelectLoop(Events(*l))
def connect(self, url, name=None, handler=None):
identifier = name or url
@@ -550,5 +553,3 @@ class Container(object):
def run(self):
self.loop.run()
-Container.DEFAULT = Container(FlowController(10))
-
Modified: qpid/proton/branches/examples/tutorial/server.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/server.py?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/server.py (original)
+++ qpid/proton/branches/examples/tutorial/server.py Tue Aug 12 14:01:00 2014
@@ -19,12 +19,12 @@
#
from proton import Message
-from proton_utils import Container, IncomingMessageHandler
+from proton_events import EventLoop, IncomingMessageHandler
class Server(IncomingMessageHandler):
- def __init__(self, container, host, address):
- self.container = container
- self.conn = container.connect(host)
+ def __init__(self, eventloop, host, address):
+ self.eventloop = eventloop
+ self.conn = eventloop.connect(host)
self.receiver = self.conn.receiver(address, handler=self)
self.senders = {}
@@ -40,10 +40,10 @@ class Server(IncomingMessageHandler):
self.conn.close()
def run(self):
- self.container.run()
+ self.eventloop.run()
try:
- Server(Container.DEFAULT, "localhost:5672", "examples").run()
+ Server(EventLoop(), "localhost:5672", "examples").run()
except KeyboardInterrupt: pass
Modified: qpid/proton/branches/examples/tutorial/simple_recv.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/simple_recv.py?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/simple_recv.py (original)
+++ qpid/proton/branches/examples/tutorial/simple_recv.py Tue Aug 12 14:01:00 2014
@@ -18,12 +18,12 @@
# under the License.
#
-from proton_utils import Container, IncomingMessageHandler
+from proton_events import EventLoop, IncomingMessageHandler
class Recv(IncomingMessageHandler):
- def __init__(self, container, host, address):
- self.container = container
- self.conn = container.connect(host, handler=self)
+ def __init__(self, eventloop, host, address):
+ self.eventloop = eventloop
+ self.conn = eventloop.connect(host, handler=self)
self.address = address
def on_message(self, event):
@@ -44,10 +44,10 @@ class Recv(IncomingMessageHandler):
self.conn.close()
def run(self):
- self.container.run()
+ self.eventloop.run()
try:
- Recv(Container.DEFAULT, "localhost:5672", "examples").run()
+ Recv(EventLoop(), "localhost:5672", "examples").run()
except KeyboardInterrupt: pass
Modified: qpid/proton/branches/examples/tutorial/simple_recv_2.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/simple_recv_2.py?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/simple_recv_2.py (original)
+++ qpid/proton/branches/examples/tutorial/simple_recv_2.py Tue Aug 12 14:01:00 2014
@@ -18,17 +18,17 @@
# under the License.
#
-from proton_utils import IncomingMessageHandler, Container
+from proton_events import IncomingMessageHandler, EventLoop
class Recv(IncomingMessageHandler):
- def __init__(self, container, host, address):
- self.container = container
+ def __init__(self, eventloop, host, address):
+ self.eventloop = eventloop
self.host = host
self.address = address
self.connect()
def connect(self):
- self.conn = self.container.connect(self.host, handler=self)
+ self.conn = self.eventloop.connect(self.host, handler=self)
def on_message(self, event):
print event.message.body
@@ -52,10 +52,10 @@ class Recv(IncomingMessageHandler):
self.connect()
def run(self):
- self.container.run()
+ self.eventloop.run()
try:
- Recv(Container.DEFAULT, "localhost:5672", "examples").run()
+ Recv(EventLoop(), "localhost:5672", "examples").run()
except KeyboardInterrupt: pass
Modified: qpid/proton/branches/examples/tutorial/simple_send.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/simple_send.py?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/simple_send.py (original)
+++ qpid/proton/branches/examples/tutorial/simple_send.py Tue Aug 12 14:01:00 2014
@@ -19,12 +19,12 @@
#
from proton import Message
-from proton_utils import OutgoingMessageHandler, Container
+from proton_events import OutgoingMessageHandler, EventLoop
class Send(OutgoingMessageHandler):
- def __init__(self, container, host, address, messages):
- self.container = container
- self.conn = container.connect(host, handler=self)
+ def __init__(self, eventloop, host, address, messages):
+ self.eventloop = eventloop
+ self.conn = eventloop.connect(host, handler=self)
self.sent = 0
self.confirmed = 0
self.total = messages
@@ -64,7 +64,7 @@ class Send(OutgoingMessageHandler):
self.conn.close()
def run(self):
- self.container.run()
+ self.eventloop.run()
-Send(Container.DEFAULT, "localhost:5672", "examples", 1000).run()
+Send(EventLoop(), "localhost:5672", "examples", 1000).run()
Modified: qpid/proton/branches/examples/tutorial/tutorial.rst
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/tutorial.rst?rev=1617478&r1=1617477&r2=1617478&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/tutorial.rst (original)
+++ qpid/proton/branches/examples/tutorial/tutorial.rst Tue Aug 12 14:01:00 2014
@@ -5,13 +5,13 @@ Hello World!
Tradition dictates that we start with hello world! However rather than
simply striving for the shortest program possible, we'll aim for a
more illustrative example while still restricting the functionality to
-simply sending and receiving a single message.
+sending and receiving a single message.
.. literalinclude:: helloworld.py
:lines: 21-
:linenos:
-You can see the import of ``Container`` from ``proton_utils`` on the
+You can see the import of ``EventLoop`` from ``proton_events`` on the
second line. This is a helper class that makes programming with proton
a little easier for the common cases. It includes within it an event
loop, and programs written using this utility are generally structured
@@ -20,7 +20,7 @@ to messaging applications.
To be notified of a particular event, you define a class with the
appropriately name method on it. That method is then called by the
-container when the event occurs.
+event loop when the event occurs.
The first class we define, ``HelloWorldReceiver``, handles the event
where a message is received and so implements a ``on_message()``
@@ -37,14 +37,14 @@ message, which we do on line 11, so we c
link on line 12.
The ``HelloWorld`` class ties everything together. It's constructor
-takes the instance of the container to use, a url to connect to, and
+takes the instance of the event loop to use, a url to connect to, and
an address through which the message will be sent. To run the example
you will need to have a broker (or similar) accepting connections on
that url either with a queue (or topic) matching the given address or
else configured to create such a queue (or topic) dynamically.
On line 17 we request that a connection be made to the process this
-url refers to by calling ``connect()`` on the ``Container``. This call
+url refers to by calling ``connect()`` on the ``EventLoop``. This call
returns a ``MessagingContext`` object through which we can create
objects for sending and receiving messages to the process it is
connected to. However we will delay doing that until our connection is
@@ -64,9 +64,9 @@ and ``on_connection_remote_close()`` als
if the broker we are connected to closes either link or the connection
for any reason.
-Finally we actually enter the event loop the container to handle all
-the necessary IO and make all the necessary event callbacks, by
-calling ``run()`` on it.
+Finally we actually enter the event loop, to handle all the necessary
+IO and make all the necessary event callbacks, by calling ``run()`` on
+it.
====================
Hello World, Direct!
@@ -85,19 +85,19 @@ Let's modify our example to demonstrate
The first difference, on line 17, is that rather than creating a
receiver on the same connection as our sender, we listen for incoming
-connections by invoking the ``listen() method on the ``Container``
+connections by invoking the ``listen() method on the ``EventLoop``
instance.
-Another difference is that the ``Container`` instance we use is not
+Another difference is that the ``EventLoop`` instance we use is not
the default instance as was used in the original example, but one we
construct ourselves on line 38, passing in some event handlers. The
first of these is ``HelloWorldReceiver``, as used in the original
-example. We pass it to the container, because we aren't going to
+example. We pass it to the event loop, because we aren't going to
directly create the receiver here ourselves. Rather we will accept an
incoming connection on which the message will be received. This
handler would then be notified of any incoming message event on any of
-the connections the container controls. As well as our own handler, we
-specify a couple of useful handlers from the ``proton_utils``
+the connections the event loop controls. As well as our own handler, we
+specify a couple of useful handlers from the ``proton_events``
toolkit. The ``Handshaker`` handler will ensure our server follows the
basic handshaking rules laid down by the protocol. The
``FlowController`` will issue credit for incoming messages. We won't
@@ -124,14 +124,14 @@ requirements mentioned for the first hel
Often we want to be notified whether the messages we send arrive at
their intended destination. We can do that by specifying a handler for
-the sender we create with an ``accepted()`` method defined on it. This
+the sender we create with an ``on_message()`` method defined on it. This
will be called whenever a message sent by the sender is accepted by
the remote peer.
When sending a large number of messages, we need to consider whether
the remote peer is able to handle them all. AMQP has a powerful flow
control mechanism through which processes can limit the incoming flow
-of messages. If we implement a ``link_flow()`` method on our sender's
+of messages. If we implement a ``on_link_flow()`` method on our sender's
handler, this will be called whenever the sender is allowed to send
and will prevent messages building up due to the receivers inability
to process them.
@@ -192,8 +192,8 @@ receive our responses.
We need to use the address allocated by the broker as the reply_to
address of our requests. To be notified when the broker has sent us
-back the address to use, we add an ``opened()`` method to our
-receiver's handler, and use that as the trigger to send our first
+back the address to use, we add an ``on_link_remote_open()`` method to
+our receiver's handler, and use that as the trigger to send our first
request.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org