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 2015/02/16 20:20:37 UTC

[9/9] qpid-proton git commit: Restructure the examples and install them all

Restructure the examples and install them all


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/913a6fb6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/913a6fb6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/913a6fb6

Branch: refs/heads/master
Commit: 913a6fb6bd4405d1ee758b1255950b70e7a80cae
Parents: cb5023d
Author: Gordon Sim <gs...@redhat.com>
Authored: Mon Feb 16 17:15:08 2015 +0000
Committer: Gordon Sim <gs...@redhat.com>
Committed: Mon Feb 16 17:15:08 2015 +0000

----------------------------------------------------------------------
 CMakeLists.txt                                  |   24 +-
 examples/CMakeLists.txt                         |    2 +-
 examples/README.txt                             |    7 -
 examples/c/messenger/CMakeLists.txt             |   32 +
 examples/c/messenger/recv-async.c               |  193 +++
 examples/c/messenger/recv.c                     |  154 ++
 examples/c/messenger/send-async.c               |  170 ++
 examples/c/messenger/send.c                     |  111 ++
 examples/engine/py/README                       |  155 --
 examples/engine/py/abstract_server.py           |   35 -
 examples/engine/py/client.py                    |   64 -
 examples/engine/py/client_http.py               |  113 --
 examples/engine/py/common.py                    |  697 --------
 examples/engine/py/db_common.py                 |  114 --
 examples/engine/py/db_ctrl.py                   |   46 -
 examples/engine/py/db_recv.py                   |   79 -
 examples/engine/py/db_send.py                   |  104 --
 examples/engine/py/helloworld.py                |   44 -
 examples/engine/py/helloworld_blocking.py       |   35 -
 examples/engine/py/helloworld_direct.py         |   47 -
 examples/engine/py/helloworld_direct_tornado.py |   47 -
 examples/engine/py/helloworld_tornado.py        |   44 -
 examples/engine/py/proton_server.py             |   61 -
 examples/engine/py/proton_tornado.py            |  114 --
 examples/engine/py/recurring_timer.py           |   42 -
 examples/engine/py/recurring_timer_tornado.py   |   44 -
 examples/engine/py/selected_recv.py             |   40 -
 examples/engine/py/server.py                    |   56 -
 examples/engine/py/server_direct.py             |   58 -
 examples/engine/py/server_tx.py                 |   77 -
 examples/engine/py/simple_recv.py               |   54 -
 examples/engine/py/simple_send.py               |   62 -
 examples/engine/py/sync_client.py               |   88 -
 examples/engine/py/test_examples.py             |  109 --
 examples/engine/py/tx_recv.py                   |   79 -
 examples/engine/py/tx_recv_interactive.py       |   83 -
 examples/engine/py/tx_send.py                   |   87 -
 examples/java/messenger/README.txt              |   22 +
 examples/java/messenger/pom.xml                 |   41 +
 examples/java/messenger/recv                    |   12 +
 examples/java/messenger/send                    |   10 +
 .../org/apache/qpid/proton/example/Recv.java    |  131 ++
 .../org/apache/qpid/proton/example/Send.java    |  102 ++
 examples/javascript/messenger/client.js         |  103 ++
 examples/javascript/messenger/drain.js          |   70 +
 examples/javascript/messenger/proxy.js          |  105 ++
 examples/javascript/messenger/qpid-config.js    | 1511 ++++++++++++++++++
 examples/javascript/messenger/recv.js           |   69 +
 examples/javascript/messenger/send.html         |  122 ++
 examples/javascript/messenger/send.js           |  105 ++
 examples/javascript/messenger/server.js         |   81 +
 examples/javascript/messenger/spout.js          |   71 +
 examples/javascript/messenger/ws2tcp.js         |  166 ++
 examples/messenger/c/CMakeLists.txt             |   32 -
 examples/messenger/c/recv-async.c               |  193 ---
 examples/messenger/c/recv.c                     |  154 --
 examples/messenger/c/send-async.c               |  170 --
 examples/messenger/c/send.c                     |  111 --
 examples/messenger/java/README.txt              |   22 -
 examples/messenger/java/pom.xml                 |   41 -
 examples/messenger/java/recv                    |   12 -
 examples/messenger/java/send                    |   10 -
 .../org/apache/qpid/proton/example/Recv.java    |  131 --
 .../org/apache/qpid/proton/example/Send.java    |  102 --
 examples/messenger/javascript/client.js         |  103 --
 examples/messenger/javascript/drain.js          |   70 -
 examples/messenger/javascript/proxy.js          |  105 --
 examples/messenger/javascript/qpid-config.js    | 1511 ------------------
 examples/messenger/javascript/recv.js           |   69 -
 examples/messenger/javascript/send.html         |  122 --
 examples/messenger/javascript/send.js           |  105 --
 examples/messenger/javascript/server.js         |   81 -
 examples/messenger/javascript/spout.js          |   71 -
 examples/messenger/javascript/ws2tcp.js         |  166 --
 examples/messenger/perl/async.pm                |  120 --
 examples/messenger/perl/client.pl               |  105 --
 examples/messenger/perl/recv.pl                 |   99 --
 examples/messenger/perl/recv_async.pl           |   84 -
 examples/messenger/perl/send.pl                 |   88 -
 examples/messenger/perl/send_async.pl           |   97 --
 examples/messenger/perl/server.pl               |  123 --
 examples/messenger/php/recv.php                 |   49 -
 examples/messenger/php/send.php                 |   41 -
 examples/messenger/py/README.txt                |   20 -
 examples/messenger/py/async.py                  |   81 -
 examples/messenger/py/client.py                 |   55 -
 examples/messenger/py/recv.py                   |   54 -
 examples/messenger/py/recv_async.py             |   55 -
 examples/messenger/py/send.py                   |   44 -
 examples/messenger/py/send_async.py             |   63 -
 examples/messenger/py/server.py                 |   61 -
 examples/messenger/ruby/client.rb               |   92 --
 examples/messenger/ruby/mailserver.rb           |   85 -
 examples/messenger/ruby/passive_recv.rb         |  140 --
 examples/messenger/ruby/recv.rb                 |   82 -
 examples/messenger/ruby/send.rb                 |   74 -
 examples/perl/messenger/async.pm                |  120 ++
 examples/perl/messenger/client.pl               |  105 ++
 examples/perl/messenger/recv.pl                 |   99 ++
 examples/perl/messenger/recv_async.pl           |   84 +
 examples/perl/messenger/send.pl                 |   88 +
 examples/perl/messenger/send_async.pl           |   97 ++
 examples/perl/messenger/server.pl               |  123 ++
 examples/php/messenger/recv.php                 |   49 +
 examples/php/messenger/send.php                 |   41 +
 examples/python/README                          |  155 ++
 examples/python/abstract_server.py              |   35 +
 examples/python/client.py                       |   64 +
 examples/python/client_http.py                  |  113 ++
 examples/python/common.py                       |  697 ++++++++
 examples/python/db_common.py                    |  114 ++
 examples/python/db_ctrl.py                      |   46 +
 examples/python/db_recv.py                      |   79 +
 examples/python/db_send.py                      |  104 ++
 examples/python/helloworld.py                   |   44 +
 examples/python/helloworld_blocking.py          |   35 +
 examples/python/helloworld_direct.py            |   47 +
 examples/python/helloworld_direct_tornado.py    |   47 +
 examples/python/helloworld_tornado.py           |   44 +
 examples/python/messenger/README.txt            |   20 +
 examples/python/messenger/async.py              |   81 +
 examples/python/messenger/client.py             |   55 +
 examples/python/messenger/recv.py               |   54 +
 examples/python/messenger/recv_async.py         |   55 +
 examples/python/messenger/send.py               |   44 +
 examples/python/messenger/send_async.py         |   63 +
 examples/python/messenger/server.py             |   61 +
 examples/python/proton_server.py                |   61 +
 examples/python/proton_tornado.py               |  114 ++
 examples/python/reactor/README.md               |   34 +
 examples/python/reactor/cat.py                  |   56 +
 examples/python/reactor/count-randomly.py       |   77 +
 examples/python/reactor/counter.py              |   60 +
 examples/python/reactor/delegates.py            |   48 +
 examples/python/reactor/echo.py                 |   61 +
 examples/python/reactor/global-logger.py        |   58 +
 examples/python/reactor/goodbye-world.py        |   46 +
 examples/python/reactor/handlers.py             |   48 +
 examples/python/reactor/hello-world.py          |   42 +
 examples/python/reactor/reactor-logger.py       |   54 +
 examples/python/reactor/recv.py                 |   48 +
 examples/python/reactor/scheduling.py           |   51 +
 examples/python/reactor/send.py                 |   87 +
 examples/python/reactor/tornado-hello-world.py  |   41 +
 examples/python/reactor/tornado-send.py         |   82 +
 examples/python/reactor/tornado_app.py          |   93 ++
 examples/python/reactor/unhandled.py            |   34 +
 examples/python/recurring_timer.py              |   42 +
 examples/python/recurring_timer_tornado.py      |   44 +
 examples/python/selected_recv.py                |   40 +
 examples/python/server.py                       |   56 +
 examples/python/server_direct.py                |   58 +
 examples/python/server_tx.py                    |   77 +
 examples/python/simple_recv.py                  |   54 +
 examples/python/simple_send.py                  |   62 +
 examples/python/sync_client.py                  |   88 +
 examples/python/test_examples.py                |  109 ++
 examples/python/tx_recv.py                      |   79 +
 examples/python/tx_recv_interactive.py          |   83 +
 examples/python/tx_send.py                      |   87 +
 examples/reactor/py/README.md                   |   34 -
 examples/reactor/py/cat.py                      |   56 -
 examples/reactor/py/count-randomly.py           |   77 -
 examples/reactor/py/counter.py                  |   60 -
 examples/reactor/py/delegates.py                |   48 -
 examples/reactor/py/echo.py                     |   61 -
 examples/reactor/py/global-logger.py            |   58 -
 examples/reactor/py/goodbye-world.py            |   46 -
 examples/reactor/py/handlers.py                 |   48 -
 examples/reactor/py/hello-world.py              |   42 -
 examples/reactor/py/reactor-logger.py           |   54 -
 examples/reactor/py/recv.py                     |   48 -
 examples/reactor/py/scheduling.py               |   51 -
 examples/reactor/py/send.py                     |   87 -
 examples/reactor/py/tornado-hello-world.py      |   41 -
 examples/reactor/py/tornado-send.py             |   82 -
 examples/reactor/py/tornado_app.py              |   93 --
 examples/reactor/py/unhandled.py                |   34 -
 examples/ruby/messenger/client.rb               |   92 ++
 examples/ruby/messenger/mailserver.rb           |   85 +
 examples/ruby/messenger/passive_recv.rb         |  140 ++
 examples/ruby/messenger/recv.rb                 |   82 +
 examples/ruby/messenger/send.rb                 |   74 +
 pom.xml                                         |    2 +-
 184 files changed, 8795 insertions(+), 8822 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 38c8f17..ae5f7cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,14 +98,6 @@ foreach (LANG ${BINDING_LANGS})
   endif ()
 endforeach()
 
-if (WIN32)
-  set (EXAMPLES_INSTALL_DIR proton/examples)
-endif (WIN32)
-
-if (UNIX)
-  set (EXAMPLES_INSTALL_DIR ${SHARE_INSTALL_DIR}/proton/examples)
-endif (UNIX)
-
 set (PROTON_SHARE ${SHARE_INSTALL_DIR}/proton-${PN_VERSION})
 # End of variables used during install
 
@@ -134,20 +126,8 @@ add_subdirectory(proton-c)
 install (FILES LICENSE README TODO
          DESTINATION ${PROTON_SHARE})
 
-# install the C messenger example
-install (FILES examples/messenger/c/CMakeLists.txt
-               examples/messenger/c/send.c
-               examples/messenger/c/recv.c
-         DESTINATION ${EXAMPLES_INSTALL_DIR}/messenger)
-
-install (FILES examples/include/pncompat/misc_defs.h
-               examples/include/pncompat/misc_funcs.inc
-         DESTINATION ${EXAMPLES_INSTALL_DIR}/messenger/pncompat)
-
-install (FILES examples/include/pncompat/internal/LICENSE
-               examples/include/pncompat/internal/getopt.c
-               examples/include/pncompat/internal/getopt.h
-         DESTINATION ${EXAMPLES_INSTALL_DIR}/messenger/pncompat/internal)
+install (DIRECTORY examples
+         DESTINATION ${PROTON_SHARE})
 
 # add relevant CTest support
 find_program (MAVEN_EXE mvn DOC "Location of the maven program")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 7b01b00..feac758 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -20,4 +20,4 @@
 set (Proton_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-add_subdirectory(messenger/c)
+add_subdirectory(c/messenger)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/README.txt
----------------------------------------------------------------------
diff --git a/examples/README.txt b/examples/README.txt
deleted file mode 100644
index d95a37a..0000000
--- a/examples/README.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-This directory contains example applications that use the Proton library.
-
-  messenger/ - simple examples using the messenger API in a variety of
-               languages (C, perl, php, python, ruby)
-
-  engine/    - examples using the engine API to build a messaging server and
-               clients

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/c/messenger/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/c/messenger/CMakeLists.txt b/examples/c/messenger/CMakeLists.txt
new file mode 100644
index 0000000..1b32d0c
--- /dev/null
+++ b/examples/c/messenger/CMakeLists.txt
@@ -0,0 +1,32 @@
+#
+# 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.
+#
+
+find_package(Proton REQUIRED)
+
+add_executable(recv recv.c)
+add_executable(send send.c)
+add_executable(recv-async recv-async.c)
+add_executable(send-async send-async.c)
+
+include_directories(${Proton_INCLUDE_DIRS})
+
+target_link_libraries(recv ${Proton_LIBRARIES})
+target_link_libraries(send ${Proton_LIBRARIES})
+target_link_libraries(recv-async ${Proton_LIBRARIES})
+target_link_libraries(send-async ${Proton_LIBRARIES})

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/c/messenger/recv-async.c
----------------------------------------------------------------------
diff --git a/examples/c/messenger/recv-async.c b/examples/c/messenger/recv-async.c
new file mode 100644
index 0000000..1f49166
--- /dev/null
+++ b/examples/c/messenger/recv-async.c
@@ -0,0 +1,193 @@
+/*
+ * 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.
+ *
+ */
+
+// This is a re-implementation of recv.c using non-blocking/asynchronous calls.
+
+#include "proton/message.h"
+#include "proton/messenger.h"
+
+#include "pncompat/misc_funcs.inc"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#if EMSCRIPTEN
+#include <emscripten.h>
+#endif
+
+pn_message_t * message;
+pn_messenger_t * messenger;
+
+#define check(messenger)                                                     \
+  {                                                                          \
+    if(pn_messenger_errno(messenger))                                        \
+    {                                                                        \
+      die(__FILE__, __LINE__, pn_error_text(pn_messenger_error(messenger))); \
+    }                                                                        \
+  }                                                                          \
+
+void die(const char *file, int line, const char *message)
+{
+    fprintf(stderr, "%s:%i: %s\n", file, line, message);
+    exit(1);
+}
+
+void usage(void)
+{
+    printf("Usage: recv [options] <addr>\n");
+    printf("-c    \tPath to the certificate file.\n");
+    printf("-k    \tPath to the private key file.\n");
+    printf("-p    \tPassword for the private key.\n");
+    printf("<addr>\tAn address.\n");
+    exit(0);
+}
+
+void process(void) {
+    while(pn_messenger_incoming(messenger))
+    {
+        pn_messenger_get(messenger, message);
+        check(messenger);
+
+        {
+        pn_tracker_t tracker = pn_messenger_incoming_tracker(messenger);
+        char buffer[1024];
+        size_t buffsize = sizeof(buffer);
+        const char* subject = pn_message_get_subject(message);
+        pn_data_t* body = pn_message_body(message);
+        pn_data_format(body, buffer, &buffsize);
+
+        printf("Address: %s\n", pn_message_get_address(message));
+        printf("Subject: %s\n", subject ? subject : "(no subject)");
+        printf("Content: %s\n", buffer);
+
+        pn_messenger_accept(messenger, tracker, 0);
+        }
+    }
+}
+
+#if EMSCRIPTEN // For emscripten C/C++ to JavaScript compiler.
+void pump(int fd, void* userData) {
+    while (pn_messenger_work(messenger, 0) >= 0) {
+        process();
+    }
+}
+
+void onclose(int fd, void* userData) {
+    process();
+}
+
+void onerror(int fd, int errno, const char* msg, void* userData) {
+    printf("error callback fd = %d, errno = %d, msg = %s\n", fd, errno, msg);
+}
+#endif
+
+int main(int argc, char** argv)
+{
+    char* certificate = NULL;
+    char* privatekey = NULL;
+    char* password = NULL;
+    char* address = (char *) "amqp://~0.0.0.0";
+    int c;
+
+    message = pn_message();
+    messenger = pn_messenger(NULL);
+    pn_messenger_set_blocking(messenger, false); // Needs to be set non-blocking to behave asynchronously.
+
+    opterr = 0;
+
+    while((c = getopt(argc, argv, "hc:k:p:")) != -1)
+    {
+        switch(c)
+        {
+            case 'h':
+                usage();
+                break;
+
+            case 'c': certificate = optarg; break;
+            case 'k': privatekey = optarg; break;
+            case 'p': password = optarg; break;
+
+            case '?':
+                if (optopt == 'c' ||
+                    optopt == 'k' ||
+                    optopt == 'p')
+                {
+                    fprintf(stderr, "Option -%c requires an argument.\n", optopt);
+                }
+                else if(isprint(optopt))
+                {
+                    fprintf(stderr, "Unknown option `-%c'.\n", optopt);
+                }
+                else
+                {
+                    fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
+                }
+                return 1;
+            default:
+                abort();
+        }
+    }
+
+    if (optind < argc)
+    {
+        address = argv[optind];
+    }
+
+    /* load the various command line options if they're set */
+    if(certificate)
+    {
+        pn_messenger_set_certificate(messenger, certificate);
+    }
+
+    if(privatekey)
+    {
+        pn_messenger_set_private_key(messenger, privatekey);
+    }
+
+    if(password)
+    {
+        pn_messenger_set_password(messenger, password);
+    }
+
+    pn_messenger_start(messenger);
+    check(messenger);
+
+    pn_messenger_subscribe(messenger, address);
+    check(messenger);
+
+    pn_messenger_recv(messenger, -1); // Set to receive as many messages as messenger can buffer.
+
+#if EMSCRIPTEN // For emscripten C/C++ to JavaScript compiler.
+    emscripten_set_socket_error_callback(NULL, onerror);
+
+    emscripten_set_socket_open_callback(NULL, pump);
+    emscripten_set_socket_connection_callback(NULL, pump);
+    emscripten_set_socket_message_callback(NULL, pump);
+    emscripten_set_socket_close_callback(NULL, onclose);
+#else // For native compiler.
+    while (1) {
+        pn_messenger_work(messenger, -1); // Block indefinitely until there has been socket activity.
+        process();
+    }
+#endif
+
+    return 0;
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/c/messenger/recv.c
----------------------------------------------------------------------
diff --git a/examples/c/messenger/recv.c b/examples/c/messenger/recv.c
new file mode 100644
index 0000000..16e8321
--- /dev/null
+++ b/examples/c/messenger/recv.c
@@ -0,0 +1,154 @@
+/*
+ * 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/message.h"
+#include "proton/messenger.h"
+
+#include "pncompat/misc_funcs.inc"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#define check(messenger)                                                     \
+  {                                                                          \
+    if(pn_messenger_errno(messenger))                                        \
+    {                                                                        \
+      die(__FILE__, __LINE__, pn_error_text(pn_messenger_error(messenger))); \
+    }                                                                        \
+  }                                                                          \
+
+void die(const char *file, int line, const char *message)
+{
+  fprintf(stderr, "%s:%i: %s\n", file, line, message);
+  exit(1);
+}
+
+void usage(void)
+{
+  printf("Usage: recv [options] <addr>\n");
+  printf("-c    \tPath to the certificate file.\n");
+  printf("-k    \tPath to the private key file.\n");
+  printf("-p    \tPassword for the private key.\n");
+  printf("<addr>\tAn address.\n");
+  exit(0);
+}
+
+int main(int argc, char** argv)
+{
+  char* certificate = NULL;
+  char* privatekey = NULL;
+  char* password = NULL;
+  char* address = (char *) "amqp://~0.0.0.0";
+  int c;
+
+  pn_message_t * message;
+  pn_messenger_t * messenger;
+
+  message = pn_message();
+  messenger = pn_messenger(NULL);
+
+  opterr = 0;
+
+  while((c = getopt(argc, argv, "hc:k:p:")) != -1)
+  {
+    switch(c)
+    {
+    case 'h':
+      usage();
+      break;
+
+    case 'c': certificate = optarg; break;
+    case 'k': privatekey = optarg; break;
+    case 'p': password = optarg; break;
+
+    case '?':
+      if(optopt == 'c' ||
+         optopt == 'k' ||
+         optopt == 'p')
+      {
+        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
+      }
+      else if(isprint(optopt))
+      {
+        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
+      }
+      else
+      {
+        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
+      }
+      return 1;
+    default:
+      abort();
+    }
+  }
+
+  if (optind < argc)
+  {
+    address = argv[optind];
+  }
+
+  /* load the various command line options if they're set */
+  if(certificate)
+  {
+    pn_messenger_set_certificate(messenger, certificate);
+  }
+
+  if(privatekey)
+  {
+    pn_messenger_set_private_key(messenger, privatekey);
+  }
+
+  if(password)
+  {
+    pn_messenger_set_password(messenger, password);
+  }
+
+  pn_messenger_start(messenger);
+  check(messenger);
+
+  pn_messenger_subscribe(messenger, address);
+  check(messenger);
+
+  for(;;)
+  {
+    pn_messenger_recv(messenger, 1024);
+    check(messenger);
+
+    while(pn_messenger_incoming(messenger))
+    {
+      pn_messenger_get(messenger, message);
+      check(messenger);
+
+      {
+      char buffer[1024];
+      size_t buffsize = sizeof(buffer);
+      const char* subject = pn_message_get_subject(message);
+      pn_data_t *body = pn_message_body(message);
+      pn_data_format(body, buffer, &buffsize);
+
+      printf("Address: %s\n", pn_message_get_address(message));
+      printf("Subject: %s\n", subject ? subject : "(no subject)");
+      printf("Content: %s\n", buffer);
+      }
+    }
+  }
+
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/c/messenger/send-async.c
----------------------------------------------------------------------
diff --git a/examples/c/messenger/send-async.c b/examples/c/messenger/send-async.c
new file mode 100644
index 0000000..de9b023
--- /dev/null
+++ b/examples/c/messenger/send-async.c
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ *
+ */
+
+// This is a re-implementation of send.c using non-blocking/asynchronous calls.
+
+#include "proton/message.h"
+#include "proton/messenger.h"
+
+#include "pncompat/misc_funcs.inc"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#if EMSCRIPTEN
+#include <emscripten.h>
+#endif
+
+pn_message_t * message;
+pn_messenger_t * messenger;
+pn_tracker_t tracker;
+int running = 1;
+
+#define check(messenger)                                                     \
+  {                                                                          \
+    if(pn_messenger_errno(messenger))                                        \
+    {                                                                        \
+      die(__FILE__, __LINE__, pn_error_text(pn_messenger_error(messenger))); \
+    }                                                                        \
+  }                                                                          \
+
+void die(const char *file, int line, const char *message)
+{
+    fprintf(stderr, "%s:%i: %s\n", file, line, message);
+    exit(1);
+}
+
+void usage(void)
+{
+    printf("Usage: send [-a addr] [message]\n");
+    printf("-a     \tThe target address [amqp[s]://domain[/name]]\n");
+    printf("message\tA text string to send.\n");
+    exit(0);
+}
+
+void process(void) {
+    pn_status_t status = pn_messenger_status(messenger, tracker);
+    if (status != PN_STATUS_PENDING) {
+        if (running) {
+            pn_messenger_stop(messenger);
+            running = 0;
+        } 
+    }
+
+    if (pn_messenger_stopped(messenger)) {
+        pn_message_free(message);
+        pn_messenger_free(messenger);
+        message = NULL;
+        messenger = NULL;
+    }
+}
+
+#if EMSCRIPTEN // For emscripten C/C++ to JavaScript compiler.
+void pump(int fd, void* userData) {
+    while (pn_messenger_work(messenger, 0) >= 0) {
+        process();
+    }
+}
+
+void onclose(int fd, void* userData) {
+    process();
+}
+
+void onerror(int fd, int errno, const char* msg, void* userData) {
+    printf("error callback fd = %d, errno = %d, msg = %s\n", fd, errno, msg);
+}
+#endif
+
+int main(int argc, char** argv)
+{
+    int c;
+    char * address = (char *) "amqp://0.0.0.0";
+    char * msgtext = (char *) "Hello World!";
+    pn_data_t* body;
+
+    opterr = 0;
+
+    while((c = getopt(argc, argv, "ha:b:c:")) != -1)
+    {
+        switch(c)
+        {
+            case 'a': address = optarg; break;
+            case 'h': usage(); break;
+
+            case '?':
+                if(optopt == 'a')
+                {
+                    fprintf(stderr, "Option -%c requires an argument.\n", optopt);
+                }
+                else if(isprint(optopt))
+                {
+                    fprintf(stderr, "Unknown option `-%c'.\n", optopt);
+                }
+                else
+                {
+                    fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
+                }
+                return 1;
+            default:
+                abort();
+        }
+    }
+
+    if (optind < argc) msgtext = argv[optind];
+
+    message = pn_message();
+    messenger = pn_messenger(NULL);
+    pn_messenger_set_blocking(messenger, false); // Needs to be set non-blocking to behave asynchronously.
+    pn_messenger_set_outgoing_window(messenger, 1024); 
+
+    pn_messenger_start(messenger);
+
+    pn_message_set_address(message, address);
+    body = pn_message_body(message);
+    pn_data_put_string(body, pn_bytes(strlen(msgtext), msgtext));
+
+    pn_messenger_put(messenger, message);
+    check(messenger);
+
+    tracker = pn_messenger_outgoing_tracker(messenger);
+
+#if EMSCRIPTEN // For emscripten C/C++ to JavaScript compiler.
+    emscripten_set_socket_error_callback(NULL, onerror);
+
+    emscripten_set_socket_open_callback(NULL, pump);
+    emscripten_set_socket_connection_callback(NULL, pump);
+    emscripten_set_socket_message_callback(NULL, pump);
+    emscripten_set_socket_close_callback(NULL, onclose);
+#else // For native compiler.
+    while (running) {
+        pn_messenger_work(messenger, -1); // Block indefinitely until there has been socket activity.
+        process();
+    }
+
+    while (messenger && !pn_messenger_stopped(messenger)) {
+        pn_messenger_work(messenger, 0);
+        process();
+    }
+#endif
+
+    return 0;
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/c/messenger/send.c
----------------------------------------------------------------------
diff --git a/examples/c/messenger/send.c b/examples/c/messenger/send.c
new file mode 100644
index 0000000..11b47ff
--- /dev/null
+++ b/examples/c/messenger/send.c
@@ -0,0 +1,111 @@
+/*
+ * 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/message.h"
+#include "proton/messenger.h"
+
+#include "pncompat/misc_funcs.inc"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#define check(messenger)                                                     \
+  {                                                                          \
+    if(pn_messenger_errno(messenger))                                        \
+    {                                                                        \
+      die(__FILE__, __LINE__, pn_error_text(pn_messenger_error(messenger))); \
+    }                                                                        \
+  }                                                                          \
+
+void die(const char *file, int line, const char *message)
+{
+  fprintf(stderr, "%s:%i: %s\n", file, line, message);
+  exit(1);
+}
+
+void usage(void)
+{
+  printf("Usage: send [-a addr] [message]\n");
+  printf("-a     \tThe target address [amqp[s]://domain[/name]]\n");
+  printf("message\tA text string to send.\n");
+  exit(0);
+}
+
+int main(int argc, char** argv)
+{
+  int c;
+  char * address = (char *) "amqp://0.0.0.0";
+  char * msgtext = (char *) "Hello World!";
+  opterr = 0;
+
+  while((c = getopt(argc, argv, "ha:b:c:")) != -1)
+  {
+    switch(c)
+    {
+    case 'a': address = optarg; break;
+    case 'h': usage(); break;
+
+    case '?':
+      if(optopt == 'a')
+      {
+        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
+      }
+      else if(isprint(optopt))
+      {
+        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
+      }
+      else
+      {
+        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
+      }
+      return 1;
+    default:
+      abort();
+    }
+  }
+
+  if (optind < argc) msgtext = argv[optind];
+
+  {
+  pn_message_t * message;
+  pn_messenger_t * messenger;
+  pn_data_t * body;
+
+  message = pn_message();
+  messenger = pn_messenger(NULL);
+
+  pn_messenger_start(messenger);
+
+  pn_message_set_address(message, address);
+  body = pn_message_body(message);
+  pn_data_put_string(body, pn_bytes(strlen(msgtext), msgtext));
+  pn_messenger_put(messenger, message);
+  check(messenger);
+  pn_messenger_send(messenger, -1);
+  check(messenger);
+
+  pn_messenger_stop(messenger);
+  pn_messenger_free(messenger);
+  pn_message_free(message);
+  }
+
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/README
----------------------------------------------------------------------
diff --git a/examples/engine/py/README b/examples/engine/py/README
deleted file mode 100644
index a361fc4..0000000
--- a/examples/engine/py/README
+++ /dev/null
@@ -1,155 +0,0 @@
-Most (though not all) of the current examples require a broker or
-similar intermediary that supports the AMQP 1.0 protocol, allows
-anonymous connections and accepts links to and from a node named
-'examples'.
-
-------------------------------------------------------------------
-
-helloworld.py
-
-Basic example that connects to an intermediary on localhost:5672,
-establishes a subscription from the 'examples' node on that
-intermediary, then creates a sending link to the same node and sends
-one message. On receving the message back via the subcription, the
-connection is closed.
-
-helloworld_blocking.py
-
-The same as the basic helloworld.py, but using a
-synchronous/sequential style wrapper on top of the
-asynchronous/reactive API. The purpose of this example is just to show
-how different functionality can be easily layered should it be
-desired.
-
-helloworld_direct.py
-
-A variant of the basic hellpwprld example, that does not use an
-intermediary, but listens for incoming connections itself. It
-establishes a connection to itself with a link over which a single
-message is sent. This demonstrates the ease with which a simple daemon
-can be built using the API.
-
-helloworld_tornado.py
-helloworld_direct_tornado.py
-
-These are variant of the helloworld.py and helloworld_direct.py
-examples that use the event loop from the tornado library, rather than
-that provided within proton itself and demonstrate how proton can be
-used with external loops.
-
--------------------------------------------------------------------
-
-simple_send.py
-
-An example of sending a fixed number of messages and tracking their
-(asynchronous) acknowledgement. Handles disconnection while
-maintaining an at-least-once guarantee (there may be duplicates, but
-no message in the sequence should be lost). Messages are sent through
-the 'examples' node on an intermediary accessible on port 5672 on
-localhost.
-
-simple_recv.py
-
-Subscribes to the 'examples' node on an intermediary accessible on port 5672 on
-localhost. Simply prints out the body of received messages.
-
-db_send.py
-
-A more realistic sending example, where the messages come from records
-in a simple database table. On being acknowledged the records can be
-deleted from the table. The database access is done in a separate
-thread, so as not to block the event thread during data
-access. Messages are sent through the 'examples' node on an
-intermediary accessible on port 5672 on localhost.
-
-db_recv.py
-
-A receiving example that records messages received from the 'examples'
-node on localhost:5672 in a database table and only acknowledges them
-when the insert completes. Database access is again done in a separate
-thread from the event loop.
-
-db_ctrl.py
-
-A utility for setting up the database tables for the two examples
-above. Takes two arguments, the action to perform and the name of the
-database on which to perfom it. The database used by db_send.py is
-src_db, that by db_recv.py is dst_db. The valid actions are 'init',
-which creates the table, 'list' which displays the contents and
-'insert' which inserts records from standard-in and is used to
-populate src_db, e.g. for i in `seq 1 50`; do echo "Message-$i"; done
-| ./db_ctrl.py insert src_db.
-
-tx_send.py
-
-A sender that sends messages in atomic batches using local
-transactions (this example does not persist the messages in anyway).
-
-tx_send_sync.py
-
-A variant of the former example that waits for all messages in a batch
-to be acknowledged before committing. Used only to work around an
-ordering issue in preoton that affected qpidd.
-
-tx_recv.py
-
-A receiver example that accepts batches of messages using local
-transactions.
-
-tx_recv_interactive.py
-
-A testing utility that allow interactive control of the
-transactions. Actions are keyed in to the console, 'fetch' will
-request another message, 'abort' will abort the transaction, 'commit'
-will commit it.
-
-The various send/recv examples can be mixed and matched if desired.
-
--------------------------------------------------------------------
-
-client.py
-
-The client part of a request-response example. Sends requests and
-prints out responses. Requires an intermediary that support the AMQP
-1.0 dynamic nodes on which the responses are received. The requests
-are sent through the 'examples' node.
-
-server.py
-
-The server part of a request-response example, that receives requests
-via the examples node, converts the body to uppercase and sends the
-result back to the indicated reply address.
-
-sync_client.py
-
-A variant of the client part, that uses a blocking/synchronous style
-instead of the reactive/asynchronous style.
-
-client_http.py
-
-A variant of the client part that takes the input to be submitted in
-the request over HTTP (point your browser to localhost:8888/client)
-
-server_tx.py
-
-A variant of the server part that consumes the request and sends out
-the response atomically in a local transaction.
-
--------------------------------------------------------------------
-
-selected_recv.py
-
-An example that uses a selector filter.
-
--------------------------------------------------------------------
-
-recurring_timer.py
-
-An example showing a simple timer event.
-
-recurring_timer_tornado.py
-
-A variant of the above that uses the tornado eventloop instead.
-
--------------------------------------------------------------------
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/abstract_server.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/abstract_server.py b/examples/engine/py/abstract_server.py
deleted file mode 100755
index 2d0de32..0000000
--- a/examples/engine/py/abstract_server.py
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env 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 proton_server import Server
-
-class Application(Server):
-    def __init__(self, host, address):
-        super(Application, self).__init__(host, address)
-
-    def on_request(self, request, reply_to):
-        response = request.upper()
-        self.send(response, reply_to)
-        print "Request from: %s" % reply_to
-
-try:
-    Application("localhost:5672", "examples").run()
-except KeyboardInterrupt: pass
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/client.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/client.py b/examples/engine/py/client.py
deleted file mode 100755
index a116175..0000000
--- a/examples/engine/py/client.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env 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.
-#
-
-import optparse
-from proton import Message
-from proton.handlers import MessagingHandler
-from proton.reactor import Container, DynamicNodeProperties
-
-class Client(MessagingHandler):
-    def __init__(self, url, requests):
-        super(Client, self).__init__()
-        self.url = url
-        self.requests = requests
-
-    def on_start(self, event):
-        self.sender = event.container.create_sender(self.url)
-        self.receiver = event.container.create_receiver(self.sender.connection, None, dynamic=True)
-
-    def next_request(self):
-        if self.receiver.remote_source.address:
-            req = Message(reply_to=self.receiver.remote_source.address, body=self.requests[0])
-            self.sender.send(req)
-
-    def on_link_opened(self, event):
-        if event.receiver == self.receiver:
-            self.next_request()
-
-    def on_message(self, event):
-        print "%s => %s" % (self.requests.pop(0), event.message.body)
-        if self.requests:
-            self.next_request()
-        else:
-            event.connection.close()
-
-REQUESTS= ["Twas brillig, and the slithy toves",
-           "Did gire and gymble in the wabe.",
-           "All mimsy were the borogroves,",
-           "And the mome raths outgrabe."]
-
-parser = optparse.OptionParser(usage="usage: %prog [options]",
-                               description="Send requests to the supplied address and print responses.")
-parser.add_option("-a", "--address", default="localhost:5672/examples",
-                  help="address to which messages are sent (default %default)")
-opts, args = parser.parse_args()
-
-Container(Client(opts.address, args or REQUESTS)).run()
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/client_http.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/client_http.py b/examples/engine/py/client_http.py
deleted file mode 100755
index cd0d63f..0000000
--- a/examples/engine/py/client_http.py
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/env 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.
-#
-
-import tornado.ioloop
-import tornado.web
-from proton import Message
-from proton.handlers import MessagingHandler
-from proton_tornado import Container
-
-class Client(MessagingHandler):
-    def __init__(self, host, address):
-        super(Client, self).__init__()
-        self.host = host
-        self.address = address
-        self.sent = []
-        self.pending = []
-        self.reply_address = None
-        self.sender = None
-        self.receiver = None
-
-    def on_start(self, event):
-        conn = event.container.connect(self.host)
-        self.sender = event.container.create_sender(conn, self.address)
-        self.receiver = event.container.create_receiver(conn, None, dynamic=True)
-
-    def on_link_opened(self, event):
-        if event.receiver == self.receiver:
-            self.reply_address = event.link.remote_source.address
-            self.do_request()
-
-    def on_sendable(self, event):
-        self.do_request()
-
-    def on_message(self, event):
-        if self.sent:
-            request, handler = self.sent.pop(0)
-            print "%s => %s" % (request, event.message.body)
-            handler(event.message.body)
-            self.do_request()
-
-    def do_request(self):
-        if self.pending and self.reply_address and self.sender.credit:
-            request, handler = self.pending.pop(0)
-            self.sent.append((request, handler))
-            req = Message(reply_to=self.reply_address, body=request)
-            self.sender.send(req)
-
-    def request(self, body, handler):
-        self.pending.append((body, handler))
-        self.do_request()
-        self.container.touch()
-
-class ExampleHandler(tornado.web.RequestHandler):
-    def initialize(self, client):
-        self.client = client
-
-    def get(self):
-        self._write_open()
-        self._write_form()
-        self._write_close()
-
-    @tornado.web.asynchronous
-    def post(self):
-        client.request(self.get_body_argument("message"), lambda x: self.on_response(x))
-
-    def on_response(self, body):
-        self.set_header("Content-Type", "text/html")
-        self._write_open()
-        self._write_form()
-        self.write("Response: " + body)
-        self._write_close()
-        self.finish()
-
-    def _write_open(self):
-        self.write('<html><body>')
-
-    def _write_close(self):
-        self.write('</body></html>')
-
-    def _write_form(self):
-        self.write('<form action="/client" method="POST">'
-                   'Request: <input type="text" name="message">'
-                   '<input type="submit" value="Submit">'
-                   '</form>')
-
-
-loop = tornado.ioloop.IOLoop.instance()
-client = Client("localhost:5672", "examples")
-client.container = Container(client, loop=loop)
-client.container.initialise()
-app = tornado.web.Application([tornado.web.url(r"/client", ExampleHandler, dict(client=client))])
-app.listen(8888)
-try:
-    loop.start()
-except KeyboardInterrupt:
-    loop.stop()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/common.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/common.py b/examples/engine/py/common.py
deleted file mode 100755
index 5d16651..0000000
--- a/examples/engine/py/common.py
+++ /dev/null
@@ -1,697 +0,0 @@
-#
-# 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.
-#
-import errno, os, random, select, time, traceback
-from proton import *
-from socket import *
-from threading import Thread
-from heapq import heappush, heappop, nsmallest
-
-class Selectable:
-
-    def __init__(self, transport, socket):
-        self.transport = transport
-        self.socket = socket
-        self.write_done = False
-        self.read_done = False
-
-    def closed(self):
-        if self.write_done and self.read_done:
-            self.socket.close()
-            return True
-        else:
-            return False
-
-    def fileno(self):
-        return self.socket.fileno()
-
-    def reading(self):
-        if self.read_done: return False
-        c = self.transport.capacity()
-        if c > 0:
-            return True
-        elif c < 0:
-            self.read_done = True
-            return False
-
-    def writing(self):
-        if self.write_done: return False
-        try:
-            p = self.transport.pending()
-            if p > 0:
-                return True
-            elif p < 0:
-                self.write_done = True
-                return False
-        except TransportException, e:
-            self.write_done = True
-            return False
-
-    def readable(self):
-        c = self.transport.capacity()
-        if c > 0:
-            try:
-                data = self.socket.recv(c)
-                if data:
-                    self.transport.push(data)
-                else:
-                    self.transport.close_tail()
-            except error, e:
-                print "read error", e
-                self.transport.close_tail()
-                self.read_done = True
-        elif c < 0:
-            self.read_done = True
-
-    def writable(self):
-        try:
-            p = self.transport.pending()
-            if p > 0:
-                data = self.transport.peek(p)
-                n = self.socket.send(data)
-                self.transport.pop(n)
-            elif p < 0:
-                self.write_done = True
-        except error, e:
-            print "write error", e
-            self.transport.close_head()
-            self.write_done = True
-
-    def tick(self, now):
-        return self.transport.tick(now)
-
-class Acceptor:
-
-    def __init__(self, driver, host, port):
-        self.driver = driver
-        self.socket = socket()
-        self.socket.setblocking(0)
-        self.socket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
-        self.socket.bind((host, port))
-        self.socket.listen(5)
-        self.driver.add(self)
-
-    def closed(self):
-        return False
-
-    def fileno(self):
-        return self.socket.fileno()
-
-    def reading(self):
-        return True
-
-    def writing(self):
-        return False
-
-    def readable(self):
-        sock, addr = self.socket.accept()
-        sock.setblocking(0)
-        print "Incoming Connection:", addr
-        if sock:
-            conn = Connection()
-            conn.collect(self.driver.collector)
-            transport = Transport(mode=Transport.SERVER)
-            transport.bind(conn)
-            sasl = transport.sasl()
-            sasl.mechanisms("ANONYMOUS")
-            sasl.done(SASL.OK)
-            sel = Selectable(transport, sock)
-            self.driver.add(sel)
-
-    def tick(self, now):
-        return None
-
-class Interrupter:
-
-    def __init__(self):
-        self.read, self.write = os.pipe()
-
-    def fileno(self):
-        return self.read
-
-    def readable(self):
-        os.read(self.read, 1024)
-
-    def interrupt(self):
-        os.write(self.write, 'x')
-
-class PQueue:
-
-    def __init__(self):
-        self.entries = []
-
-    def add(self, task, priority):
-        heappush(self.entries, (priority, task))
-
-    def peek(self):
-        if self.entries:
-            return nsmallest(1, self.entries)[0]
-        else:
-            return None
-
-    def pop(self):
-        if self.entries:
-            return heappop(self.entries)
-        else:
-            return None
-
-    def __nonzero__(self):
-        if self.entries:
-            return True
-        else:
-            return False
-
-import proton
-
-TIMER_EVENT = proton.EventType(10000, "on_timer")
-
-class Timer:
-
-    def __init__(self, collector):
-        self.collector = collector
-        self.tasks = PQueue()
-
-    def schedule(self, task, deadline):
-        self.tasks.add(task, deadline)
-
-    def tick(self, now):
-        while self.tasks:
-            deadline, task = self.tasks.peek()
-            if now > deadline:
-                self.tasks.pop()
-                self.collector.put(task, TIMER_EVENT)
-            else:
-                return deadline
-
-def _dispatch(ev, handler):
-    if ev.clazz == "pn_delivery" and ev.context.released:
-        return
-    else:
-        ev.dispatch(handler)
-
-def _expand(handlers):
-    result = []
-    for h in handlers:
-        if hasattr(h, "handlers"):
-            result.extend(h.handlers)
-        else:
-            result.append(h)
-    return result
-
-class Driver(Handler):
-
-    def __init__(self, *handlers):
-        self.collector = Collector()
-        self.handlers = _expand(handlers)
-        self.interrupter = Interrupter()
-        self.timer = Timer(self.collector)
-        self.selectables = []
-        self.now = None
-        self.deadline = None
-        self._abort = False
-        self._exit = False
-        self._thread = Thread(target=self.run)
-        self._thread.setDaemon(True)
-
-    def schedule(self, task, timeout):
-        self.timer.schedule(task, self.now + timeout)
-
-    def abort(self):
-        self._abort = True
-
-    def exit(self):
-        self._exit = True
-
-    def wakeup(self):
-        self.interrupter.interrupt()
-
-    def start(self):
-        self._thread.start()
-
-    def join(self):
-        self._thread.join()
-
-    def _init_deadline(self):
-        self.now = time.time()
-        self.deadline = None
-
-    def _update_deadline(self, t):
-        if t is None or t < self.now: return
-        if self.deadline is None or t < self.deadline:
-            self.deadline = t
-
-    @property
-    def _timeout(self):
-        if self.deadline is None:
-            return None
-        else:
-            return self.deadline - self.now
-
-    def run(self):
-        self._init_deadline()
-        for h in self.handlers:
-            dispatch(h, "on_start", self)
-
-        while True:
-            self._init_deadline()
-
-            while True:
-                self.process_events()
-                if self._abort: return
-                self._update_deadline(self.timer.tick(self.now))
-                count = self.process_events()
-                if self._abort: return
-                if not count:
-                    break
-
-            reading = [self.interrupter]
-            writing = []
-
-            for s in self.selectables[:]:
-                if s.reading(): reading.append(s)
-                if s.writing(): writing.append(s)
-                self._update_deadline(s.tick(self.now))
-                if s.closed(): self.selectables.remove(s)
-
-            if self._exit and not self.selectables: return
-
-            try:
-                readable, writable, _ = select.select(reading, writing, [], self._timeout)
-            except select.error, (err, errtext):
-                if err == errno.EINTR:
-                    continue
-                else:
-                    raise
-
-            for s in readable:
-                s.readable()
-            for s in writable:
-                s.writable()
-
-    def process_events(self):
-        count = 0
-
-        quiesced = False
-        while True:
-            ev = self.collector.peek()
-            if ev:
-                count += 1
-                quiesced = False
-                _dispatch(ev, self)
-                for h in self.get_handlers(ev.context):
-                    _dispatch(ev, h)
-                self.collector.pop()
-            elif quiesced:
-                return count
-            else:
-                for h in self.handlers:
-                    dispatch(h, "on_quiesced", self)
-                quiesced = True
-
-        return count
-
-    getters = {
-        Transport: lambda x: x.connection,
-        Delivery: lambda x: x.link,
-        Sender: lambda x: x.session,
-        Receiver: lambda x: x.session,
-        Session: lambda x: x.connection,
-    }
-
-    def get_handlers(self, context):
-        if hasattr(context, "handlers"):
-            return context.handlers
-        elif context.__class__ in self.getters:
-            parent = self.getters[context.__class__](context)
-            return self.get_handlers(parent)
-        else:
-            return self.handlers
-
-    def on_connection_local_open(self, event):
-        conn = event.context
-        if conn.state & Endpoint.REMOTE_UNINIT:
-            self._connect(conn)
-
-    def _connect(self, conn):
-        transport = Transport()
-        transport.idle_timeout = 300
-        sasl = transport.sasl()
-        sasl.mechanisms("ANONYMOUS")
-        transport.bind(conn)
-        sock = socket()
-        sock.setblocking(0)
-        hostport = conn.hostname.split(":", 1)
-        host = hostport[0]
-        if len(hostport) > 1:
-            port = int(hostport[1])
-        else:
-            port = 5672
-        sock.connect_ex((host, port))
-        selectable = Selectable(transport, sock)
-        self.add(selectable)
-
-    def on_timer(self, event):
-        event.context()
-
-    def connection(self, *handlers):
-        conn = Connection()
-        if handlers:
-            conn.handlers = _expand(handlers)
-        conn.collect(self.collector)
-        return conn
-
-    def acceptor(self, host, port):
-        return Acceptor(self, host, port)
-
-    def add(self, selectable):
-        self.selectables.append(selectable)
-
-class Handshaker(Handler):
-
-    def on_connection_remote_open(self, event):
-        conn = event.context
-        if conn.state & Endpoint.LOCAL_UNINIT:
-            conn.open()
-
-    def on_session_remote_open(self, event):
-        ssn = event.context
-        if ssn.state & Endpoint.LOCAL_UNINIT:
-            ssn.open()
-
-    def on_link_remote_open(self, event):
-        link = event.context
-        if link.state & Endpoint.LOCAL_UNINIT:
-            link.source.copy(link.remote_source)
-            link.target.copy(link.remote_target)
-            link.open()
-
-    def on_connection_remote_close(self, event):
-        conn = event.context
-        if not (conn.state & Endpoint.LOCAL_CLOSED):
-            conn.close()
-
-    def on_session_remote_close(self, event):
-        ssn = event.context
-        if not (ssn.state & Endpoint.LOCAL_CLOSED):
-            ssn.close()
-
-    def on_link_remote_close(self, event):
-        link = event.context
-        if not (link.state & Endpoint.LOCAL_CLOSED):
-            link.close()
-
-class FlowController(Handler):
-
-    def __init__(self, window):
-        self.window = window
-
-    def top_up(self, link):
-        delta = self.window - link.credit
-        link.flow(delta)
-
-    def on_link_local_open(self, event):
-        link = event.context
-        if link.is_receiver:
-            self.top_up(link)
-
-    def on_link_remote_open(self, event):
-        link = event.context
-        if link.is_receiver:
-            self.top_up(link)
-
-    def on_link_flow(self, event):
-        link = event.context
-        if link.is_receiver:
-            self.top_up(link)
-
-    def on_delivery(self, event):
-        delivery = event.context
-        if delivery.link.is_receiver:
-            self.top_up(delivery.link)
-
-class Row:
-
-    def __init__(self):
-        self.links = set()
-
-    def add(self, link):
-        self.links.add(link)
-
-    def discard(self, link):
-        self.links.discard(link)
-
-    def choose(self):
-        if self.links:
-            return random.choice(list(self.links))
-        else:
-            return None
-
-    def __iter__(self):
-        return iter(self.links)
-
-    def __nonzero__(self):
-        return bool(self.links)
-
-
-class Router(Handler):
-
-    EMPTY = Row()
-
-    def __init__(self):
-        self._outgoing = {}
-        self._incoming = {}
-
-    def incoming(self, address):
-        return self._incoming.get(address, self.EMPTY)
-
-    def outgoing(self, address):
-        return self._outgoing.get(address, self.EMPTY)
-
-    def address(self, link):
-        if link.is_sender:
-            return link.source.address or link.target.address
-        else:
-            return link.target.address
-
-    def table(self, link):
-        if link.is_sender:
-            return self._outgoing
-        else:
-            return self._incoming
-
-    def add(self, link):
-        address = self.address(link)
-        table = self.table(link)
-        row = table.get(address)
-        if row is None:
-            row = Row()
-            table[address] = row
-        row.add(link)
-
-    def remove(self, link):
-        address = self.address(link)
-        table = self.table(link)
-        row = table.get(address)
-        if row is not None:
-            row.discard(link)
-            if not row:
-                del table[address]
-
-    def on_link_local_open(self, event):
-        self.add(event.context)
-
-    def on_link_local_close(self, event):
-        self.remove(event.context)
-
-    def on_link_final(self, event):
-        self.remove(event.context)
-
-class Pool(Handler):
-
-    def __init__(self, collector, router=None):
-        self.collector = collector
-        self._connections = {}
-        if router:
-            self.outgoing_resolver = lambda address: router.outgoing(address).choose()
-            self.incoming_resolver = lambda address: router.incoming(address).choose()
-        else:
-            self.outgoing_resolver = lambda address: None
-            self.incoming_resolver = lambda address: None
-
-    def resolve(self, remote, local, resolver, constructor):
-        link = resolver(remote)
-        if link is None:
-            host = remote[2:].split("/", 1)[0]
-            conn = self._connections.get(host)
-            if conn is None:
-                conn = Connection()
-                conn.collect(self.collector)
-                conn.hostname = host
-                conn.open()
-                self._connections[host] = conn
-
-            ssn = conn.session()
-            ssn.open()
-            link = constructor(ssn, remote, local)
-            link.open()
-        return link
-
-    def on_transport_closed(self, event):
-        transport =  event.context
-        conn = transport.connection
-        del self._connections[conn.hostname]
-
-    def outgoing(self, target, source=None):
-        return self.resolve(target, source, self.outgoing_resolver, self.new_outgoing)
-
-    def incoming(self, source, target=None):
-        return self.resolve(source, target, self.incoming_resolver, self.new_incoming)
-
-    def new_outgoing(self, ssn, remote, local):
-        snd = ssn.sender("%s-%s" % (local, remote))
-        snd.source.address = local
-        snd.target.address = remote
-        return snd
-
-    def new_incoming(self, ssn, remote, local):
-        rcv = ssn.receiver("%s-%s" % (remote, local))
-        rcv.source.address = remote
-        rcv.target.address = local
-        return rcv
-
-class MessageDecoder(Handler):
-
-    def __init__(self, delegate):
-        self.__delegate = delegate
-
-    def on_start(self, drv):
-        try:
-            self.__delegate
-        except AttributeError:
-            self.__delegate = self
-        self.__message = Message()
-
-    def on_delivery(self, event):
-        dlv = event.context
-        if dlv.link.is_receiver and not dlv.partial:
-            encoded = dlv.link.recv(dlv.pending)
-            self.__message.decode(encoded)
-            try:
-                dispatch(self.__delegate, "on_message", dlv.link, self.__message)
-                dlv.update(Delivery.ACCEPTED)
-            except:
-                dlv.update(Delivery.REJECTED)
-                traceback.print_exc()
-            dlv.settle()
-
-class Address:
-
-    def __init__(self, st):
-        self.st = st
-
-    @property
-    def host(self):
-        return self.st[2:].split("/", 1)[0]
-
-    @property
-    def path(self):
-        parts = self.st[2:].split("/", 1)
-        if len(parts) == 2:
-            return parts[1]
-        else:
-            return ""
-
-    def __repr__(self):
-        return "Address(%r)" % self.st
-
-    def __str__(self):
-        return self.st
-
-class SendQueue(Handler):
-
-    def __init__(self, address):
-        self.address = Address(address)
-        self.messages = []
-        self.sent = 0
-
-    def on_start(self, drv):
-        self.driver = drv
-        self.connect()
-
-    def connect(self):
-        self.conn = self.driver.connection(self)
-        self.conn.hostname = self.address.host
-        ssn = self.conn.session()
-        snd = ssn.sender(str(self.address))
-        snd.target.address = str(self.address)
-        ssn.open()
-        snd.open()
-        self.conn.open()
-        self.link = snd
-
-    def put(self, message):
-        self.messages.append(message.encode())
-        if self.link:
-            self.pump(self.link)
-
-    def on_link_flow(self, event):
-        link = event.context
-        self.pump(link)
-
-    def pump(self, link):
-        while self.messages and link.credit > 0:
-            dlv = link.delivery(str(self.sent))
-            bytes = self.messages.pop(0)
-            link.send(bytes)
-            dlv.settle()
-            self.sent += 1
-
-    def on_transport_closed(self, event):
-        conn = event.context.connection
-        self.conn = None
-        self.link = None
-        self.driver.schedule(self.connect, 1)
-
-# XXX: terrible name for this
-class RecvQueue(Handler):
-
-    def __init__(self, address, delegate):
-        self.address = Address(address)
-        self.delegate = delegate
-        self.decoder = MessageDecoder(self.delegate)
-        self.handlers = [FlowController(1024), self.decoder, self]
-
-    def on_start(self, drv):
-        self.driver = drv
-        self.decoder.on_start(drv)
-        self.connect()
-
-    def connect(self):
-        self.conn = self.driver.connection(self)
-        self.conn.hostname = self.address.host
-        ssn = self.conn.session()
-        rcv = ssn.receiver(str(self.address))
-        rcv.source.address = str(self.address)
-        ssn.open()
-        rcv.open()
-        self.conn.open()
-
-    def on_transport_closed(self, event):
-        conn = event.context.connection
-        self.conn = None
-        self.driver.schedule(self.connect, 1)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/db_common.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/db_common.py b/examples/engine/py/db_common.py
deleted file mode 100755
index 05ad6f5..0000000
--- a/examples/engine/py/db_common.py
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/env 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.
-#
-
-import Queue
-import sqlite3
-import threading
-
-class Db(object):
-    def __init__(self, db, events):
-        self.db = db
-        self.events = events
-        self.tasks = Queue.Queue()
-        self.position = None
-        self.pending_events = []
-        self.running = True
-        self.thread = threading.Thread(target=self._process)
-        self.thread.daemon=True
-        self.thread.start()
-
-    def close(self):
-        self.tasks.put(lambda conn: self._close())
-
-    def reset(self):
-        self.tasks.put(lambda conn: self._reset())
-
-    def load(self, records, event=None):
-        self.tasks.put(lambda conn: self._load(conn, records, event))
-
-    def get_id(self, event):
-        self.tasks.put(lambda conn: self._get_id(conn, event))
-
-    def insert(self, id, data, event=None):
-        self.tasks.put(lambda conn: self._insert(conn, id, data, event))
-
-    def delete(self, id, event=None):
-        self.tasks.put(lambda conn: self._delete(conn, id, event))
-
-    def _reset(self, ignored=None):
-        self.position = None
-
-    def _close(self, ignored=None):
-        self.running = False
-
-    def _get_id(self, conn, event):
-        cursor = conn.execute("SELECT * FROM records ORDER BY id DESC")
-        row = cursor.fetchone()
-        if event:
-            if row:
-                event.id = row['id']
-            else:
-                event.id = 0
-            self.events.trigger(event)
-
-    def _load(self, conn, records, event):
-        if self.position:
-            cursor = conn.execute("SELECT * FROM records WHERE id > ? ORDER BY id", (self.position,))
-        else:
-            cursor = conn.execute("SELECT * FROM records ORDER BY id")
-        while not records.full():
-            row = cursor.fetchone()
-            if row:
-                self.position = row['id']
-                records.put(dict(row))
-            else:
-                break
-        if event:
-            self.events.trigger(event)
-
-    def _insert(self, conn, id, data, event):
-        if id:
-            conn.execute("INSERT INTO records(id, description) VALUES (?, ?)", (id, data))
-        else:
-            conn.execute("INSERT INTO records(description) VALUES (?)", (data,))
-        if event:
-            self.pending_events.append(event)
-
-    def _delete(self, conn, id, event):
-        conn.execute("DELETE FROM records WHERE id=?", (id,))
-        if event:
-            self.pending_events.append(event)
-
-    def _process(self):
-        conn = sqlite3.connect(self.db)
-        conn.row_factory = sqlite3.Row
-        with conn:
-            while self.running:
-                f = self.tasks.get(True)
-                try:
-                    while True:
-                        f(conn)
-                        f = self.tasks.get(False)
-                except Queue.Empty: pass
-                conn.commit()
-                for event in self.pending_events:
-                    self.events.trigger(event)
-                self.pending_events = []
-        self.events.close()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/db_ctrl.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/db_ctrl.py b/examples/engine/py/db_ctrl.py
deleted file mode 100755
index b28e0eb..0000000
--- a/examples/engine/py/db_ctrl.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env 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.
-#
-
-import sqlite3
-import sys
-
-if len(sys.argv) < 3:
-    print "Usage: %s [init|insert|list] db" % sys.argv[0]
-else:
-    conn = sqlite3.connect(sys.argv[2])
-    with conn:
-        if sys.argv[1] == "init":
-            conn.execute("DROP TABLE IF EXISTS records")
-            conn.execute("CREATE TABLE records(id INTEGER PRIMARY KEY AUTOINCREMENT, description TEXT)")
-            conn.commit()
-        elif sys.argv[1] == "list":
-            cursor = conn.cursor()
-            cursor.execute("SELECT * FROM records")
-            rows = cursor.fetchall()
-            for r in rows:
-                print r
-        elif sys.argv[1] == "insert":
-            while True:
-                l = sys.stdin.readline()
-                if not l: break
-                conn.execute("INSERT INTO records(description) VALUES (?)", (l.rstrip(),))
-            conn.commit()
-        else:
-            print "Unrecognised command: %s" %  sys.argv[1]

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/db_recv.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/db_recv.py b/examples/engine/py/db_recv.py
deleted file mode 100755
index 3be2dc7..0000000
--- a/examples/engine/py/db_recv.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env 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.
-#
-
-import optparse
-from proton.handlers import MessagingHandler
-from proton.reactor import ApplicationEvent, Container
-from db_common import Db
-
-class Recv(MessagingHandler):
-    def __init__(self, url, count):
-        super(Recv, self).__init__(auto_accept=False)
-        self.url = url
-        self.delay = 0
-        # TODO: load last tag from db
-        self.last_id = None
-        self.expected = count
-        self.received = 0
-        self.accepted = 0
-
-    def on_start(self, event):
-        self.db = Db("dst_db", event.container.get_event_trigger())
-        e = ApplicationEvent("id_loaded")
-        e.container = event.container
-        self.db.get_id(e)
-
-    def on_id_loaded(self, event):
-        self.last_id = event.id
-        event.container.create_receiver(self.url)
-
-    def on_record_inserted(self, event):
-        self.accept(event.delivery)
-        self.accepted += 1
-        if self.accepted == self.expected:
-            event.connection.close()
-            self.db.close()
-
-    def on_message(self, event):
-        id = int(event.message.id)
-        if (not self.last_id) or id > self.last_id:
-            if self.received < self.expected:
-                self.received += 1
-                self.last_id = id
-                self.db.insert(id, event.message.body, ApplicationEvent("record_inserted", delivery=event.delivery))
-                print "inserted message %s" % id
-            else:
-                self.release(event.delivery)
-        else:
-            self.accept(event.delivery)
-
-parser = optparse.OptionParser(usage="usage: %prog [options]")
-parser.add_option("-a", "--address", default="localhost:5672/examples",
-                  help="address from which messages are received (default %default)")
-parser.add_option("-m", "--messages", type="int", default=0,
-                  help="number of messages to receive; 0 receives indefinitely (default %default)")
-opts, args = parser.parse_args()
-
-try:
-    Container(Recv(opts.address, opts.messages)).run()
-except KeyboardInterrupt: pass
-
-
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/db_send.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/db_send.py b/examples/engine/py/db_send.py
deleted file mode 100755
index 29d64dd..0000000
--- a/examples/engine/py/db_send.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env 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.
-#
-
-import optparse
-import Queue
-import time
-from proton import Message
-from proton.handlers import MessagingHandler
-from proton.reactor import ApplicationEvent, Container
-from db_common import Db
-
-class Send(MessagingHandler):
-    def __init__(self, url, count):
-        super(Send, self).__init__()
-        self.url = url
-        self.delay = 0
-        self.sent = 0
-        self.confirmed = 0
-        self.load_count = 0
-        self.records = Queue.Queue(maxsize=50)
-        self.target = count
-
-    def keep_sending(self):
-        return self.target == 0 or self.sent < self.target
-
-    def on_start(self, event):
-        self.container = event.container
-        self.db = Db("src_db", self.container.get_event_trigger())
-        self.sender = self.container.create_sender(self.url)
-
-    def on_records_loaded(self, event):
-        if self.records.empty():
-            if event.subject == self.load_count:
-                print "Exhausted available data, waiting to recheck..."
-                # check for new data after 5 seconds
-                self.container.schedule(5, self)
-        else:
-            self.send()
-
-    def request_records(self):
-        if not self.records.full():
-            print "loading records..."
-            self.load_count += 1
-            self.db.load(self.records, event=ApplicationEvent("records_loaded", link=self.sender, subject=self.load_count))
-
-    def on_sendable(self, event):
-        self.send()
-
-    def send(self):
-        while self.sender.credit and not self.records.empty():
-            if not self.keep_sending(): return
-            record = self.records.get(False)
-            id = record['id']
-            self.sender.send(Message(id=id, durable=True, body=record['description']), tag=str(id))
-            self.sent += 1
-            print "sent message %s" % id
-        self.request_records()
-
-    def on_settled(self, event):
-        id = int(event.delivery.tag)
-        self.db.delete(id)
-        print "settled message %s" % id
-        self.confirmed += 1
-        if self.confirmed == self.target:
-            event.connection.close()
-            self.db.close()
-
-    def on_disconnected(self, event):
-        self.db.reset()
-        self.sent = self.confirmed
-
-    def on_timer_task(self, event):
-        print "Rechecking for data..."
-        self.request_records()
-
-parser = optparse.OptionParser(usage="usage: %prog [options]",
-                               description="Send messages to the supplied address.")
-parser.add_option("-a", "--address", default="localhost:5672/examples",
-                  help="address to which messages are sent (default %default)")
-parser.add_option("-m", "--messages", type="int", default=0,
-                  help="number of messages to send; 0 sends indefinitely (default %default)")
-opts, args = parser.parse_args()
-
-try:
-    Container(Send(opts.address, opts.messages)).run()
-except KeyboardInterrupt: pass
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/helloworld.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/helloworld.py b/examples/engine/py/helloworld.py
deleted file mode 100755
index d741f5e..0000000
--- a/examples/engine/py/helloworld.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env 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 proton import Message
-from proton.handlers import MessagingHandler
-from proton.reactor import Container
-
-class HelloWorld(MessagingHandler):
-    def __init__(self, server, address):
-        super(HelloWorld, self).__init__()
-        self.server = server
-        self.address = address
-
-    def on_start(self, event):
-        conn = event.container.connect(self.server)
-        event.container.create_receiver(conn, self.address)
-        event.container.create_sender(conn, self.address)
-
-    def on_sendable(self, event):
-        event.sender.send(Message(body=u"Hello World!"))
-        event.sender.close()
-
-    def on_message(self, event):
-        print event.message.body
-        event.connection.close()
-
-Container(HelloWorld("localhost:5672", "examples")).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/helloworld_blocking.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/helloworld_blocking.py b/examples/engine/py/helloworld_blocking.py
deleted file mode 100755
index d9a24a9..0000000
--- a/examples/engine/py/helloworld_blocking.py
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env 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 proton import Message
-from proton.utils import BlockingConnection
-from proton.handlers import IncomingMessageHandler
-
-class HelloWorldReceiver(IncomingMessageHandler):
-    def on_message(self, event):
-        print event.message.body
-        event.connection.close()
-
-conn = BlockingConnection("localhost:5672")
-conn.create_receiver("examples", handler=HelloWorldReceiver())
-sender = conn.create_sender("examples")
-sender.send(Message(body=u"Hello World!"));
-conn.run()
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/engine/py/helloworld_direct.py
----------------------------------------------------------------------
diff --git a/examples/engine/py/helloworld_direct.py b/examples/engine/py/helloworld_direct.py
deleted file mode 100755
index 2ad78a7..0000000
--- a/examples/engine/py/helloworld_direct.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env 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 proton import Message
-from proton.handlers import MessagingHandler
-from proton.reactor import Container
-
-class HelloWorld(MessagingHandler):
-    def __init__(self, url):
-        super(HelloWorld, self).__init__()
-        self.url = url
-
-    def on_start(self, event):
-        self.acceptor = event.container.listen(self.url)
-        event.container.create_sender(self.url)
-
-    def on_sendable(self, event):
-        event.sender.send(Message(body=u"Hello World!"))
-        event.sender.close()
-
-    def on_message(self, event):
-        print event.message.body
-
-    def on_accepted(self, event):
-        event.connection.close()
-
-    def on_connection_closed(self, event):
-        self.acceptor.close()
-
-Container(HelloWorld("localhost:8888/examples")).run()


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