Home

Getting Started Guide - Community RTI Connext Users

image

Contents

1. 04 1 3 1 14 Interoperability with OMG Data Distribution Service Based Systems 1 4 1 2 Features of RTI Message Service cceceecsssseseseesesssssesesessssssesesesssesssesesssesesesssesesesescsens 1 4 13 JMS Contormianice nsession sisas eiie hace aAa EEEE EEEE Ae Eea NE Raa iaai 1 6 1 4 Understanding and Navigating the Documentation s sssseessssssrtssssesttssssesttsssestssseestes 1 6 2 Installation and Setup 2 1 Installing RTI Message Service on UNIX Based Systems eseeeeseeseereesessessessssesesse 2 1 2 2 Installing RTI Message Service on Windows Systems eeerrseseerrserseersseasseseessesesess 2 2 2 3 License Managemen booe orre enaena aena oe ae E LSe E E E EES Oaa EA SEREA a 2 3 23 1 fmstallme a License Filesssssseianir ann e e Wh e aia 2 3 2 3 2 Adding or Removing License Management ereeseeserereesesessessssssassssasssess 2 4 Tutorial 3 1 Simple Tutorial Hello World iss irsssii ide ic eile agad asa aa Wace eei chee 3 2 3 1 1 Inspect the Files nor Sarens o a eagair ah sc Again ha iti usw roic ae easa E 3 2 3 1 2 set Up the Environments sssusa heen ahat eesi ah 3 2 3 1 3 Build and Run the Applications ssssesrsseserstssssestesstesstrsnsesstsnteesteteesntenteesneenten 3 3 3 1 4 Understanding the Cod sse tsss seans nedya N A setetven 3 6 3 2 Advanced Tutorial Market Data ccccccccccccsscsssecssceesecesssessecesseceeseessceeseesseeesseceee
2. J Whitepapers and other articles are available from http www rti com resources QWOIIOM L Chapter 2 Installation and Setup 2 1 This chapter describes how to install RTI Message Service The basic steps are 1 Unpack and install RTI Message Service from the distribution file RTI Message Ser vice is included with RTI Connext Messaging If you want to install RTI Message Service independently of RTI Connext Messaging this chapter describes how to extract the RTI Message Service distribution If the distribution you downloaded is license managed this is the case for all free evaluation downloads you will have to install the license file as described in this document This includes setting the required environment variables and installing the license file Make sure that you have the correct Java SDK installed on your system The Java SDK used to build the RTI Message Service Java libraries is listed in the Release Notes If you want to use the Durable Producer History or Durable Consumer State fea tures you will also need to install a relational database See Chapter 5 Installing a Database Optional RTI Message Service is designed to have all its files under a single tree All directory loca tions in this guide are meant as suggestions only adjust them to suit your site You do not need administrator privileges to install RTI Message Service Installing RTI Message Service on UNIX Based Systems
3. java 2 If you ve chosen to place the tutorial code inside a package or you are running the shipped tutorial code which is in the com rti jms example stock package you will need to start the JVM from the root of the package directory hierarchy and include the fully qualified name of the class like this gt java com rti jms example stock StockPricePublisher 0 Advanced Tutorial Market Data Test Requirement II Now we will test our Requirement II changes with the following scenario which has a StockPrice publishing application sending at the default rate of every 4 seconds and a StockPrice subscribing application that requires a minimum separation between mes sages of 15 seconds 5 Open two command prompt windows 6 In the first command prompt window start the StockPricePublisher gt java StockPricePublisher 0 reuters 7 In the second command prompt window start StockPriceSubscriber using the Guest service level gt java StockPriceSubscriber 0 guest 8 Verify that the StockPriceSubscriber is reading messages every 15 seconds even though the Publisher is sending messages every 4 seconds StockPrice subscriber sleeping for 4 sec Received Symbol RTII Price 32 70 Updated By reuters Time Mon Aug 11 11 45 51 PDT 2008 StockPrice subscriber sleeping for 4 sec StockPrice subscriber sleeping for 4 sec StockPrice subscriber sleeping for 4 sec StockPrice subscriber sleeping for 4 sec R
4. lt topic gt 3 30 Advanced Tutorial Market Data 5 Open StockPriceSubscriber java 6 Override the QoS for the MessageConsumer as follows public static void main String args throws Exception int messageCount 0 if args length gt 1 messageCount Integer valueOf args 0 intValue String service_level guest if args length gt 2 service_level args 1 Properties prop new Properties prop setProperty Context PROVIDER_URL ExampleQosConfig xml if guest equals service_level Guest service level prop setProperty RTIContext QOS_FIELD PREFIX 3 stock Example Stock Price consumer_defaults time _based_filter minimum_separation sec 15 prop setProperty RTIContext QOS_FIELD PREFIX stock Example Stock Price consumer_defaults deadline period sec nos else Premium service level prop setProperty RTIContext QOS_FIELD PREFIX 3 stock Example Stock Price consumer_defaults time _based_filter minimum_separation sec A prop setProperty RTIContext QOS_FIELD PREFIX stock Example Stock Price consumer_defaults deadline period sec wg8 InitialContext ctx new InitialContext prop 3 31 Tutorial 3 2 2 4 1 Test Requirement I 3 32 Testing the StockPrice Applications Now we will compile and run the applications Note the classpath and other environ ment variable settings described above for the s
5. 1 Create a directory for RTI Message Service We will assume that you want to install under opt rti you may replace refer ences to opt rti with the directory of your choice 2 1 UOHDI D SU Z Installation and Setup 2 2 2 2 cd opt mkdir rti cd rti Note If you have the same versions of RTI Data Distribution Service and RTI Mes sage Service they should be installed into the same directory so you will end up with one directory ndds 5 0 x that contains the files for both products You do not need to be logged in as root during installation Note If you are sharing a drive between your UNIX and Windows systems you can install all the files in the same tree Move the downloaded file into your newly created directory In these example instructions we assume your distribution file is named RTI_Message_Service 5 0 x i86Linux2 6gcc4 1 1jdk tar gz This is just an example your filename will be different Use tar to extract the distribution For example tar xvzf RTI_Message_Service 5 0 x i86Linux2 6gcc4 1 1jdk tar gz Using our example path you will end up with opt rti ndds 5 0 x Set the environment variables as described in Section 3 1 2 Install your license as described in License Management Section 2 3 Finally we recommend running the example applications described in Chapter 3 Tutorial Installing RTI Message Service on Windows Systems 1 Create a directory to hold t
6. RTIJMSHOME license dat As RTI Message Service attempts to locate and read your license file you may depend ing on the terms of the license see a printed message with details about your license If the license file cannot be found or the license has expired your application may be unable to initialize RTI Message Service depending on the terms of the license If that is the case your application s call to ConnectionFactory createConnection will return null preventing communication Adding or Removing License Management If you are using an RTI software distribution that requires a license file in order to oper ate and your license file changes for example you receive a new license for a longer term than your original license you do not need to reinstall RTI Message Service However if you decide to migrate from a license managed distribution of RTI Message Service to one of the same version that does not require license management or visa versa RTI recommends that you first uninstall your original distribution before install ing your new distribution Doing so will prevent you from inadvertently using a mix ture of libraries from multiple installations Chapter 3 Tutorial This chapter will teach you with hands on examples how to write your first RTI Mes sage Service applications It s divided into two parts I A simple Hello World example gets you compiling and running your code as quickly as possible I
7. Received Text Hello World Received Text Hello World Received Text Hello World 3 5 Ipuoin c Tutorial 3 1 4 3 2 Advanced 3 6 7 Stop both applications Understanding the Code Now that you ve successfully compiled and run the code take this opportunity to inspect the source files and configuration file to better understand what they do The comments in each file explain the logic and configuration there step by step The next tutorial which is more involved than this one will also explain many of these concepts in more detail Once you have completed both tutorials you will be ready to continue reading with the User s Manual Advanced Tutorial Market Data This tutorial uses a simple market data application to illustrate the mechanics of using RTI Message Service to build a distributed application with specific data delivery require ments The example s requirements illustrate the basics of how to implement these common use cases I Reliable delivery to late joining subscribers J Minimum separation to control how quickly messages are received L Seamless failover to a backup publisher In Design Phase Section 3 2 1 we ll describe the basic requirements of our example application map out the structure of the data to be published and decide what Topics to use Then we ll list the required network related behavior and see which Quality of Service QoS parameters to chang
8. below if you choose not to set it simply expand the variable as you type b Update your path Add RTI Data Message Service s scripts directory to your path This will allow you to run some of the simple command line utilities included in your distribution with out typing the full path to the executable On UNIX based systems Add the scripts directory to your PATH environment vari able Simple Tutorial Hello World On Windows systems Add the scripts directory to your Path environment variable Make sure Java is available Make sure that a supported version of the JDK is on your path The Release Notes list the Java versions that are supported On Linux systems Note that GNU java from the GNU Classpath project is not sup ported and will typically not work but is on the path by default on many Linux systems Update your class path The following jar files must be on the class path e RTIJMSHOME class rtijms jar e RTIJMSHOME class nddsjava jar Also make sure that your Java installation includes Java Enterprise Edition EE Java Standard Edition SE does not ship with the javaee jar file that contains the definitions of the JMS standard interfaces that RTI Message Service requires This file can be found in the lib directory of your Java EE installation Make sure the native libraries are available Make sure that your application can load the RTI Message Distribution Service native librarie
9. class path you should also have nddsjava jar you should not have nddsjavad jar on your class path Java Libraries Required to Run Description File Name release File Name debug RTI Message Service API rtijms jar rtijmsd jar Core messaging engine nddsjava jar nddsjavad jar Java Enterprise Edition 1 5 or 1 6 j2eejar or javaee jar a RTI Message Service will not build against an installation of Java Standard Edition SE because the javaee jar file which contains the JMS APIs on which it depends is not included in that edition That jar file can be found in your Java EE installation b The name of this jar file may vary depending on the version of Java EE you have installed You can modify the class path on the command line of the java virtual machine VM or by modifying the CLASSPATH environment variable Native Libraries RTI Message Service depends on a number of native libraries to provide the high perfor mance and strict determinism RTI customers require RTI provides libraries in both debug and release formats and recommends that you use one or the other consistently do not use the release version of some libraries and the debug version of others The release and debug Java libraries documented above will Running Your Application 4 2 2 1 Table 4 3 attempt to load the corresponding versions release or debug of the native libraries on which they depend Native Libraries o
10. deadline period by which a producer must publish new messages The Deadline QoS Policy has a value of infinite The deadline offered by the producer cannot be greater than the deadline requested by the consumer For the producer we will use a deadline of 8 seconds For the consumer we will use a different deadline for each service level e Guest Level deadline 30 seconds e Premium Level deadline 8 seconds For our example we ll set the above deadlines in both the Stock Price Publisher and Subscriber applications 3 13 Ipuoin c Tutorial 3 2 1 4 3 2 2 3 2 2 1 3 14 Summary The example s requirements summarized below illustrate how to achieve these com mon use cases Use Case Requirement in Stock Example Related QoS Policies Late joining subscribers I Late Joiners Need Last Price and Last 20 News Messages Durability History Reliability Minimum separation to control how quickly messages are received II Service Level Controls How Often Stock Prices are Received Time Based Filter Seamless failover to a backup publisher Ill Stock Price From the Most Trusted Publisher Service Level Determines the Deadline Ownership Ownership Strength Deadline Implementing the Design The exercises show you how to create the example application from scratch Your com pleted code should match the source code provided with your RTI Mes
11. out printin Sending Stock News count count instance writeUTF RTII stock ticker symbol instance writeUTF http www rti com stock news URL instance writeUTF reuters updated by instance writeLong System currentTimeMillis date producer send instance Prepare message for reuse then pause for four seconds before sending again instance clearBody Thread sleep sendPeriodMillis Close down communication finally if conn null conn close 2 Next add the following bold blue lines to ExampleQosConfig xml lt jms gt 1 Define a library to store the managed object i e ConnectionFactory and Topic configurations All managed object A i are stored in libraries lt library name stock gt 2 Add a simple configuration for the ConnectionFactory that is used in the code to creation the MessageProducer and MessageConsumer lt connection_factory name connectionFactory gt lt connection_factory gt 3 Define the Example Stock News topic and prepare a placeholder for configuring the QoS of producers to that topic lt topic name Example Stock News gt lt producer_defaults gt lt TO DO QoS policies will be filled in later gt lt producer_defaults gt 3 17 Tutorial lt topic gt lt library gt lt jms gt 3 2 2 2 2 StockNews Subscriber 1 Make the following changes in StockNewsSubscriber java import ja
12. simple we will create 4 separate applications LL Stock News Publisher LL Stock News Subscriber LL Stock Price Publisher LL Stock Price Subscriber 3 2 1 2 3 8 StockNews Publisher App StockPrice Publisher App StockPrice Ea u Subscriber App Global Data Space StockNews Subscriber App Designing Data Structures and Topics The first step in designing an RTI Message Service application is to consider the structure of your data For our example we ll use the predefined JMS BytesMessages type to effi ciently represent the following data When designing your own applications consider your data types carefully the design has a significant impact on the performance of the distributed application To preserve network bandwidth applications should send no more data than is required For exam 1 See http java sun com javaee 5 docs api javax jms BytesMessage html Advanced Tutorial Market Data Table 3 1 Table 3 2 3 2 1 3 Stock News Type Description String Stock ticker symbol String Stock news URL String Updated by long Updated date Stock Price Type Description String Stock ticker symbol double Stock price String Updated by long Updated date ple while we could combine the data pertaining to Stock Price and Stock News in every message that would imply that we want to send stock news with every update to the
13. 1n i Time new Date bytes readLong catch JMSException jx Svstem err println Error reading message jx printStackTrace else System out printin message 1 conn start 5 Wait for messages to arrive final long receivePeriodSec 4 for int count 0 messageCount 0 count lt messageCount count System out print1n Stock Price subscriber sleeping for receivePeriodSec gec Thread sleep receivePeriodSec 1000 in msec 6 Close down communication finally if conn null conn close 2 Open ExampleQosConfig xml and add another topic as follows lt topic name Example Stock Price gt lt Prepare a placeholder for configuring the QoS of consumers of that topic gt lt consumer_defaults gt lt TO DO QoS policies will be filled in later gt lt consumer_defaults gt lt topic gt 3 23 Tutorial 3 2 2 3 Implement the Requirements in StockNews In Design Phase Section 3 2 1 we identified the specific behavior we want in the appli cation Now we ll change the basic code you wrote previously and fill in the configu ration file to implement each requirement Table 3 3 summarizes how the requirements map to QoS Policies in the StockNews application Table 3 3 Mapping Requirements to QoS in StockNews Publisher Requirement Messages I Late Joiners Need Last 20 News Stock
14. News Publisher StockNews Subscriber MessageProducer MessageConsumer Changes Changes producer s reliability kind consumer s reliability kind RELIABLE RELIABLE producer s history depth consumer s history depth 20 20 producer s durability kind TRANSIENT_LOCAL consumer s durability kind TRANSIENT_LOCAL II Service Level Controls How Determines Deadline Often Stock Prices are Received aa nochange III Stock Price from the Most Trusted Publisher Service Level no changes no changes 1 Open ExampleQosConfig xml and set the MessageProducer QoS parameters to as listed in Table 3 3 lt topic name 1 Example Stock News gt lt producer_defaults gt lt reliability gt lt kind gt RELIABLE_ RELIABILITY QOS lt kind gt lt reliability gt lt history gt lt depth gt 20 lt depth gt lt history gt lt durability gt lt kind gt TRANSIENT LOCAL DURABILITY _QOS lt kind gt lt durability gt lt producer_defaults gt lt topic gt 3 24 Advanced Tutorial Market Data 2 Make the required MessageConsumer QoS changes listed in Table 3 3 to keep com patibility between the publisher and subscriber QoS policies lt topic name Example Stock News gt lt consumer_defaults gt lt reliability gt lt kind gt RELIABLE_ RELIABILITY QOS lt kind gt lt reliability gt lt history gt lt depth gt 20 lt depth gt lt history gt lt durability gt lt
15. RTI Message Service Getting Started Guide Version 5 0 t j Your systems Working as one 2008 2012 Real Time Innovations Inc All rights reserved Printed in U S A First printing August 2012 Trademarks Real Time Innovations RTI and Connext are trademarks or registered trademarks of Real Time Innovations Inc All other trademarks used in this document are the property of their respective owners Copy and Use Restrictions No part of this publication may be reproduced stored in a retrieval system or transmitted in any form including electronic mechanical photocopy and facsimile without the prior written permission of Real Time Innovations Inc The software described in this document is furnished under and subject to the RTI software license agreement The software may be used or copied only under the terms of the license agreement Technical Support Real Time Innovations Inc 232 E Java Drive Sunnyvale CA 94089 Phone 408 990 7444 Email support rti com Website https support rti com Contents 1 Welcome to RTI Message Service 1 1 Benefits of RTT Message Service cscccc sissies pecesncsessesstnaneseetsrneneiststeensaastonersentutterseonatins 1 2 1 1 1 Reduced Risk Through Industry Leading Performance and Availability 1 2 1 1 2 Reduced Cost through Ease of Use and Simplified Deployment eeeeeeee 1 3 1 1 3 Unmatched Power and Flexibility to Meet Unique Requirements
16. SRTIJMSHOME class rtijms jar CLASSPATH gt export CLASSPATH lt Java EE install dir gt lib javaee jar CLASSPATH gt export CLASSPATH SCLASSPATH Also you must ensure that your Java installation includes Java Enterprise Edi tion EE Java Standard Edition SE does not ship with the javaee jar file that contains the definitions of the JMS standard interfaces that RTI Message Service requires 2 Use the Java compiler javac to compile gt javac java 3 Add an additional library to your class path On Windows systems gt set CLASSPATH SRTIJMSHOME class nddsjava jar CLASSPATHS On UNIX Linux systems exact syntax depends on your shell gt export CLASSPATH S RTIJMSHOME class nddsjava jar CLASSPATH If you have not already done so as part of your installation you must also add the native libraries required by RTI Message Service to your Path on Windows or LD_LIBRARY_PATH on UNIX Linux environment variable replace lt arch gt with your architecture On Windows systems gt set Path SRTIJMSHOME 1ib lt arch gt Path e g gt set Path RTIJMSHOME lib i86Win32jdk Path 1 If you ve chosen to place the tutorial code inside a package or you are compiling the shipped tutorial code which is in the com rti jms example stock package you will need to run the javac compiler from the root of the package directory hierarchy and include the fully qualified name of the class like this g
17. age you will need to start the JVM from the root of the package directory hierarchy and include the fully qualified name of the class like this gt java com rti jms example stock StockNewsPublisher 0 3 27 Ipuoin c Tutorial 3 2 2 4 Table 3 4 3 28 Update Time d By reuters Mon Aug 11 10 17 39 PDT 2008 7 Stop both applications Implement the Requirements in StockPrice In Design Phase Section 3 2 1 we identified the specific behavior we want in the appli cation Now we ll change the basic code you wrote as well as the configuration file to implement each requirement Table 3 4 summarizes how the requirements map to QoS Policies in the StockPrice applications Mapping Requireme nts to QoS in StockPrice Publisher Requirement StockPrice Publisher MessageProducer Changes StockPrice Subscriber MessageConsumer Changes I Late Joiners Need Last Price producer s reliability kind RELIABLE consumer s reliability kind RELIABLE producer s durability kind TRANSIENT_LOCAL consumer s durability kind TRANSIENT_LOCAL II Service Level Con trols How Often Stock Prices are Received no changes in Price Publisher Guest consumer s time based filter mini mum separation 15 sec Premium consumer s time based filter mini mum separation 4 sec III Stock Price from Most Trusted Pub lisher Service Level Determines Deadline
18. age Service should deliver only the most recent value of an instance attempt to deliver all intermediate values or do something in between The History QoS Policy s depth field specifies the number of messages to be kept By default RTI Message Service only keeps the last message depth 1 To change the behavior so that the last 20 messages are saved for late joining subscribers we ll change the History QoS s depth field to 20 in the Stock News Publisher Advanced Tutorial Market Data Since we only need to keep the last stock price we can use the default depth 1 in the Stock Price Publisher and Subscriber I Durability Qos The Durability QoS Policy controls whether or not and how published mes sages are stored for subscribing applications that are found after the messages were initially sent late joiners A consumer uses this QoS Policy to request mes sages that were published before the consumer was created These are known as historical messages By default RTI Message Service does not need to keep any messages for possible delivery to future subscribers These are the possible settings for this QoS e VOLATILE default RTI Message Service will not deliver any messages to MessageConsumers that are discovered after the messages were initially published e TRANSIENT LOCAL RTI Message Service will store and send previously published messages for delivery to newly discovered MessageConsumers The H
19. ails Understanding and Navigating the Documentation L RTI Example Performance Test This recommended download includes example code and configuration files for testing and optimizing the performance of a sim ple RTI Message Service based application on your system The program will test both throughput and latency under a wide variety of middleware configura tions It also includes documentation on tuning the middleware and the underly ing operating system To download this test first log into your self service support portal as described above Click Find Solution in the menu bar at the top of the page then click Per formance under All Solutions in the resulting page Finally click on or search for Example Performance Test to download the test You can also review the data from several performance benchmarks here http www rti com products jms latency throughput benchmarks html LJ Java Message Service JMS API Documentation RTI Message Service APIs are compliant with the JMS specification This specification is a part of the broader Java Enterprise Edition Java EE product from Sun Microsystems Java EE 5 is documented at http java sun com javaee 5 docs api In particular see the javax jms package J Java Standard Edition API Documentation Java EE is an extension to and relies on types imported from the Java Standard Edition Java SE product Java SE 6 is documented online at http java sun com javase 6 docs api
20. ake of brevity they are not repeated here 1 Use the Java compiler javac to compile gt javac java First we will test our Requirement I changes with the following scenario which starts a StockPrice publishing application waits until at least one message has been sent then starts a StockPrice subscribing application you ll see that the late joining subscriber gets the last published message 2 Start StockPricePublisher gt java StockPricePublisher 0 You should see the StockPrice publisher start and then display the following output on the console Sending Stock Price count 0 Sending Stock Price count 1 Sending Stock Price count 2 3 After you see a few messages of StockPrice published on the console start the StockPrice subscriber from a different command prompt gt java StockPriceSubscriber 0 You should see the subscribing application start and then retrieve and publish the last stock price message that the producer published Received Symbol RTII Price 32 50 Updated By Message Board Time Mon Aug 11 11 38 53 PDT 2008 4 Stop both applications 1 If you ve chosen to place the tutorial code inside a package or you are compiling the shipped tutorial code which is in the com rti jms example stock package you will need to run the javac compiler from the root of the package directory hierarchy and include the fully qualified name of the class like this gt javac com rti jms example stock
21. ally RTI Message Service provides fine grained control over fail over among publishers as well as detailed status notifications to allow applications to detect missed delivery deadlines dropped connections and other potential failure conditions See Chapter 6 Fault Tolerance in the Configuration and Operation Manual for more information about these capabilities Reduced Cost through Ease of Use and Simplified Deployment L Increased developer productivity Easy to use well understood JMS APIs get developers productive quickly Take an opportunity to go through the tutorial in the Getting Started Guide if you haven t already Outside of the product docu mentation itself a wide array of third party JMS resources exist on the web and on the shelves of your local book store I Simplified deployment Because RTI Message Service consists only of dynamic libraries you don t need to configure or manage server machines or processes That translates into faster turnaround and lower overhead for your team L Reduced hardware costs Some traditional messaging products require you to purchase specialized acceleration hardware in order to achieve high perfor mance The extreme efficiency and reduced overhead of RTI s implementation on the other hand allows you to see strong performance even on commodity hardware Unmatched Power and Flexibility to Meet Unique Requirements When you need it RTI provides a high degree of fine grained l
22. ce to only use shared memory Modify the ExampleQosConfig xml file as follows lt connection_factory name helloConnectionFactory gt lt transport_builtin gt lt mask gt TRANSPORTBUILTIN_SHMEM lt mask gt lt transport_builtin gt lt discovery gt lt initial_peers gt lt element gt shmem lt element gt lt initial_peers gt lt multicast_receive_addresses gt lt multicast_receive_addresses gt lt discovery gt lt connection_factory gt 1 Make sure the following JAR files are on the class path they can be found in the RTIJMSHOME class directory of your installation On Windows systems gt set CLASSPATH RTIJMSHOMES class rtijms jar CLASSPATH S gt set CLASSPATH lt Java EE install dir gt lib javaee jar 3CLASSPATH gt set CLASSPATH 3CLASSPATH On UNIX Linux systems exact syntax depends on your shell gt export CLASSPATH SRTIJMSHOME class rtijms jar CLASSPATH gt export CLASSPATH lt Java EE install dir gt lib javaee jar CLASSPATH gt export CLASSPATH SCLASSPATH Also you must ensure that your Java installation includes Java Enterprise Edi tion EE Java Standard Edition SE does not ship with the javaee jar file that contains the definitions of the JMS standard interfaces that RTI Message Service requires 2 Use the Java compiler javac to compile Go to the RTIJMSHOME example JMS directory and enter gt javac com rti jms example hello java 3 4 S
23. createBytesMessage final long sendPeriodMillis 4 1000 4 seconds for int count 0 messageCount 0 count lt messageCount count System out println Sending Stock Price count count instance writeUTF RTII stock ticker symbol instance writeDouble 32 0 0 1 count stock price instance writeUTF price_provider updated by date time instance writeLong System currentTimeMillis producer send instance 6 Prepare message for reuse then pause for four seconds before sending again instance clearBody Thread sleep sendPeriodMillis 7 Close down communication finally if conn null conn close 2 Open ExampleQosConfig xml and add another topic as follows lt library name stock gt lt Define the Example Stock Price topic and prepare a placeholder for configuring gt lt the QoS of producers to that topic gt lt topic name Example Stock Price lt producer_defaults gt lt TO DO QoS policies will be filled in later gt lt producer_defaults gt lt topic gt lt library gt 3 2 Tutorial 3 2 2 2 4 StockPrice Subscriber 1 Make the following changes in StockPriceSubscriber java import java util import javax jms import javax naming Context import com rti naming public class StockPriceSubscriber public static void main String args throws Exception 1 Get number of me
24. divided this documentation into several parts L Release Notes Provides system level requirements and other platform specific information about the product Those responsible for installing RTI Message Service should read this document first I Getting Started Guide Describes how to download and install RTI Message Ser vice It also lays out the core value and concepts behind the product and takes you step by step through the creation of a simple example application Develop ers should read this document first L User s Manual Describes the features of the product their purpose and value and how to use them It is aimed at developers who are responsible for imple menting the functional requirements of a distributed system and is organized around the structure of the JMS APIs and certain common high level scenarios E Configuration and Operation Manual Provides lower level more in depth configuration information and focuses on system level concerns It is aimed at engineers who are responsible for configuring optimizing and administering RTI Message Service based distributed systems Many readers will also want to consult additional documentation available online In particular RTI recommends the following LJ RTI Self Service Portal http www rti com support Select the Find Solution link to see sample code general information on RTI Message Service performance information troubleshooting tips and other technical det
25. e to implement those behaviors In the final sections we ll walk through the hands on process of creating and running the applications You will see how to modify the code to implement each required behavior l The exercises show how to create the example application from scratch I Your completed code should match the source code provided with your RTI Mes sage Service installation in RTIJMSHOME example JMS Advanced Tutorial Market Data 3 2 1 3 2 1 1 In this tutorial you will learn how to L Design the Topics and keys to use for the example Analyze the example s communication requirements and map them to QoS Poli cies LI Write a configuration file to specify these policies L Write code to supply hypothetical data to be passed from publisher to subscriber This tutorial will not cover all the concepts of RTI Message Service The User s Manual covers all the middleware topics in detail Design Phase This chapter describes the example stock application with particular focus on the struc ture of the data to be published as well as the Quality of Service QoS parameters that will be used to implement the application s communications requirements We ll also introduce some important RTI terms such as keys instances and Topics This chapter includes the following sections l Example Stock Application Section 3 2 1 1 L Designing Data Structures and Topics Section 3 2 1 2 LI Selecting Qualit
26. eceived Symbol RTII Price 33 10 Updated By reuters Time Mon Aug 11 11 46 07 PDT 2008 StockPrice subscriber sleeping for 4 sec StockPrice subscriber sleeping for 4 sec StockPrice subscriber sleeping for 4 sec StockPrice subscriber sleeping for 4 sec Received Symbol RTII Price 33 50 Updated By reuters Time Mon Aug 11 11 46 23 PDT 2008 9 Stop both applications 3 33 Ipuoin c Tutorial Test Now we will test our Requirement III changes by starting a StockPrice subscribing Requirement IIT application and two StockPrice publishing applications with different strengths You will see the subscriber get data only from the stronger publisher then the stronger pub lisher will quit and messages from the weaker publisher will be used instead 10 11 12 13 14 15 16 3 34 Open three separate command prompts In the first command prompt start StockPricePublisher with an additional argument the strength 100 gt java StockPricePublisher 0 reuters 100 In the second command prompt start StockPricePublisher with prwire as the stock price source and strength 10 gt java StockPricePublisher 0 prwire 10 In the third command prompt Start StockPriceSubscriber gt java StockPriceSubscriber 0 premium Verify that StockPriceSubscriber is reporting data from reuters since it has the higher strength Received Symbol RTII Price 32 50 Updated By re
27. eet a wide range of timeliness reliability fault tolerance and resource usage related goals This chapter introduces the basic concepts within the middleware and summarizes how RTI Message Service addresses the needs of high performance systems It also describes the documentation resources available to you and provides a road map for navigating them Specifically this chapter includes L Benefits of RTI Message Service Section 1 1 l Features of RTI Message Service Section 1 2 LJ JMS Conformance Section 1 3 LI Understanding and Navigating the Documentation Section 1 4 QWOIIOM L 1 1 Benefits of RTI Message Service RTI Message Service is publish subscribe networking middleware for high performance distributed applications It implements the Java Message Service JMS specification but it is not just another MOM message oriented middleware Its unique peer to peer architecture and targeted high performance and real time capabilities extend the speci fication to provide unmatched value Reduced Risk Through Industry Leading Performance and Availability RTI Message Service provides industry leading performance whether measured in terms of latency throughput or real time determinism One contributor to this superior per formance is RTI s unique architecture which is entirely peer to peer Traditional messaging middleware implementations require dedicated servers to broker message flows crippling application p
28. er Message if args length gt 2 price_provider args 1 Board Default provider 3 29 Tutorial int ownership strength 0 if args length gt 3 ownership strength Integer valueOf args 2 intValue Properties prop new Properties prop setProperty Context PROVIDER_URL ExampleQosConfig xml1 prop setProperty RTIContext QOS FIELD PREFIX stock Example Stock Price producer_defaults ownership _strength value String valueOf ownership strength InitialContext ctx new InitialContext prop 4 Return to ExampleQosConfig xml and update the consumer configuration lt topic name Example Stock Price gt lt consumer_defaults gt lt reliability gt lt kind gt RELIABLE_RELIABILITY_ QOS lt kind gt lt reliability gt lt history gt lt depth gt 1 lt depth gt lt history gt lt durability gt lt kind gt TRANSIENT LOCAL DURABILITY QOS lt kind gt lt durability gt lt ownership gt lt kind gt EXCLUSIVE_OWNERSHIP_QOS lt kind gt lt ownership gt lt time_based_filter gt lt minimum_separation gt lt Will be overridden in code gt lt sec gt 0 lt sec gt lt nanosec gt 0 lt nanosec gt lt minimum_separation gt lt time_based_filter gt lt deadline gt lt period gt lt Will be overridden in code gt lt sec gt 8 lt sec gt lt nanosec gt 0 lt nanosec gt lt period gt lt deadline gt lt consumer_defaults gt
29. erformance increasing latency and introducing time non determinism These brokers increase system administration costs and can rep resent single points of failure within a distributed application putting data reliability and availability at risk RTI eliminates broker overhead by allowing messages to flow directly from a publisher to each of its subscribers in a strictly peer to peer fashion At the same time it provides a variety of powerful capabilities to ensure high availability Messaging Messaging Application Application Traditional message oriented middleware implementations require a broker to forward every message increasing latency and decreasing determinism and fault tolerance RTI s unique peer to peer architecture eliminates bottlenecks and single points of failure Redundancy and high availability can optionally be layered onto the peer to peer data fabric by transparently inserting instances of RTI Persistence Service These instances can distribute the load across topics and can also be arbitrarily redundant to provide the level of data availability your application requires See Chapter 7 Scalable High Per formance Applications Durability and Persistence for High Availability in the User s Manual for more information about this capability Benefits of RTI Message Service Publishers and subscribers can enter and leave the network at any time and the middle ware will connect and disconnect them automatic
30. es The service level command line parameter will determine the minimum_separation value of the Stock Price Subscriber e Guest Level 15 seconds e Premium Level 4 seconds In either case the networking code remains the same The Time Based Filter QoS Policy is only set on the MessageConsumer so no changes are needed in the Stock Price Publisher 3 2 1 3 3 Requirement Ill Stock Price From the Most Trusted Publisher 3 12 We want the Stock Price Subscriber application to get updates from the most trusted source If that source disappears for some reason then data from the next most trusted source will be delivered to all the subscribing applications To meet this requirement we will change the following QoS policies in the Stock Price Publisher and Stock Price Subscriber applications L Ownership QoS Policy The Ownership QoS Policy specifies whether multiple producers can update the same instance By default a subscribing application can receive messages from multiple pro ducers That is the data instance is shared among all its producers there is no exclusive owner The kind field in the Ownership QoS Policy can be either e SHARED default In effect there is no owner The subscribing appli cation will receive modifications from all producers e EXCLUSIVE The producer with the highest ownership strength is con sidered the exclusive owner Only messages from the owner are passed on to the c
31. eseeeeneenes 3 6 32 1 Design Phase wasnt aceite a EE RENE E R gais oes 3 7 3 2 2 Implementing the Design cccccsessscesesssesescsesesesesescscsssesesescsessseseecsesesssneeeeenes 3 14 Building and Running Applications 4 1 Building Your Applications e ia h aa a Eae 4 1 42 Running Your Applicaon ssnipe aiea ae a a p ar Ga AREAS 4 2 421 Java Libraries oeseosirnio i ainen A E a iaa a iaaea eia aiioa Et 4 2 A AAN EED EA E 01 S E Tee EA E E E EE EENEI 4 2 423 Running on Linux GC Jeet a aan eieaa a easa dahsh Sh sa dhaideo a hesshaiiiy 4 4 Installing a Database Optional 5 1 Creating a Data Source for MYSQL aksies are Ea aE E a Ea ENESE e aE 5 2 Sled Linux Solaris Systems sn pmonnnanun a a a i 5 2 Di 12 WINGOW S Systems iieis a enee E AERE EE E eA EE E aE AEE EERS 5 3 Chapter 1 Welcome to RTI Message Service Welcome to RTI Message Service the highest performing JMS compliant messaging system in the world RTI Message Service makes it easy to develop deploy and maintain distributed applications Its core messaging technology has been proven in hundreds of unique designs for life and mission critical applications across a variety of industries providing LL ultra low latency and extremely high throughput I with industry leading latency determinism I across heterogeneous systems spanning thousands of applications Its extensive set of real time quality of service parameters allows you to fine tune your application to m
32. he installation such as c rti Note If you have the same versions of RTI Data Distribution Service and RTI Mes sage Service they should be installed into the same directory so you will end up with one directory such as ndds 5 0 x that contains the files for both products Unzip the downloaded file to extract their contents into the installation directory The extraction program will create and populate the required subdirectories You will need a ZIP file program such as WinZip Using our example path you will end up with c rti ndds 5 0 x 3 Set the environment variables described below License Management 2 3 2 3 1 e Set RTISMSHOME to the RTI Message Service installation directory such as c rti ndds 5 0 x e Add RTI Message Service s scripts directory to your Path RTIJMSHOME scripts e Add RTI Message Service s lib directory for your target architecture to your Path such as RTIJMSHOME lib lt architecture gt the last part of the path depends on your target architecture such as i86Win32jdk If your distribution of RTI Message Service is license managed this is the case for all free evaluations your next step is to install your license as described in License Manage ment Section 2 3 Finally we recommend running the example applications described in Chapter 3 Tutorial License Management Some distributions of RTI Message Service require a license file in order to run for exam
33. imple Tutorial Hello World 3 Add the nddsjava jar library to your class path if you have not already done so On Windows systems gt set CLASSPATH SRTIJMSHOME class nddsjava jar CLASSPATHS On UNIX Linux systems the exact syntax depends on your shell gt export CLASSPATH SRTIJMSHOME class nddsjava jar CLASSPATH If you have not already done so as part of your installation you must also add the native libraries required by RTI Message Service to your Path on Windows systems or LD_LIBRARY_PATH on UNIX Linux systems environment vari able In the following examples replace lt arch gt with your architecture On Windows systems gt set Path SRTIUMSHOME 1ib lt arch gt Paths e g gt set Path RTIJMSHOME lib i86Win32jdk Path On UNIX Linux Systems exact syntax depends on your shell gt export LD_LIBRARY_PATH RTIJMSHOME 1lib lt arch gt LD_LIBRARY_PATH eg gt export LD_LIBRARY_PATH gt SRTIJMSHOME 1ib i86Linux2 6gcc4 1 1jdk LD_LIBRARY_PATH Start HelloWorldPublisher gt java com rti jms example hello HelloWorldPublisher Verify that the HelloWorldPublisher starts and that it displays the following output on the console Sending count 0 Sending count 1 Sending count 2 Open anew command prompt Start the HelloWorldSubscriber gt java com rti jms example hello HelloWorldSubscriber You should see the subscribing application start
34. istory QoS Policy determines exactly how many messages are saved or delivered see below To change the behavior so that already sent messages are saved we ll change the Durability QoS s kind field to TRANSIENT_LOCAL We must make this change in all four applications Stock News Publisher and Sub scriber Stock Price Publisher and Subscriber e TRANSIENT PERSISTENT RTI Message Service will store sent messages in a database external to the publishing process itself These levels of durability require one or more instances of the RTI Persistence Service on your net work 3 2 1 3 2 Requirement Il Service Level Controls How Often Stock Prices are Received When you start the Stock Price Subscriber application with the Guest service level you will get stock price updates every 15 seconds When you start the application with the Premium service level you will get stock price updates every 4 seconds To meet this requirement we will change the following QoS policy in the Stock Price Subscriber application Ipuoin c Tutorial L Time Based Filter QoS Policy The Time Based Filter QoS Policy allows you to specify that a consumer does not want to receive more than one message during each minimum_separation time period regardless of how fast producers are sending new messages This QoS Policy only applies to consumers not producers By default RTI Message Service does not impose any minimum separation time between messag
35. kind gt TRANSIENT LOCAL DURABILITY QOS lt kind gt lt durability gt lt consumer_defaults gt lt topic gt 3 Save your changes 3 2 2 3 1 Testing the StockNews Applications Now we will compile and run the applications I You need to know the name of your target architecture look in your RTIJM SHOME lib directory Use it in place of lt arch gt in the commands below For example your architecture might be i86Win32jdk I If you are on a Windows system and your computer is not connected to a net work you must configure RTI Message Service to only use shared memory For example lt connection_factory name connectionFactory gt lt transport_builtin gt lt mask gt TRANSPORTBUILTIN_SHMEM lt mask gt lt transport_builtin gt lt discovery gt lt initial_peers gt lt element gt shmem lt element gt lt initial_peers gt lt multicast_receive_addresses gt lt multicast_receive_addresses gt lt discovery gt lt connection_factory gt 3 25 Ipuoin c Tutorial 1 Make sure the following JAR files are on the class path they can be found in the RTIJMSHOME class directory of your installation On Windows systems gt set CLASSPATH SRTIJMSHOMES class rtijms jar CLASSPATH S gt set CLASSPATH lt Java EE install dir gt lib javaee jar 3CLASSPATH gt set CLASSPATH 3CLASSPATHS On UNIX Linux systems exact syntax depends on your shell gt export CLASSPATH
36. main String args throws Exception 1 Get number of messages to send from command line 0 means publish indefinitely int messageCount 0 if args length gt 1 messageCount Integer valueOf args 0 intValue 2 Get price provider from command line If none is specified assume the default _ Message Board This string will be used for filling in the updated by field String price_provider Message Board Default provider if args length gt 2 price_provider args 1 3 Initialize administered objects from XML file the code won t run until we fill in that file Use properties to programmatically override QoS values that were loaded from the file Properties prop new Properties prop setProperty Context PROVIDER_URL ExampleQosConfig xml1 InitialContext ctx new InitialContext prop 4 Look up administered ConnectionFactory from file Use the factory to create _ the other entities ConnectionFactory factory ConnectionFactory ctx lookup stock connectionFactory Connection conn factory createConnection try Session session conn createSession false Session DUPS_OK_ACKNOWLEDGE Topic topic Topic ctx lookup stock Example Stock Price MessageProducer producer session createProducer topic conn start 3 20 Advanced Tutorial Market Data 5 Send messages filling in hypothetical data BytesMessage instance session
37. ms Native Libraries Required to Run on Linux Systems Description File Name release File Name debug libnddsc so libnddscd so Core messaging engine libnddscore so libnddscored so libnddsjava so libnddsjavad so To use these libraries add them to your LD_LIBRARY_PATH environment variable Running on Linux GCJ Some Linux distributions include the GNU Compiler for Java GCJ by default and place the java and javac executables on the path where they can be picked up in prefer ence to a JDK from Sun Microsystems RTI does not test or support this configuration the Sun JDK with Java EE is the recommended Java distribution If you experience errors while building or running the tutorial and you see the string gcj in the output you are likely encountering this configuration To resolve it make sure that the directories containing your Sun JDK binaries appear before those contain ing the GCJ binaries in your PATH environment variable or start the java and javac binaries using their full paths Chapter 5 Installing a Database Optional This chapter only applies if you want to use the Durable Producer History and or Durable Consumer State features For more information about these features see the 6 chapter on Durability and Persistence for High Availability in the User s Manual Advanced Durable Producer History This feature allows a MessageProducer to locally persist its local history cache so tha
38. n Windows Systems The native libraries in Table 4 3 are required on Windows systems Native Libraries Required to Run on Windows Systems Description File Name release File Name debug nddsc dll nddscd dll Core messaging engine nddscore dll nddscored dll nddsjava dll nddsjavad dll To use these libraries add them to your Path environment variable Visual Studio 2005 Service Pack 1 Requirement When running on Windows you must have Visual Studio 2005 Service Pack 1 or the Microsoft Visual C 2005 SP1 Redistribution Package installed on the machine where you are running your application The Microsoft Visual C 2005 SP1 Redistribution Package can be downloaded from RTI s Self Service Portal or obtained from the following Microsoft website e For x86 architectures http www microsoft com downloads details aspx fami lyid 200B2FD9 AE1A 4A14 984D 389C36F85647 amp displaylang en e For x64 architectures http www microsoft com downloads details aspx Fami lyID EB4EBE2D 33C0 4A47 9DD4 B9 A6D7BD44DA amp displaylang en 1 On the portal select the Downloads page The Redistribution Package is in the section labeled Win dows Target Libraries for RTI Message Service 4 3 Gulu ung pup Buipliing 7 Building and Running Applications 4 2 2 2 Table 4 4 4 2 3 4 4 Native Libraries on Linux Systems The native libraries in Table 4 4 are required on Linux syste
39. n communicate transparently with each other regardless of the underlying operating system or hardware Consult the Release Notes to see which platforms are supported in this release Vendor neutrality and standards compliance The RTI Message Service API complies with the JMS specification Unlike other JMS implementations it also supports a wire protocol that is open and standards based the Real Time Publish Subscribe RTPS protocol specification from the Object Management Group OMG which extends the International Engineering Consortium s IEC s publicly available RTPS specification This protocol also enables interoperability between RTI Message Service and RTI Data Distribution Service and between various DDS implementations See Interoperability with OMG Data Distribution Service Based Systems Section 1 1 4 QWOIIOM L 1 3 JMS Conformance RTI Message Service is a high performance messaging platform for demanding applica tions including applications with real time requirements Not all portions of the JMS specification are relevant or appropriate for this domain and some required features are not included in the specification For more information about JMS conformance includ ing both limitations and significant extensions see Appendix A JMS Conformance in the User s Manual 1 4 Understanding and Navigating the Documentation To get you from your download to running software as quickly as possible we have
40. nclud ing embedded hardware running real time operating systems For more information consult your RTI account representative If you are already an RTI Data Distribution Ser vice user and are interested in DDS JMS interoperability consult the Interoperability Guide that accompanies this documentation Features of RTI Message Service Under the hood RTI Message Service goes beyond the basic JMS publish subscribe model to target the needs of applications with high performance real time and or low overhead requirements and provide the following L Peer to peer publish subscribe communications Simplifies distributed applica tion programming and provides time critical data flow with minimal latency e Clear semantics for managing multiple sources of the same data e Efficient data transfer customizable Quality of Service and error notifica tion e Guaranteed periodic messages with minimum and maximum rates set by subscriptions including notifications when applications fail to meet their deadlines e Synchronous or asynchronous message delivery to allow applications con trol over the degree of concurrency e Ability to send the same message to multiple subscribers efficiently including support for reliable multicast with customizable levels of posi tive and negative message acknowledgement Features of RTI Message Service L Reliable messaging Enables subscribing applications to not only specify reli able delive
41. nd StockPrice messages and add command line parameters for the service level Guest or Premium data source and strength When we are done adding the command line parameters the syntax for the applica tions will be StockNewsPublisher messages StockNewsSubscriber messages StockPricePublisher messages provider strength StockPriceSubscriber messages guest premium The first parameter is included in every application L messages In the publishing application this is the number of messages to publish before terminating In the subscribing application this is the number of 4 second intervals for which it will sleep awake before terminating In both applications a value of 0 means an infinite number of messages Default 0 infi nite 3 15 Ipuoin c Tutorial We will add the following parameters for our example I provider You can enter any string here it will be displayed in the updated by field Default Message Board L strength The OwnershipStrength QoS for the StockPrice Publisher Default 0 Valid range 0 to 1 million I guest premium This is the service level For simplicity in this example we have not provided any error checking or allowance for mixed upper lower case Default guest 3 2 2 2 1 StockNews Publisher Changes to the example code are shown in bold blue 1 Make the following changes in StockNewsPublisher java Note If you copy paste the above code you ma
42. olicies Let s look at the specific OoS changes needed for our application Requirement I Late Joiners Need Last Price and Last 20 News Messages When the Stock News Subscriber application starts up we want it to receive the last 20 news items When the Stock Price Subscriber application starts up we want it to receive the last price To meet this requirement we will change the following QoS policies in the Stock News Publisher and Subscriber applications I Reliability QoS Policy The Reliability QoS Policy determines whether or not a producer s data will be reliably delivered by RTI Message Service to matching consumers By default RTI Message Service is configured for best effort delivery for the low est possible latency and the greatest possible determinism The kind field in the Reliability QoS Policy can be either e BEST_EFFORT RTI Message Service will send messages only once to Mes sageConsumers No effort or resources are spent to track whether or not sent messages are received Messages may be lost e RELIABLE RTI Message Service will send messages reliably buffering pub lished messages until they have been acknowledged by the consumers and resending any messages that may have been lost during transport To ensure that messages are delivered reliably in our example we ll change the Reliability QoS s kind field to RELIABLE LJ History QoS Policy The History QoS Policy controls whether RTI Mess
43. onsumers The owner of an instance can change dynamically Advanced Tutorial Market Data To ensure that messages are from the single most trusted source we ll change the Ownership QoS s kind field to EXCLUSIVE Both the Stock Price Publisher and Stock Price Subscriber applications must use the same settings for the Ownership QoS Policy so we must make this change in both applications I Ownership Strength QoS Policy You can use the Ownership Strength QoS Policy to indicate which producer has the highest strength When the Ownership QoS Policy is set to EXCLUSIVE the producer with the highest strength owns the instance By default all producers have equal strength 0 Rather than hard code a strength value we ll use a command line parameter This will allow us to start multiple copies of the publishing application with var ious strengths Since this QoS Policy only applies to producers we will only need to make this change in the Stock Price Publisher application Deadline QoS Policy For a producer the Deadline QoS Policy sets the maximum amount of time that may pass between sending new messages That is the producer is offering to send new messages within this deadline period For a consumer the Deadline QoS Policy sets the maximum amount of time that is acceptable between receipt of new messages That is the consumer is request ing that messages are received by this deadline period By default there is no
44. ormance than the synchronous method used above for Hello World 3 1 Ipuoin c Tutorial 3 1 3 1 1 3 2 If you encounter problems building or running the applications you create in these tuto rials please consult Chapter 4 Building and Running Applications in this guide or the Release Notes Simple Tutorial Hello World In this simple application a publisher repeatedly writes the string Hello World to any number of identical subscribers We ll start with the completed code that is included in your RTI Message Service distribution Inspect the Files Start by examining the files and folders included in this example Change to the RTIJMSHOME example JMS directory In that directory you should see the configuration file ExampleQosConfig xml You should also see a com directory which is the root of the package com rti jms exam ple hello That package directory includes the Java source files HelloWorldPub lisher java and HelloWorldSubscriber java The example JMS directory also contains source packages for other example programs you can ignore them for now Set Up the Environment There are a few things to take care of before you start working with the example code a Set the RTIJMSHOME environment variable Set the environment variable RTIJMSHOME to the RTI Message Distribution Service installation directory such as opt rti ndds 5 0 x This step is optional but this vari able is used
45. ow level control over the operation of the middleware including but not limited to LJ The volume of meta traffic sent to assure reliability l The frequencies and timeouts associated with all events within the middleware L The amount of memory consumed including the policies under which addi tional memory may be allocated by the middleware These quality of service QoS policies can be specified in configuration files so that they can be tested and validated independently of the application logic When they are not specified the middleware will use default values chosen to provide good perfor mance for a wide range of applications For specific information about the parameters available to you consult the Configura tion and Operation Manual QWOIIOM L 1 2 Interoperability with OMG Data Distribution Service Based Systems The Data Distribution Service DDS specification from the Object Management Group OMG has become the standard for real time data distribution and publish subscribe messaging for high performance real time systems especially in the aerospace and defense industries RTI Message Service is the only JMS implementation to directly inter operate at the wire protocol level with RTI Data Distribution Service the leading DDS implementation RTI Data Distribution Service is available not only in Java but also in several other man aged and unmanaged languages It is supported on a wide variety of platforms i
46. ple those provided for evaluation purposes or on a subscription basis A single license file can be used to run on any architecture and is not node locked You are not required to run a license server Installing a License File If your distribution of RTI Message Service requires a license file you will receive one from RTI via email If you did not receive one please email support rti com or contact your RTI account representative Save the license file in any location of your choice the locations checked by the middle ware are listed below these locations may be on a drive mounted from another machine if you wish If you have licenses for both RTI Message Service and RTI Data Distribution Service you can concatenate both into the same file If your distribution of RTI Message Service is license managed the software will not operate without a properly installed license file Each time your RTI Message Service application starts will look for the license file in the following locations until it finds a valid license 1 In your application s current working directory in a file called license dat 2 3 uoUDIIDISuI Z Installation and Setup 2 3 2 2 4 2 In the location specified in the environment variable RTI LICENSE FILE which you may set to point to the full path of the license file including the file name for example C RTI my_license_file dat 3 In the RTI Message Service installation in the file
47. producer s ownership kind EXCLUSIVE consumer s ownership kind EXCLUSIVE producer s ownership strength set via command line producer s deadline period 8 sec Guest consumer s deadline period 30 sec Premium consumer s deadline period 10 sec Advanced Tutorial Market Data Changes to the code are shown in bold blue 1 Open ExampleQosConfig xml Configure the producer QoS as follows lt topic name Example Stock Price gt lt producer_defaults gt lt reliability gt lt kind gt RELIABLE_RELIABILITY_QOS lt kind gt lt reliability gt lt history gt lt depth gt 1 lt depth gt lt history gt lt durability gt lt kind gt TRANSIENT_LOCAL DURABILITY_QOS lt kind gt lt durability gt lt ownership gt lt kind gt EXCLUSIVE_OWNERSHIP_QOS lt kind gt lt ownership gt lt ownership strength lt Will be overridden in code gt lt value gt 0 lt value gt omership strength lt deadline gt lt period gt lt sec gt 8 lt sec gt lt nanosec gt 0 lt nanosec gt lt period gt lt deadline gt lt producer_defaults gt lt topic gt 2 Open StockPricePublisher java 3 Override the ownership strength specified in the configuration file public static void main String args throws Exception int messageCount 0 if args length gt 1 messageCount Integer valueOf args 0 intValue String price_provid
48. ry The stored information describes each data source in detail specifying the driver name a description and any additional information the driver needs to connect to the data source To add a data source named Example follow these steps 1 Open the ODBC Data Source Administrator e On Windows 2000 systems choose Start Control Panel Performance and Maintenance Administrative Tools Data Sources ODBC e On Windows XP systems choose Start Settings Control Panel Adminis trative Tools Data Sources ODBC Select the System DSN tab Click Add the Create New Data Source dialog appears Select the MySQL driver from the list of drivers Click Finish the MySQL ODBC Driver Configuration dialog appears Fill in the fields in the dialog a Enter Example as the Data Source Name DSN DA mg w NV b Enter a valid username as the user and a valid password as the password c Select a database for example test d All other fields can be left empty 7 Click OK 5 3 espapipa D BuillDISul G Installing a Database Optional 5 4
49. ry of messages but to customize the degree of reliability required Data flows can be configured for 1 guaranteed delivery at any cost at one extreme 2 the lowest possible latency and highest possible determinism even if it means that some messages will be lost at the other extreme or 3 many points in between J Multiple communication networks Multiple independent communication net works domains each using RTI Message Service can be used over the same phys ical network to isolate unrelated systems and subsystems Individual applications can be configured to participate in one or multiple domains L Symmetric architecture Makes your application robust e No central server or privileged nodes so the system is robust to applica tion and or node failures e Topics subscriptions and publications can be dynamically added and removed from the system at any time Multiple network transports RTI Message Service includes support for UDP IP v4 and v6 including for example Ethernet wireless and Infiniband networks and shared memory transports It also includes the ability to dynamically plug in support for addi tional network transports and route messages over them It can optionally be config ured to operate over a variety of transport mechanisms including backplanes switched fabrics and other networking technologies Multi platform and heterogeneous system support Applications based on RTI Message Service ca
50. s These libraries are in the directory RTIJMSHOME lib lt architecture gt where lt architecture gt may be i86Win32jdk i86Linux2 6gcc3 4 3jdk or another name in your lib directory The gcc part only present on UNIX based architectures identifies the corresponding native architecture that relies on the same version of the C runtime library e On UNIX based systems Add this directory to your LD_LIBRARY_PATH environment variable e On Windows systems Add this directory to your Path environment variable For more information about where Windows looks for dynamic libraries see http msdn microsoft com en us library ms682586 aspx Build and Run the Applications Now we will compile and run the applications If you have trouble with this section consult Chapter 4 Building and Running Applications it contains more detailed infor mation 3 3 Ipuoin c Tutorial I Both applications accept the same command line argument which is the number of messages to process before terminating A value of 0 means an infinite num ber of messages this is also the default if you specify nothing J You need to know the name of your target architecture look in your RTIJM SHOME lib directory Use it in place of lt arch gt in the commands below For example your architecture might be i86Win32jdk LL If you re running on a Windows system and your computer is not connected to a network you must configure RTI Message Servi
51. sage Service installation in RTIJMSHOME example JMS com rti jms example stock This section describes how to LI Create Files Section 3 2 2 1 J Publish and Subscribe to Data Section 3 2 2 2 m Implement the Requirements in StockNews Section 3 2 2 3 L Implement the Requirements in StockPrice Section 3 2 2 4 Create Files Start by creating the files and folders you ll need for this example 1 Create a new directory such as MyStockTutorial and change to that directory 2 Create the class StockNewsPublisher in the file Stock NewsPublisher java public class TODO StockNewsPublisher fill in later Advanced Tutorial Market Data 3 2 2 2 3 Create the class StockNewsSubscriber in the file StockNewsSubscriber java public class StockNewsSubscriber TODO fill in later 4 Create the class StockPricePublisher in the file StockPricePublisher java public class StockPricePublisher TODO fill in later 5 Create the class StockPriceSubscriber in the file StockPriceSubscriber java public class StockPriceSubscriber TODO fill in later 6 Create the XML configuration file ExampleQosConfig xml lt xml version 1 0 encoding UTF 8 gt lt jms gt lt TODO fill in later gt lt jms gt Publish and Subscribe to Data First we ll make code changes that are not strictly related to any single requirement These changes will supply example data for the StockNews a
52. ssages to expect from command line 0 means wait indefinitely int messageCount 0 if args length gt 1 messageCount Integer valueOf args 0 intValue 2 Initialize administered objects from XML file the code won t run until we fill in that file Use properties to programmatically override QoS values loaded from the file Properties prop new Properties prop setProperty Context PROVIDER_URL ExampleQosConfig xml InitialContext ctx new InitialContext prop 3 Look up administered ConnectionFactory from file Use the factory to create the other entities ConnectionFactory factory ConnectionFactory ctx lookup stock connectionFactory Connection conn factory createConnection try Session session conn createSession false Session DUPS_OK_ACKNOWLEDGE Topic topic Topic ctx lookup stock Example Stock Price MessageConsumer consumer session createConsumer topic 4 Set listener to handle received messages consumer setMessageListener new MessageListener public void onMessage Message message System out println Received message if message instanceof BytesMessage try BytesMessage bytes BytesMessage message System out print1n a Symbol bytes readUTF System out printf sa Price 1 2f n bytes readDouble System out print1n n Updated By bytes readUTF 3 22 Advanced Tutorial Market Data System out print
53. stock price This would not be desirable since we plan to send stock price updates every 4 seconds but only want to send stock news every 15 seconds At this point it is helpful to have a basic understanding of the term Topics A Topic has a unique name Applications can subscribe to a Topic and receive Messages For the publishing and subscribing applications to communicate they need to use the same topic We will define two topics Example Stock News and Example Stock Price which will use the Stock News and Stock Price messages described above Selecting Quality of Service QoS Parameters Quality of Service QoS policies allow you to control the behavior of application com munications QoS policies give you the flexibility to change the behavior of the distributed applica tion with zero or minimal code changes The QoS policies you choose are picked up from a configuration file when you start the application This allows you to test different QoS settings without even recompiling We ll see an example of this later in the tutorial Many QoS policies have to be set compatibly in both the publishing and subscribing applications Other QoS policies apply to one side only We will see examples of both cases 3 9 Ipuoin c Tutorial 3 2 1 3 1 3 10 For the sake of brevity we will not cover all the OoS policies in this document See the Configuration and Operation Manual for a detailed review of all the OoS p
54. t javac com rti jms example stock java 3 26 Advanced Tutorial Market Data Test Requirement I On UNIX Linux Systems exact syntax depends on your shell gt export LD_LIBRARY_PATH RTIJMSHOME 1lib lt arch gt LD_LIBRARY_PATH e g gt export LD_LIBRARY_PATH gt SRTIJMSHOME 1ib i86Linux2 6gcc4 1 1jdk LD_LIBRARY_PATH Now you re ready to run the StockNewsPublisher application gt java StockNewsPublisher 0 Verify that the StockNews publisher starts and that it displays the following output on the console Sending Stock News count 0 Sending Stock News count 1 Sending Stock News count 2 Sending Stock News count 20 Open anew command prompt After you see at least 20 messages of StockNews published in the first command console start the StockNews subscriber you must also make the environment variable changes described above in this new prompt gt java StockNewsSubscriber 0 You should see the subscribing application start and then retrieve and publish the last 20 messages that the producer published StockNews subscriber sleeping for 4 sec Received Symbol RTII URL http www rti com Updated By reuters Time Mon Aug 11 10 17 35 PDT 2008 Received Symbol RTII URL http www rti com If you ve chosen to place the tutorial code inside a package or you are running the shipped tutorial code which is in the com rti jms example stock pack
55. t does not discuss or configure quality of service QoS parameters it simply publishes and subscribes to simple text messages LI A more complex financial market data tutorial introduces you applications with richer functionality It includes multiple publishers and subscribers and uses a number of QoS parameters RTI recommends that you complete both of these tutorials The Hello World tutorial should be completed before reading further in the product documentation in order to get you minimally acquainted with the product and its use You may complete the mar ket data tutorial either immediately following the Hello World tutorial or later at your convenience You may notice that these two examples use different methods to receive messages I The Hello World example uses the synchronous receive method of the Mes sageConsumer in a loop This method is appropriate in cases like this one where simplicity is the overriding goal However because it requires memory alloca tion and a context switch this method is not appropriate for applications with the most demanding performance requirements L The market data example uses a MessageListener to receive messages asynchro nously This mechanism is more complex because it involves multiple threads However it requires no critical path memory allocation and the message is delivered in the same thread from which it was read from the network so it pro vides higher perf
56. t it can survive shutdowns crashes and restarts When an application restarts each MessageProducer that has been configured to have durable producer history automatically loads all the data in its history cache from disk and can carry on sending data as if it had never stopped execut ing To the rest of the system it will appear as if the MessageProducer was tem porarily disconnected from the network and then reappeared L Durable Consumer State This feature allows a MessageConsumer to locally per sists its state and remember the data it has already received When an applica tion restarts each MessageConsumer that has been configured to have durable consumer state automatically loads its state from disk and can carry on receiving data as if it had never stopped executing Data that was received by the Message Consumer before the restart will be suppressed so it is not sent over the net work To use either of these features you need a relational database such as MySQL We have tested the following driver L MySQL ODBC 5 0 45 To use MYSQL as the database you will need L MySQL 5 0 45 or higher The installation of MySQL is beyond the scope of this document Please refer to the MySQL Reference Manual for the process to install and configure MySQL espapipa D Burjjpysuy S 5 1 Installing a Database Optional m MySQL ODBC 3 51 driver The driver is not bundled with the MySQL server and must be installed sepa ra
57. tely The ODBC connector can be downloaded from http dev mysql com downloads connector odbc 3 51 html The installation guide can be found here http dev mysql com doc refman 5 0 en myodbc installation binary html J UnixODBC The MySQL ODBC driver requires an ODBC driver manager We recommend using UnixODBC a complete free open ODBC solution for Unix and Linux sys tems The driver manager can be downloaded from http www unixodbc org 5 1 Creating a Data Source for MySQL 5 1 1 Linux Solaris Systems RTI Message Service uses the MySQL ODBC driver to access data sources The connection information for each data source is stored in the odbc ini file The stored information describes each data source in detail specifying the driver name a description and any additional information the driver needs to connect to the data source To create the odbc ini file with a DSN named Example follow these steps 1 Create a new text file named odbc ini in your home directory 2 Insert these lines in the file ODBC Data Source Example MySQL Driver Example DRIVER usr lib libmyodbc3 so Database test 5 2 Creating a Data Source for MySQL Note Make sure that DRIVER points to the valid location of the MySQL ODBC driver on you system Windows Systems RTI Message Service uses the MySQL ODBC driver to access data sources The connection information for each data source is stored in the Windows regist
58. tion To compile an application that uses RTI Message Service the JAR files in Table 4 1 must be on the class path RTI provides libraries in both debug and release formats With respect to the API both are equivalent you may compile against whichever you prefer Java Libraries Required for Building Description File Name release File Name debug RTI Message Service API rtijms jar rtijmsd jar J2EE SDK 1 4 or Java EE SDK 5 j2eejar or javaeejar B a RTI Message Service will not build against an installation of Java Standard Edition SE because the javaee jar file which contains the JMS APIs on which it depends is not included in that edition That jar file can be found in your Java EE installation b The name of this jar file may vary depending on the version of Java EE you have installed 4 1 6uluuny pup 6uipiing y Building and Running Applications 4 2 4 2 1 Table 4 2 4 2 2 4 2 You can modify the class path on the command line of the javac compiler or modify the CLASSPATH environment variable Running Your Application RTI Message Service requires a number of Java and native libraries Java Libraries When running an application that uses RTI Message Service the JAR files in Table 4 2 must be on the class path RTI provides libraries in both debug and release formats and recommends that you use one or the other consistently For example if you have rtijms jar on your
59. ut printin 3 18 Advanced Tutorial Market Data a By bytes readUTF System out print1n Time new Date bytes readLong catch JMSException jx Svstem err println Error reading message jx printStackTrace else System out printlin message conn start 5 Wait for messages to arrive final long receivePeriodSec 4 for int count 0 messageCount 0 count lt messageCount count System out println Stock News subscriber sleeping for receivePeriodSec gec Thread sleep receivePeriodSec 1000 in millisec 6 Close down communication finally if conn null conn close 2 Next add the following to ExampleQosConfig xml lt library name stock gt 1 Reuse the same ConnectionFactory lt connection_factory name connectionFactory gt lt connection_factory gt lt topic name Example Stock News gt 2 Prepare a placeholder for configuring the QoS of consumers of that topic lt consumer_defaults gt lt TO DO QoS policies will be filled in later gt lt consumer_defaults gt lt topic gt lt library gt 3 19 Tutorial 3 2 2 2 3 StockPrice Publisher 1 Make the following changes in StockPricePublisher java import java util Properties import javax jms import javax naming Context import com rti naming public class StockPricePublisher public static void
60. uters Time Wed Mar 11 10 05 30 PDT 2009 Stock Price subscriber sleeping for 4 sec You may see data from prwire at first if it discovers that Publisher first Once both Publishers are discovered the higher strength reuters data will prevail Terminate the first StockPricePublisher from reuters with strength 100 by typing Ctr1 c Verify that after the Subscriber s deadline expires the subscriber seamlessly picks up the prwire source StockPrice subscriber sleeping for 4 sec Received Symbol RTII Price 37 00 Updated By reuters Time Tue Aug 12 09 22 53 PDT 2008 Advanced Tutorial Market Data StockPrice subscriber sleeping for 4 sec reuters publisher Sock Ease subscriber sleeping for 4 sec stops After the deadline Received the subscriber accepts Symbol RTII sa ar samples from prwire Price 36 10 Updated By prwire Time Tue Aug 12 09 23 01 PDT 2008 17 Stop the two remaining applications This completes the Tutorial 3 35 Ipuoin c Tutorial 3 36 Chapter 4 Building and Running Applications 4 1 Table 4 1 In the Tutorial chapter you learned how to build and run a sample application This chapter codifies the requirements which were summarized in the Tutorial for build ing and running applications This chapter is organized as follows 1 Building Your Application Section 4 1 LJ Running Your Application Section 4 2 Building Your Applica
61. va util import javax jms import javax naming Context import com rti naming InitialContext public class StockNewsSubscriber public static void main String args throws Exception 1 Get number of messages to expect from command line 0 means wait indefinitely int messageCount 0 if args length gt 1 messageCount Integer valueOf args 0 intValue 2 Initialize administered objects from XML file the code won t run until files is filled in Properties prop new Properties prop setProperty Context PROVIDER_URL ExampleQosConfig xml1 InitialContext ctx new InitialContext prop 3 Look up administered ConnectionFactory from file Use factory to create other entities ConnectionFactory factory ConnectionFactory ctx lookup stock connectionFactory Connection conn factory createConnection try Session session conn createSession false Session DUPS_OK_ACKNOWLEDGE Topic topic Topic ctx lookup stock Example Stock News MessageConsumer consumer session createConsumer topic 4 Set listener to handle received messages consumer setMessageListener new MessageListener public void onMessage Message message System out println Received message if message instanceof BytesMessage try BytesMessage bytes BytesMessage message System out printi1n m Symbol bytes readUTF System out printin eg URL bytes readUTF System o
62. y need to correct the quotation marks in your file import java util Properties import javax jms import javax naming Context import com rti naming InitialContext public class StockNewsPublisher public static void main String args throws Exception 1 Get number of messages to send from command line 0 means publish indefinitely int messageCount 0 if args length gt 1 messageCount Integer valueOf args 0 intValue 2 Initialize administered objects from XML file the code won t run until we fill in that file Properties prop new Properties prop setProperty Context PROVIDER_URL ExampleQosConfig xml InitialContext ctx new InitialContext prop 3 Look up administered ConnectionFactory from file Use the factory to create other entities ConnectionFactory factory ConnectionFactory ctx lookup stock connectionFactory Connection conn factory createConnection try Session session conn createSession false Session DUPS_OK_ACKNOWLEDGE Topic topic Topic ctx lookup stock Example Stock News 3 16 Advanced Tutorial Market Data MessageProducer producer session createProducer topic conn start 4 Send messages filling in hypothetical data BytesMessage instance session createBytesMessage final long sendPeriodMillis 4 1000 4 seconds for int count 0 messageCount 0 count lt messageCount count System
63. y of Service QoS Parameters Section 3 2 1 3 LI Summary Section 3 2 1 4 Example Stock Application We will use a stock application to illustrate some of the key concepts of RTI Message Ser vice The application will have publishers and subscribers exchanging data on stock news and stock prices Requirement I When you start the subscribing application you want to receive the last 20 news items for the stock and the most recent update for the stock price Requirement Il Like some real world stock applications we will have two levels of ser vice Guest and Premium The service level entered as a command line parameter will determine how often you get a stock price update l Guest Level Stock price updates every 15 seconds L Premium Level Stock price updates every 4 seconds Requirement Ill You only want to receive stock price updates from the most trusted source If that source disappears you want to automatically get data from the next 3 7 Ipuoin c Tutorial most trusted source We ll use the same service level guest or premium to determine how long to wait before switching to the next most trusted source that is the deadline for hearing from the most trusted source To keep the example focused on the middleware logic we will not cover other aspects of building the application such as user authentication the user interface or acquiring news and stock data from a database To keep things

Download Pdf Manuals

image

Related Search

Related Contents

Manuel caractéristiques et entretien FB7B  comprende Sistema di chiodi tibiali Sistema di  Bedienungsanleitung  残さいフィルターの掃除  Istruzioni d`Uso - Amazon Web Services  DX MMZ-02 ムニュムニュズバーーン 取扱説明書  MR-J2-JR Servomotors and Amplifiers  Heißpressvorrichtung PF-101  Origin Storage Dell Desktop series HD kit  logFaces User Manual  

Copyright © All rights reserved.
Failed to retrieve file