{"id":1147,"date":"2012-11-07T16:07:06","date_gmt":"2012-11-07T14:07:06","guid":{"rendered":"http:\/\/www.cloudcomp.ch\/?p=1147"},"modified":"2014-04-22T11:31:32","modified_gmt":"2014-04-22T09:31:32","slug":"rti-connext-dds-setup-and-helloworld-example-windowseclipsejava","status":"publish","type":"post","link":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/","title":{"rendered":"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java)"},"content":{"rendered":"<p style=\"text-align: justify\">This blog post aims to give you an overview over what RTI Connext DDS is, how it works and in which context it is used here at the ICCLab. Furthermore it shows you how to set it up and implement a simple HelloWorld-like application. It is not intended to explain details or specific concepts. For this you are kindly referred to the very abundant and well written documentation which comes with the product or can be found <a title=\"RTI-DDS Documentation\" href=\"http:\/\/community.rti.com\/content\/page\/documentation\" target=\"_blank\">online<\/a>.<\/p>\n<p style=\"text-align: justify\">The source code of the example can be found here &#8211;&gt;\u00a0<a href=\"http:\/\/www.cloudcomp.ch\/wp-content\/uploads\/2012\/11\/HelloWorld_Source.zip\">HelloWorld_Source<\/a><\/p>\n<h3><!--more--><\/h3>\n<p><!--more--><\/p>\n<h1><strong style=\"color: #000000\">What is RTI Connext DDS?<\/strong><\/h1>\n<p style=\"text-align: justify\">RTI Connext DDS is a network middleware built for real-time distributed applications. It implements the Data-Centric Publish-Subscribe (DCPS) API within OMG\u2019s\u00a0<a title=\"OMG DDS Portal\" href=\"http:\/\/portals.omg.org\/dds\/\" target=\"_blank\">Data Distribution Service<\/a> (DDS). As can be deduced by this name, the employed communications-model of this middleware is <em>publish-subscribe<\/em>. In this model applications \u201cpublish\u201d data they want to share and \u201csubscribe\u201d to data they need. These messages of data flow directly between publishers and subscribers and hence eliminate the need of having a centralized node (server\/broker) which has to organize the data-flow. A real life example of this model would be television or newspapers. The \u201cdata-centric\u201d part of DCPS describes the fundamental concept supported by the design of the API. In data-centric communications, the focus lies on the distribution of <strong>data<\/strong> (known data types in named streams) between communicating applications. In contrast, in object-centric communications the fundamental concept is the <strong>interface<\/strong> (know methods of known types) between applications. Another strength of RTI Connext DDS is its advanced and easy to use quality of service (QoS) support.<\/p>\n<h1>\u00a0<span style=\"color: #000000\"><strong>How does RTI Connext DDS work?<\/strong><\/span><\/h1>\n<p>The most important objects and entities of RTI Connext DDS are:<\/p>\n<ul>\n<li><strong><span style=\"color: #000000\">Domain:\u00a0<\/span><br \/>\n<\/strong>Is a concept to bind individual applications together for communication.<br \/>\nIt can be seen as the \u201cchannel\u201d through which data flows.<\/li>\n<li><span style=\"color: #000000\"><strong>DomainParticipant:\u00a0<\/strong><\/span><br \/>\nEnables an application to exchange messages within a certain domain.<br \/>\nIs used to create Publishers, DataWriters, Subscribers, DataReaders and Topics.<\/li>\n<li><span style=\"color: #000000\"><strong>Publisher<\/strong><\/span> and <strong><span style=\"color: #000000\">DataWriter:<\/span><br \/>\n<\/strong>Are used to send messages\/data. A DataWriter writes the actual message\/data and publishes it into a domain. A Publisher is used to group individual DataWriters together and to share common properties (e.g. QoS settings)\u00a0among them.<\/li>\n<li><span style=\"color: #000000\"><strong>Subscriber<\/strong><\/span> and <strong><span style=\"color: #000000\">DataReader:\u00a0<\/span><br \/>\n<\/strong>Are used to receive messages\/data. A DataReader reads the actual message it has received.\u00a0A Subscriber is used to group individual DataReaders together and to share common properties\u00a0(e.g. QoS settings)\u00a0among them.<\/li>\n<li><strong><span style=\"color: #000000\">Topic:\u00a0<\/span><br \/>\n<\/strong>Connects a DataWriter to a DataReader. Consists of a name and a data-type<strong><\/strong><\/li>\n<\/ul>\n<p style=\"text-align: justify\">To establish a communication-channel, DataWriters and DataReaders must have the same <em>Topic<\/em> of the same <em>data-type<\/em> and be members of the same <em>Domain<\/em>. There is no need to define an address of a subscriber or publisher, RTI Connext DDS works with an auto-discovery mechanism to match publishers with subscribers.<\/p>\n<p style=\"text-align: justify\">The following picture (Source: RTI Connext Core Libraries and Utilities Getting Started Guide) shows you the relationship of these objects and entities.<\/p>\n<figure id=\"attachment_1166\" aria-describedby=\"caption-attachment-1166\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1166 \" title=\"RTI Entity Overview\" alt=\"\" src=\"http:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small-300x173.png\" width=\"300\" height=\"173\" srcset=\"https:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small-300x173.png 300w, https:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small-500x289.png 500w, https:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small.png 547w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1166\" class=\"wp-caption-text\">RTI Connext DDS Components<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h1><strong style=\"color: #000000\">In what Context is RTI Connext DDS used at the ICCLab?<\/strong><\/h1>\n<p style=\"text-align: justify\">The ICCLab is currently one of the members of the <a title=\"FI-WARE Web-Portal\" href=\"http:\/\/http:\/\/www.fi-ware.eu\/\" target=\"_blank\">FI-WARE<\/a>\u00a0open call project \u201cMiddleware for efficient and QoS\/Security-aware invocation of services and exchange of messages\u201d named <a title=\"KIARA ICCLab Page\" href=\"http:\/\/www.cloudcomp.ch\/research\/foundation\/projects\/kiara\/\" target=\"_blank\">KIARA<\/a>. RTI Connext DDS middleware serves as the basis on which KIARA will build upon. KIARA\u2019s goal is to add the following capabilities to RTI Connext DDS:<\/p>\n<ul>\n<li>Multi-Domain Model<\/li>\n<li>Runtime Negotiation and Transport Configuration<\/li>\n<li>Embedded Compiler to simplify data access by applications<\/li>\n<li>Additional communication protocols and mechanisms<\/li>\n<li>Support for SOAP and RESTfull marshaling<\/li>\n<li>Security by Design<\/li>\n<\/ul>\n<p>KIARA will use the plugin architecture of RTI Connext DDS to implement these extensions, but they should also be easily adoptable for alternative DDS implementations like <a href=\"http:\/\/www.opendds.org\">OpenDDS<\/a>.<\/p>\n<h1><span style=\"color: #000000\"><strong>Setting up RTI Connext DDS<\/strong><\/span><\/h1>\n<p style=\"text-align: justify\">Remark: As this is a middleware, it is possible to send data from one platform (language\/compiler\/operating system\/processor) to many others. Therefore there are multiple operating systems this middleware could be installed on and multiple programming languages an application could be written in. In this example the used operating system is Windows 7 and the programming language is Java (JDK1.7) with the Eclipse IDE (JUNO).<\/p>\n<p>To set up RTI Connext DDS follow these steps:<\/p>\n<p>1)\u00a0<span style=\"color: #000000\"><strong>Install RTI Connext DDS<\/strong><\/span><\/p>\n<p style=\"padding-left: 30px\">RTI Connext DDS can easily be installed by using the installer.<\/p>\n<p>2)\u00a0<span style=\"color: #000000\"><strong>Install License File<\/strong><\/span><\/p>\n<p style=\"padding-left: 30px\">Copy the license file (as received by RTI) into the C:&#8230;RTI and C:&#8230;RTIndds.x.x.x folders.<\/p>\n<p>3)\u00a0<span style=\"color: #000000\"><strong>Set Environment Variables<\/strong><\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td>RTI_LICENSE_FILE<\/td>\n<td>C:&#8230;RTI<\/td>\n<\/tr>\n<tr>\n<td>NDDSHOME<\/td>\n<td>C:&#8230;RTIndds.x.x.x<\/td>\n<\/tr>\n<tr>\n<td>PATH (append)<\/td>\n<td>C:&#8230;RTIndds.x.x.x lib&lt;architecture&gt;jdk<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>4) <span style=\"color: #000000\"><strong>Eclipse: Add Libraries<\/strong><\/span><\/p>\n<p style=\"padding-left: 30px\">In order to be able to build applications, add C:&#8230;RTIndds.5.0.0classnddsjava.jar to your project libraries (Project&#8211;&gt;Properties&#8211;&gt;Java Build Path&#8211;&gt;Libraries&#8211;&gt;Add External JARs).<\/p>\n<p>&nbsp;<\/p>\n<h1><span style=\"color: #000000\"><strong>Getting started with RTI Connext DDS: HelloWorld<br \/>\n<\/strong><\/span><\/h1>\n<p style=\"text-align: justify\">As mentioned before, the documentation of RTI Connext DDS is abundant \u2013 the user manual alone is 780 pages strong &#8211; and very well and clearly written. The \u201cGetting Started\u201d guide shows you basics concepts and familiarizes with the API. \u00a0There are also numerous code examples. And every example is available in C, C++, C# and Java. A big compliment has to be given here to RTI for this outstanding documentation of the product.<\/p>\n<p style=\"text-align: justify\">I will now walk you through the <em>HelloSimple<\/em> example which also comes with the product. This application has two classes, a publisher who allows a user to write an arbitrary line of text and a subscriber who will receive this text as soon as it becomes available.<\/p>\n<h2><span style=\"color: #000000\"><strong>Implementing the Publisher<\/strong><\/span><\/h2>\n<p>Let\u2019s start with the <em>Publisher<\/em> class which in this case is named <span style=\"color: #000000\"><strong>HelloPublisher<\/strong>.<\/span><\/p>\n<pre>public class HelloPublisher {\r\npublic static final void main(String[] args)<\/pre>\n<p><a href=\"https:\/\/gist.github.com\/sandorkan\/4025165\" target=\"_blank\">Gist:\u00a04025165<\/a><\/p>\n<p><span style=\"color: #000000\"><strong>1) Creating the DomainParticipant<\/strong><\/span><\/p>\n<p style=\"text-align: justify\">First a <em>DomainParticipant<\/em> has to be created. The <em>DomainParticipant<\/em> defines in which <em>Domain<\/em> an application belongs and will be used to create all other needed entities\u00a0like the <em>Publisher<\/em>, <em>DataWriter<\/em> and <em>Topic<\/em>. The create_participant() method takes four arguments:<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>domainID<\/strong><\/td>\n<td>An integer value which defines the <em>Domain<\/em> the <em>DomainParticipant<\/em> is in.<\/td>\n<\/tr>\n<tr>\n<td><strong>QoS<\/strong><\/td>\n<td>Quality of service settings to be used. In this case the default QoS settings are being used.<\/td>\n<\/tr>\n<tr>\n<td><strong>listener<\/strong><\/td>\n<td>An optional listener (callback routine) to be invoked when specific events with respect to the <em>DomainParticipant<\/em> occur.<\/td>\n<\/tr>\n<tr>\n<td><strong>mask<\/strong><\/td>\n<td>Defines the type of events that trigger the callback routine (listener).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre id=\"file-hellopublisherdomainparticipant-java-LC1\">\/\/ Create the DDS Domain participant on domain ID 0\r\nDomainParticipant participant = DomainParticipantFactory.get_instance().create_participant(\r\n0,                                                \/\/ Domain ID = 0\r\nDomainParticipantFactory.PARTICIPANT_QOS_DEFAULT, \/\/ QoS Settings = Default\r\nnull,                                             \/\/ listener\r\nStatusKind.STATUS_MASK_NONE);                     \/\/ mask\r\nif (participant == null) {\r\n    System.err.println(\"Unable to create domain participant\");\r\n    return;\r\n}<\/pre>\n<p><a href=\"https:\/\/gist.github.com\/sandorkan\/4025343\" target=\"_blank\">Gist: 4025343<\/a><\/p>\n<p><span style=\"color: #000000\"><strong>2) Creating the Topic<\/strong><\/span><\/p>\n<p style=\"text-align: justify\">The <em>DomainParticipant<\/em> is now used to create a <em>Topic<\/em> with the name \u201cHello, World\u201d and the built-in String data type. Remember, a <em>Topic<\/em> always consists of a name and a data type. The create_topic() method takes five arguments:<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>topic_name<\/strong><\/td>\n<td>Name of the <em>Topic<\/em> (String)<\/td>\n<\/tr>\n<tr>\n<td><strong>type_name<\/strong><\/td>\n<td>The name of the user data type. In this case, the built-in String data type is used.<\/td>\n<\/tr>\n<tr>\n<td><strong>QoS<\/strong><\/td>\n<td>Quality of service settings to be used. In this case the default QoS settings are being used.<\/td>\n<\/tr>\n<tr>\n<td><strong>listener<\/strong><\/td>\n<td>An optional listener (callback routine) to be invoked when specific events with respect to the <em>Topic<\/em> occur. If this is null, the <em>DomainParticipant<\/em>&#8216;s listener (if existing) will be used.<\/td>\n<\/tr>\n<tr>\n<td><strong>mask<\/strong><\/td>\n<td>Defines the type of events that trigger the callback routine (listener).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre id=\"file-hellopublishertopiccreation-java-LC1\">\/\/ Create the topic \"Hello World\" with the built-in String type\r\nTopic helloWorldTopic = participant.create_topic(\r\n    \"Hello, World\",                      \/\/topic_name\r\n    StringTypeSupport.get_type_name(),   \/\/type_name\r\n    DomainParticipant.TOPIC_QOS_DEFAULT, \/\/QoS\r\n    null,                                \/\/listener\r\n    StatusKind.STATUS_MASK_NONE);        \/\/mask\r\nif (topic == null) {\r\n    System.err.println(\"Unable to create topic.\");\r\n    return;\r\n}<\/pre>\n<p><a href=\"https:\/\/gist.github.com\/sandorkan\/4025420\" target=\"_blank\">Gist: 4025420<\/a><\/p>\n<p><span style=\"color: #000000\"><strong>3) Creating the DataWriter (with default Publisher)<\/strong><\/span><\/p>\n<p style=\"text-align: justify\">The <em>DomainParticipant<\/em> can now instantiate a <em>DataWriter<\/em>. This object will then later be used to write the messages to be sent to subscribers. The create_datawriter() method takes four arguments:<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>topic<\/strong><\/td>\n<td>The topic for which this <em>DataWriter<\/em> will write messages\/data.<\/td>\n<\/tr>\n<tr>\n<td><strong>QoS<\/strong><\/td>\n<td>The name of the user data type. In this case, the built-in String data type is used.<\/td>\n<\/tr>\n<tr>\n<td><strong>listener<\/strong><\/td>\n<td>An optional listener (callback routine) to be invoked when specific events with respect to the <em>DataWriter<\/em> occur. If this is null, the <em>Publisher<\/em>&#8216;s listener (if existing) will be used.<\/td>\n<\/tr>\n<tr>\n<td><strong>mask<\/strong><\/td>\n<td>Defines the type of events that trigger the callback routine (listener).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: justify\">If you\u2019re wondering why there was no <em>Publisher<\/em> instantiated. The creation of a <em>Publisher\u00a0<\/em>is optional and if not explicitly created, a default publisher is used (this is an extension of RTI Connext DDS and not part of the DDS standard). Otherwise the <em>Publisher\u00a0<\/em>could be used to create the <em>DataWriter<\/em>.<\/p>\n<pre id=\"file-hellopublisherdatawriter-java-LC1\">\/\/ Create the data writer using the default publisher\r\nStringDataWriter dataWriter = (StringDataWriter)participant.create_datawriter(\r\n    helloWorldTopic,                  \/\/ Topic\r\n    Publisher.DATAWRITER_QOS_DEFAULT, \/\/ QoS\r\n    null,                             \/\/ listener\r\n    StatusKind.STATUS_MASK_NONE);     \/\/ mask\r\nif (dataWriter == null) {\r\n    System.err.println(\"Unable to create data writer\\n\");\r\n    return;\r\n}<\/pre>\n<p><a href=\"https:\/\/gist.github.com\/sandorkan\/4030283\" target=\"_blank\">Gist: 4030283<\/a><\/p>\n<p><span style=\"color: #000000\"><strong>4) Writing messages with DataWriter<\/strong><\/span><\/p>\n<p style=\"text-align: justify\">Finally we can use the <em>DataWriter<\/em> to write \u2013 and automatically publish through the default <em>Publisher<\/em>\u00a0&#8211; messages that we in this case receive as user input. The write() method takes two arguments.<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Instance<\/strong><\/td>\n<td>An instance of the data type to be sent. In this case a String.<\/td>\n<\/tr>\n<tr>\n<td><strong>InstanceHandle<\/strong><\/td>\n<td>An InstanceHandle. This is used with keyed data types, a subject not covered in this blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: justify\">Before terminating the program, all entities of the <em>DomainParticipant<\/em> and the <em>DomainParticipant<\/em> itself are deleted.<\/p>\n<pre id=\"file-hellopublisherwritingdata-java-LC1\">System.out.println(\"Ready to write data.\");\r\nSystem.out.println(\"When the subscriber is ready, you can start writing.\");\r\nSystem.out.print(\"Press CTRL+C to terminate or enter an empty line to do a clean shutdown.\\n\\n\");\u00a0\r\n\r\nBufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\r\ntry\r\n{\r\nwhile (true) {\r\nSystem.out.print(\"Please type a message&gt; \");\r\n    String toWrite = reader.readLine();\r\n        dataWriter.write(toWrite, InstanceHandle_t.HANDLE_NIL);\u00a0\r\n\r\n        if (toWrite.equals(\"\")) break;\r\n    }\r\n}\r\ncatch (IOException e)\r\n{\r\n    e.printStackTrace();\r\n} catch (RETCODE_ERROR e) {\r\n    \/\/ This exception can be thrown from DDS write operation\r\n    e.printStackTrace();\r\n}\u00a0\r\n\r\nSystem.out.println(\"Exiting...\");\u00a0\r\n\r\n\/\/ Deleting entities of DomainParticipant and DomainParticipant\r\nparticipant.delete_contained_entities();\r\nDomainParticipantFactory.get_instance().delete_participant(participant);\r\n}}<\/pre>\n<p><a href=\"https:\/\/gist.github.com\/sandorkan\/4030299\" target=\"_blank\">Gist: 4030299<\/a><\/p>\n<h2><strong><span style=\"color: #000000\">Implementing the Subscriber<\/span><\/strong><\/h2>\n<p style=\"text-align: justify\">The <em>Subscriber<\/em> is very similar to the <em>Publisher<\/em>.\u00a0 There also needs to be a <em>DomainParticipant<\/em> and a <em>Topic<\/em>. The creation of those will not be explained again. Instead of a <em>DataWriter<\/em>, there will now be a <em>DataReader<\/em>. A listener will be implemented to automatically run when new messages are available. For the <em>Subscriber<\/em>\u00a0to be able to receive messages sent by the HelloPublisher, the <em>DomainParticipant<\/em> must be in the same <em>Domain<\/em> and the <em>Topic<\/em> must have the same name and data type.<\/p>\n<pre id=\"file-hellosubscriberbeginning-java-LC1\">public class HelloSubscriber extends DataReaderAdapter {\u00a0\r\n\r\n\/\/ For clean shutdown sequence\r\nprivate static boolean shutdown_flag = false;\r\n\r\npublic static final void main(String[] args) {\r\n\r\n\/\/ Create the DDS Domain participant on domain ID 0\r\nDomainParticipant participant = DomainParticipantFactory.get_instance().create_participant(\r\n    0,                                                \/\/ Domain ID = 0\r\n    DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT, \/\/ QoS\r\n    null,                                             \/\/ listener\r\n    StatusKind.STATUS_MASK_NONE);                     \/\/ mask\r\nif (participant == null) {\r\nSystem.err.println(\"Unable to create domain participant\");\r\nreturn;\r\n}\u00a0\r\n\r\n\/\/ Create the topic \"Hello World\" for the String type\r\nTopic topic = participant.create_topic(\r\n    \"Hello, World\",                      \/\/ Topic Name\r\n    StringTypeSupport.get_type_name(),   \/\/ Topic Data Type\r\n    DomainParticipant.TOPIC_QOS_DEFAULT, \/\/ QoS\r\n    null,                                \/\/ listener\r\n    StatusKind.STATUS_MASK_NONE);        \/\/ mask\r\nif (topic == null) {\r\n    System.err.println(\"Unable to create topic.\");\r\n    return;\r\n}<\/pre>\n<p style=\"text-align: justify\"><a href=\"https:\/\/gist.github.com\/sandorkan\/4030332\" target=\"_blank\">Gist: 4030332<\/a><\/p>\n<p style=\"text-align: justify\"><strong style=\"color: #000000\">1 ) Creating the DataReader<\/strong><\/p>\n<p>After the <em>DomainParticipant<\/em> and <em>Topic<\/em>, the <em>DataReader<\/em> will be created. As can be seen, it has to be bound to a topic at instantiation time and in this case \u2013 for the first time in our example &#8211; uses a listener as well as a mask. The listener is, in this case, an instance of HelloSubscriber. That is also the reason why the HelloSubscriber class extends from the DataReaderAdapter class and overrides the on_data_available(DataReader reader) method which is the method that will be triggered once data becomes available. The mask indicates that this listener should be trigger as soon as new messages\/data is available.<\/p>\n<pre id=\"file-hellosubscriberdatareader-java-LC2\">\/\/ Create the data reader using the default publisher\r\nStringDataReader dataReader = (StringDataReader) participant.create_datareader(\r\n    topic, \/\/Topic\r\n    Subscriber.DATAREADER_QOS_DEFAULT, \/\/ QoS\r\n    new HelloSubscriber(), \/\/ Listener\r\n    StatusKind.DATA_AVAILABLE_STATUS); \/\/ mask\r\n\r\nif (dataReader == null) {\r\n    System.err.println(\"Unable to create DDS Data Reader\");\r\n    return;\r\n}\r\n\r\n\/\/ Reading User-Input\r\nSystem.out.println(\"Ready to read data.\");\r\nSystem.out.println(\"Press CTRL+C to terminate.\");\r\n\r\nfor (;;) {\r\ntry {\r\n    Thread.sleep(2000);\r\n    if(shutdown_flag) break;\r\n    }catch (InterruptedException e) {\r\n    \/\/ Nothing to do...\r\n    }\r\n}\r\n\r\nSystem.out.println(\"Shutting down...\");\r\n\r\n\/\/ Deleting entities and DomainParticipant\r\nparticipant.delete_contained_entities();\r\nDomainParticipantFactory.get_instance().delete_participant(participant);\r\n}<\/pre>\n<p><a href=\"https:\/\/gist.github.com\/sandorkan\/4030389\" target=\"_blank\">Gist: 4030389<\/a><\/p>\n<p><span style=\"color: #000000\"><strong>2) Reading the Data<\/strong><\/span><\/p>\n<p style=\"text-align: justify\">Finally in the on_data_available() Method the logic to read data is implemented. Every received message (called sample)\u00a0 is actually composed of two parts. First of the message itself (here a String) and second of a metafile of type SampleInfo which\u00a0 contains additional information about that message.<\/p>\n<p style=\"text-align: justify\">The created stringReader then tries to read the next sample with the take_next_sample() method into which it passes the info file. If the sample contains actual data, the valid_data property of the info object will equal true and the sample will be printed onto the console.<\/p>\n<pre id=\"file-hellosubscribercallbackmethod-java-LC1\">public void on_data_available(DataReader reader) {\r\n\r\n\/\/ Method Parameter of Type DataReader must be cast to Data Type ofDataReader for this Topic\r\nStringDataReader stringReader = (StringDataReader) reader;\r\nSampleInfo info = new SampleInfo();\r\n\r\nfor (;;) {\r\ntry {\r\n    String sample = stringReader.take_next_sample(info);\r\n    if (info.valid_data) {\r\n        System.out.println(sample);\r\n\r\n        if (sample.equals(\"\")) {\r\n        shutdown_flag = true;\r\n        }\r\n    }\r\n}\r\ncatch (RETCODE_NO_DATA noData) {\r\n    \/\/ No more data to read\r\n    break;\r\n}\r\ncatch (RETCODE_ERROR e) {\r\n<span style=\"font-family: 'Courier 10 Pitch', Courier, monospace;font-size: 13px;font-style: normal;line-height: 1.5\">    \/\/ An error occurred\r\n<\/span>    e.printStackTrace();\r\n}\r\n}}}<\/pre>\n<p style=\"text-align: justify\"><a href=\"https:\/\/gist.github.com\/sandorkan\/4030451\" target=\"_blank\">Gist: 4030451<\/a><\/p>\n<h1 style=\"text-align: justify\"><span style=\"color: #000000\"><strong>Conclusion<\/strong><\/span><\/h1>\n<p style=\"text-align: justify\">This should have given you a small insight into RTI Connext DDS. There is still a vast amount of additional functionalities and configurations that this product has to offer. But after exploring this middleware for some weeks it has clearly shown to be an excellent starting point for the KIARA project.<\/p>\n<div class=\"pt-sm\">Schlagw\u00f6rter: <a href=\"https:\/\/blog.zhaw.ch\/icclab\/tag\/data-centric\/\">Data-Centric<\/a>, <a href=\"https:\/\/blog.zhaw.ch\/icclab\/tag\/fi-ware\/\">FI-WARE<\/a>, <a href=\"https:\/\/blog.zhaw.ch\/icclab\/tag\/kiara\/\">KIARA<\/a>, <a href=\"https:\/\/blog.zhaw.ch\/icclab\/tag\/middleware\/\">Middleware<\/a>, <a href=\"https:\/\/blog.zhaw.ch\/icclab\/tag\/publish-subscribe\/\">Publish-Subscribe<\/a>, <a href=\"https:\/\/blog.zhaw.ch\/icclab\/tag\/rti-connext-dds\/\">RTI Connext DDS<\/a>, <a href=\"https:\/\/blog.zhaw.ch\/icclab\/tag\/rti-dds\/\">RTI-DDS<\/a><br><\/div>","protected":false},"excerpt":{"rendered":"<p>This blog post aims to give you an overview over what RTI Connext DDS is, how it works and in which context it is used here at the ICCLab. Furthermore it shows you how to set it up and implement a simple HelloWorld-like application. It is not intended to explain details or specific concepts. For this you are kindly referred to the very abundant and well written documentation which comes with the product or can be found online.<\/p>\n","protected":false},"author":80,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[5,15],"tags":[101,141,205,218,270,287,288],"features":[],"class_list":["post-1147","post","type-post","status-publish","format-standard","hentry","category-articles","category-howtos","tag-data-centric","tag-fi-ware","tag-kiara","tag-middleware","tag-publish-subscribe","tag-rti-connext-dds","tag-rti-dds"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java) - Service Engineering (ICCLab &amp; SPLab)<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java)\" \/>\n<meta property=\"og:description\" content=\"This blog post aims to give you an overview over what RTI Connext DDS is, how it works and in which context it is used here at the ICCLab. Furthermore it shows you how to set it up and implement a simple HelloWorld-like application. It is not intended to explain details or specific concepts. For this you are kindly referred to the very abundant and well written documentation which comes with the product or can be found online.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/\" \/>\n<meta property=\"og:site_name\" content=\"Service Engineering (ICCLab &amp; SPLab)\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-07T14:07:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-04-22T09:31:32+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small-300x173.png\" \/>\n<meta name=\"author\" content=\"Sandro Brunner\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sandro Brunner\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/\"},\"author\":{\"name\":\"Sandro Brunner\",\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/#\/schema\/person\/99f82e9c9e266cab97fb4fdcec230d05\"},\"headline\":\"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java)\",\"datePublished\":\"2012-11-07T14:07:06+00:00\",\"dateModified\":\"2014-04-22T09:31:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/\"},\"wordCount\":1785,\"commentCount\":7,\"image\":{\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small-300x173.png\",\"keywords\":[\"Data-Centric\",\"FI-WARE\",\"KIARA\",\"Middleware\",\"Publish-Subscribe\",\"RTI Connext DDS\",\"RTI-DDS\"],\"articleSection\":[\"Articles\",\"HowTos\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/\",\"url\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/\",\"name\":\"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java) - Service Engineering (ICCLab &amp; SPLab)\",\"isPartOf\":{\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small-300x173.png\",\"datePublished\":\"2012-11-07T14:07:06+00:00\",\"dateModified\":\"2014-04-22T09:31:32+00:00\",\"author\":{\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/#\/schema\/person\/99f82e9c9e266cab97fb4fdcec230d05\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#primaryimage\",\"url\":\"https:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small.png\",\"contentUrl\":\"https:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small.png\",\"width\":547,\"height\":317,\"caption\":\"RTI Connext DDS Components\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\/\/blog.zhaw.ch\/icclab\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/#website\",\"url\":\"https:\/\/blog.zhaw.ch\/icclab\/\",\"name\":\"Service Engineering (ICCLab &amp; SPLab)\",\"description\":\"A Blog of the ZHAW Zurich University of Applied Sciences\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.zhaw.ch\/icclab\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/#\/schema\/person\/99f82e9c9e266cab97fb4fdcec230d05\",\"name\":\"Sandro Brunner\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.zhaw.ch\/icclab\/files\/2014\/03\/IMG_0234.jpg\",\"url\":\"https:\/\/blog.zhaw.ch\/icclab\/files\/2014\/03\/IMG_0234.jpg\",\"contentUrl\":\"https:\/\/blog.zhaw.ch\/icclab\/files\/2014\/03\/IMG_0234.jpg\",\"caption\":\"Sandro Brunner\"},\"url\":\"https:\/\/blog.zhaw.ch\/icclab\/author\/brnr\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java) - Service Engineering (ICCLab &amp; SPLab)","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/","og_locale":"en_US","og_type":"article","og_title":"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java)","og_description":"This blog post aims to give you an overview over what RTI Connext DDS is, how it works and in which context it is used here at the ICCLab. Furthermore it shows you how to set it up and implement a simple HelloWorld-like application. It is not intended to explain details or specific concepts. For this you are kindly referred to the very abundant and well written documentation which comes with the product or can be found online.","og_url":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/","og_site_name":"Service Engineering (ICCLab &amp; SPLab)","article_published_time":"2012-11-07T14:07:06+00:00","article_modified_time":"2014-04-22T09:31:32+00:00","og_image":[{"url":"http:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small-300x173.png","type":"","width":"","height":""}],"author":"Sandro Brunner","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sandro Brunner","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#article","isPartOf":{"@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/"},"author":{"name":"Sandro Brunner","@id":"https:\/\/blog.zhaw.ch\/icclab\/#\/schema\/person\/99f82e9c9e266cab97fb4fdcec230d05"},"headline":"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java)","datePublished":"2012-11-07T14:07:06+00:00","dateModified":"2014-04-22T09:31:32+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/"},"wordCount":1785,"commentCount":7,"image":{"@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#primaryimage"},"thumbnailUrl":"http:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small-300x173.png","keywords":["Data-Centric","FI-WARE","KIARA","Middleware","Publish-Subscribe","RTI Connext DDS","RTI-DDS"],"articleSection":["Articles","HowTos"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/","url":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/","name":"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java) - Service Engineering (ICCLab &amp; SPLab)","isPartOf":{"@id":"https:\/\/blog.zhaw.ch\/icclab\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#primaryimage"},"image":{"@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#primaryimage"},"thumbnailUrl":"http:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small-300x173.png","datePublished":"2012-11-07T14:07:06+00:00","dateModified":"2014-04-22T09:31:32+00:00","author":{"@id":"https:\/\/blog.zhaw.ch\/icclab\/#\/schema\/person\/99f82e9c9e266cab97fb4fdcec230d05"},"breadcrumb":{"@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#primaryimage","url":"https:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small.png","contentUrl":"https:\/\/blog.zhaw.ch\/icclab\/files\/2012\/11\/RTI_EntityOverview_small.png","width":547,"height":317,"caption":"RTI Connext DDS Components"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.zhaw.ch\/icclab\/rti-connext-dds-setup-and-helloworld-example-windowseclipsejava\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/blog.zhaw.ch\/icclab\/"},{"@type":"ListItem","position":2,"name":"RTI Connext DDS : Setup and HelloWorld Example (Windows\/Eclipse\/Java)"}]},{"@type":"WebSite","@id":"https:\/\/blog.zhaw.ch\/icclab\/#website","url":"https:\/\/blog.zhaw.ch\/icclab\/","name":"Service Engineering (ICCLab &amp; SPLab)","description":"A Blog of the ZHAW Zurich University of Applied Sciences","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.zhaw.ch\/icclab\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.zhaw.ch\/icclab\/#\/schema\/person\/99f82e9c9e266cab97fb4fdcec230d05","name":"Sandro Brunner","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.zhaw.ch\/icclab\/files\/2014\/03\/IMG_0234.jpg","url":"https:\/\/blog.zhaw.ch\/icclab\/files\/2014\/03\/IMG_0234.jpg","contentUrl":"https:\/\/blog.zhaw.ch\/icclab\/files\/2014\/03\/IMG_0234.jpg","caption":"Sandro Brunner"},"url":"https:\/\/blog.zhaw.ch\/icclab\/author\/brnr\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/posts\/1147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/comments?post=1147"}],"version-history":[{"count":3,"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/posts\/1147\/revisions"}],"predecessor-version":[{"id":4724,"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/posts\/1147\/revisions\/4724"}],"wp:attachment":[{"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/media?parent=1147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/categories?post=1147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/tags?post=1147"},{"taxonomy":"features","embeddable":true,"href":"https:\/\/blog.zhaw.ch\/icclab\/wp-json\/wp\/v2\/features?post=1147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}