| |
| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <meta name="description" content=""> |
| <meta name="author" content=""> |
| |
| <title>Publisher / subscriber implementation / Apache Celix</title> |
| |
| |
| <link rel="icon" href="/assets/img/favicon.ico"> |
| |
| |
| <link href="/assets/css/bootstrap.min.css" rel="stylesheet"> |
| |
| |
| <link href="/assets/css/style.css" rel="stylesheet"> |
| |
| <style> |
| |
| |
| .card-body img { |
| max-width: 100%; |
| width: 100%; |
| height: auto; |
| } |
| |
| |
| .card-body img + em { |
| text-decoration: underline; |
| } |
| </style> |
| |
| |
| <script> |
| var _paq = window._paq = window._paq || []; |
| |
| _paq.push(['disableCookies']); |
| |
| _paq.push(['trackPageView']); |
| _paq.push(['enableLinkTracking']); |
| (function() { |
| var u="https://analytics.apache.org/"; |
| _paq.push(['setTrackerUrl', u+'matomo.php']); |
| _paq.push(['setSiteId', '9']); |
| var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; |
| g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); |
| })(); |
| </script> |
| |
| |
| </head> |
| <body class="light-grey"> |
| |
| <a href="https://github.com/apache/celix" class="github-ribbon"> |
| <img src="/assets/img/forkme_right_red_aa0000.png" alt="Fork me on GitHub"> |
| </a> |
| |
| |
| <nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top"> |
| <div class="container"> |
| <a class="navbar-brand" href="/"> |
| <img src="/assets/img/celix-white.svg" height="40" class="d-inline-block align-top" alt="Celix Logo"> |
| </a> |
| <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> |
| <span class="navbar-toggler-icon"></span> |
| </button> |
| <div class="collapse navbar-collapse" id="navbarResponsive"> |
| <ul class="navbar-nav ml-auto"> |
| <li class="nav-item"> |
| <a class="nav-link" href="/">Home</a> |
| </li> |
| <li class="nav-item"> |
| <a class="nav-link" href="/download.cgi">Download</a> |
| </li> |
| <li class="nav-item dropdown active"> |
| <a class="nav-link dropdown-toggle" href="#" id="ddDocs" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
| Docs |
| </a> |
| <div class="dropdown-menu" aria-labelledby="ddDocs"> |
| <a class="dropdown-item" href="/docs/2.4.0/docs.html">2.4.0 (latest)</a> |
| <a class="dropdown-item" href="/docs/2.3.0/docs.html">2.3.0</a> |
| <a class="dropdown-item" href="/docs/2.2.1/docs.html">2.2.1</a> |
| <a class="dropdown-item" href="/docs/2.1.0/docs.html">2.1.0</a> |
| </div> |
| </li> |
| <li class="nav-item dropdown"> |
| <a class="nav-link dropdown-toggle" href="#" id="ddContributing" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
| Contributing |
| </a> |
| <div class="dropdown-menu" aria-labelledby="ddContributing"> |
| <a class="dropdown-item" href="/contributing/youatcelix.html">You at Celix</a> |
| <a class="dropdown-item" href="/contributing/submitting-patches.html">Submitting patches</a> |
| <a class="dropdown-item" href="/contributing/source-and-builds.html">Source code and builds</a> |
| <hr> |
| <a class="dropdown-item" href="/contributing/releasing.html">Releasing</a> |
| <a class="dropdown-item" href="/contributing/volunteers.html">Volunteers</a> |
| <a class="dropdown-item" href="https://whimsy.apache.org/board/minutes/Celix.html">Board Reports</a> |
| </div> |
| </li> |
| <li class="nav-item dropdown"> |
| <a class="nav-link dropdown-toggle" href="#" id="ddSupport" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
| Support |
| </a> |
| <div class="dropdown-menu" aria-labelledby="ddSupport"> |
| <a class="dropdown-item" href="/support/mailing-list.html">Mailing Lists</a> |
| <a class="dropdown-item" href="/support/issue-tracking.html">Issue Tracking</a> |
| </div> |
| </li> |
| <li class="nav-item dropdown"> |
| <a class="nav-link dropdown-toggle" href="#" id="ddFoundation" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
| ASF |
| </a> |
| <div class="dropdown-menu" aria-labelledby="ddFoundation"> |
| <a class="dropdown-item" href="https://www.apache.org/">ASF Home</a> |
| <a class="dropdown-item" href="https://www.apache.org/foundation/how-it-works.html">How it works</a> |
| <a class="dropdown-item" href="https://www.apache.org/licenses/">License</a> |
| <a class="dropdown-item" href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a> |
| <a class="dropdown-item" href="https://www.apache.org/foundation/thanks.html">Thanks</a> |
| <a class="dropdown-item" href="https://www.apache.org/security/">Security</a> |
| <a class="dropdown-item" href="https://www.apache.org/foundation/policies/conduct">Code of Conduct</a> |
| </div> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </nav> |
| |
| |
| <div class="section"> |
| <div class="container"> |
| <div class="row py-4"> |
| <div class="col-sm-12 card"> |
| <div class="card-body pt-5"> |
| |
| |
| |
| |
| <a class="edit-on-gh" href="https://github.com/apache/celix/edit/master/bundles/pubsub/README.md" title="Edit this page on GitHub">Edit on GitHub</a> |
| |
| |
| |
| |
| |
| <a href="/docs/2.4.0/docs.html" title="back to documentation"><< back to documentation</a> |
| |
| |
| |
| <!-- |
| 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. |
| --> |
| <h1 id="publisher--subscriber-implementation">Publisher / subscriber implementation</h1> |
| <p>This subdirectory contains an implementation for a publish-subscribe remote services system, that use dfi library for message serialization. |
| For low-level communication, TCP, UDP and ZMQ is used.</p> |
| <h1 id="description">Description</h1> |
| <p>This publisher / subscriber implementation is based on the concepts of the remote service admin (i.e. rsa / topology / discovery pattern).</p> |
| <p>Publishers are senders of data, subscribers can receive data. Publishers can publish/send data to certain channels (called ’topics’ further on), subscribers can subscribe to these topics. For every topic a publisher service is created by the pubsub admin. This publisher is announced through etcd. So etcd is used for discovery of the publishers. Subscribers are also registered as a service by the pubsub admin and will watch etcd for changes and when a new publisher is announced, the subscriber will check if the topic matches its interests. If the subscriber is interested in/subscribed to a certain topic, a connection between publisher and subscriber will be instantiated by the pubsub admin.</p> |
| <p>The dfi library is used for message serialization. The publisher / subscriber implementation will arrange that every message which will be send gets an unique id.</p> |
| <p>For communication between publishers and subscribers TCP, UDP and ZeroMQ can be used. When using ZeroMQ it’s also possible to setup a secure connection to encrypt the traffic being send between publishers and subscribers. This connection can be secured with ZeroMQ by using a curve25519 key pair per topic.</p> |
| <p>The publisher/subscriber implementation supports sending of a single message and sending of multipart messages.</p> |
| <h2 id="getting-started">Getting started</h2> |
| <p>The publisher/subscriber implementation contains 3 different PubSubAdmins for managing connections:</p> |
| <ul> |
| <li>PubsubAdminUDP: This pubsub admin is using udp (multicast) linux sockets to setup a connection.</li> |
| <li>PubsubAdminTCP: This pubsub admin is using tcp linux sockets to setup a connection.</li> |
| <li>PubsubAdminZMQ (LGPL License): This pubsub admin is using ZeroMQ and is disabled as default. This is a because the pubsub admin is using ZeroMQ which is licensed as LGPL (<a href="https://github.com/zeromq/libzmq#license">View ZeroMQ License</a>).</li> |
| </ul> |
| <p>The ZeroMQ pubsub admin can be enabled by specifying the build flag <code>BUILD_PUBSUB_PSA_ZMQ=ON</code>. To get the ZeroMQ pubsub admin running, <a href="https://github.com/zeromq/libzmq">ZeroMQ</a> and <a href="https://github.com/zeromq/czmq">CZMQ</a> need to be installed. Also, to make use of encrypted traffic, <a href="https://github.com/openssl/openssl">OpenSSL</a> is required.</p> |
| <h2 id="running-instructions">Running instructions</h2> |
| <h3 id="running-psa-udp-multicast">Running PSA UDP-Multicast</h3> |
| <ol> |
| <li>Open a terminal</li> |
| <li>Run <code>etcd</code></li> |
| <li>Open second terminal on project build location</li> |
| <li>Run <code>cd deploy/pubsub/pubsub_publisher_udp_mc</code></li> |
| <li>Run <code>sh run.sh</code></li> |
| <li>Open third terminal on project build location</li> |
| <li>Run <code>cd deploy/pubsub/pubsub_subscriber_udp_mc</code></li> |
| <li>Run <code>sh run.sh</code></li> |
| </ol> |
| <p>Design information can be found at pubsub_admin_udp_mc/README.md</p> |
| <h3 id="running-psa-tcp">Running PSA TCP</h3> |
| <ol> |
| <li>Open a terminal</li> |
| <li>Run <code>cd runtimes/pubsub/tcp</code></li> |
| <li>Run <code>sh start.sh</code></li> |
| </ol> |
| <h3 id="properties-psa-tcp">Properties PSA TCP</h3> |
| <p>Some properties can be set to configure the PSA-TCP. If not configured defaults will be used. These |
| properties can be set in the config.properties file (<PROPERTY>=<VALUE> format)</p> |
| <pre><code>PSA_IP The url address to be used by the TCP admin to publish its data. Default the first IP not on localhost |
| This can be hostname / IP address / IP address with postfix, e.g. 192.168.1.0/24 |
| </code></pre> |
| <h3 id="running-psa-zmq">Running PSA ZMQ</h3> |
| <p>For ZeroMQ without encryption, skip the steps 1-12 below</p> |
| <ol> |
| <li>Run <code>touch ~/pubsub.keys</code></li> |
| <li>Run <code>echo "aes_key:{AES_KEY here}" >> ~/pubsub.keys</code>. Note that AES_KEY is just a sequence of random bytes. To generate such a key, you can use the command <code>cat /dev/urandom | hexdump -v -e '/1 "%02X"' | head -c 32</code> (this will take out of /dev/urandom 16 bytes, thus a 128bit key)</li> |
| <li>Run <code>echo "aes_iv:{AES_IV here}" >> ~/pubsub.keys</code>. Note that AES_IV is just a sequence of random bytes. To generate such an initial vector , you can use the command <code>cat /dev/urandom | hexdump -v -e '/1 "%02X"' | head -c 16</code> (this will take out of /dev/urandom 8 bytes, thus a 64bit initial vector)</li> |
| <li>Run <code>touch ~/pubsub.conf</code></li> |
| <li>Run <code>echo "keys.file.path=$HOME" >> ~/pubsub.conf</code></li> |
| <li>Run <code>echo "keys.file.name=pubsub.keys" >> ~/pubsub.conf</code></li> |
| <li>Generate ZMQ keypairs by running <code>pubsub/keygen/makecert pub_<topic_name>.pub pub_<topic_name>.key</code></li> |
| <li>Encrypt the private key file using <code>pubsub/keygen/ed_file ~/pubsub.keys pub_<topic_name>.key pub_<topic>.key.enc</code></li> |
| <li>Store the keys in the pubsub/examples/keys/ directory, as described in the pubsub/examples/keys/README.</li> |
| <li>Build project to include these keys (check the CMakeLists.txt files to be sure that the keys are included in the bundles)</li> |
| <li>Add to the config.properties the property SECURE_TOPICS=<list_of_secure_topics></li> |
| </ol> |
| <p>For ZeroMQ without encryption, start here</p> |
| <ol> |
| <li>Run <code>etcd</code></li> |
| <li>Open second terminal on pubsub root</li> |
| <li>Run <code>cd deploy/pubsub/pubsub_publisher_zmq</code></li> |
| <li>Run <code>cat ~/pubsub.conf >> config.properties</code> (only for ZeroMQ with encryption)</li> |
| <li>Run <code>sh run.sh</code></li> |
| <li>Open third terminal on pubsub root</li> |
| <li>Run <code>cd deploy/pubsub/pubsub_subscriber_zmq</code></li> |
| <li>Run <code>cat ~/pubsub.conf >> config.properties</code> (only for ZeroMQ with encryption)</li> |
| <li>Run <code>sh run.sh</code></li> |
| </ol> |
| <h3 id="properties-psa-zmq">Properties PSA ZMQ</h3> |
| <p>Some properties can be set to configure the PSA-ZMQ. If not configured defaults will be used. These |
| properties can be set in the config.properties file (<PROPERTY>=<VALUE> format)</p> |
| <pre><code>PSA_IP The local IP address to be used by the ZMQ admin to publish its data. Default the first IP not on localhost |
| PSA_INTERFACE The local ethernet interface to be used by the ZMQ admin to publish its data (ie eth0). Default the first non localhost interface |
| PSA_ZMQ_RECEIVE_TIMEOUT_MICROSEC Set the polling interval of the ZMQ receive thread. Default 1ms</code></pre> |
| |
| |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| |
| <footer class="py-3 bg-secondary"> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-md-8 text-center"> |
| <p class="m-0 text-white"> |
| Copyright © 2023 The Apache Software Foundation, Licensed under |
| the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>. |
| <br> |
| Apache Celix, Celix, Apache, the Apache feather logo and the Apache Celix logo are trademarks of The Apache Software Foundation. |
| </p> |
| </div> |
| <div class="col-md-4 text-center"> |
| <a href="https://www.apache.org/events/current-event.html" target="_blank"> |
| <img src="https://www.apache.org/events/current-event-234x60.png" title="Apache Event" width="234" height="60" border="0"> |
| </a> |
| </div> |
| </div> |
| </div> |
| </footer> |
| |
| |
| <script src="/assets/js/jquery.min.js"></script> |
| <script src="/assets/js/bootstrap.bundle.min.js"></script> |
| |
| |
| </body> |
| </html> |