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:26:01 UTC

svn commit: r1617486 - in /qpid/proton/branches/examples/tutorial: helloworld.py tutorial.rst

Author: gsim
Date: Tue Aug 12 14:26:01 2014
New Revision: 1617486

URL: http://svn.apache.org/r1617486
Log:
Update the first example to show sender created only once receiver is ready and describe why/where this may be a good idea

Modified:
    qpid/proton/branches/examples/tutorial/helloworld.py
    qpid/proton/branches/examples/tutorial/tutorial.rst

Modified: qpid/proton/branches/examples/tutorial/helloworld.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/helloworld.py?rev=1617486&r1=1617485&r2=1617486&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/helloworld.py (original)
+++ qpid/proton/branches/examples/tutorial/helloworld.py Tue Aug 12 14:26:01 2014
@@ -39,7 +39,10 @@ class HelloWorld(object):
 
     def on_connection_remote_open(self, event):
         self.conn.receiver(self.address, handler=HelloWorldReceiver())
-        self.conn.sender(self.address, handler=HelloWorldSender())
+
+    def on_link_remote_open(self, event):
+        if event.link.is_receiver:
+            self.conn.sender(self.address, handler=HelloWorldSender())
 
     def on_link_remote_close(self, event):
         self.closed(event.link.remote_condition)

Modified: qpid/proton/branches/examples/tutorial/tutorial.rst
URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/tutorial/tutorial.rst?rev=1617486&r1=1617485&r2=1617486&view=diff
==============================================================================
--- qpid/proton/branches/examples/tutorial/tutorial.rst (original)
+++ qpid/proton/branches/examples/tutorial/tutorial.rst Tue Aug 12 14:26:01 2014
@@ -54,10 +54,14 @@ connection).
 
 To be notified of this we pass a reference to self as the handler in
 ``connect()`` and define an ``on_connection_remote_open()`` method
-within which we can create our receiver and sender using the
-connection context we obtained from the earlier ``connect()`` call,
-and passing the handler implementations defined by
-``HelloWorldReceiver`` and ``HelloWorldSender`` respectively.
+within which we can create our receiver using the connection context
+we obtained from the earlier ``connect()`` call, and passing the
+handler implementation defined by ``HelloWorldReceiver``. When the
+remote peer confirms the establishment of that receiver we get a
+callback on ``on_link_remote_open()`` and that is where we then create
+our sender, passing it the ``HelloWorldSender`` handler. Delaying the
+creation of the sender until the receiver is established avoids losing
+messages even when these are not queued up by the remote peer.
 
 We'll add definitions to ``HelloWorld`` of ``on_link_remote_close()``
 and ``on_connection_remote_close()`` also, so that we can be notified



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org