<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright, Real-Time Innovations, Inc. 2001. All rights reserved.
   No duplications, whole or partial, manual or electronic, may be made without
   prior written permission. Any such copies, or revisions thereof, must display
   this notice unaltered. This code contains trade secrets of Real-Time Innovations,
   Inc. -->

<!-- ================================================================== -->
<!-- RTI Queuing Service configuration XML Schema -->
<!-- ================================================================== -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   elementFormDefault="qualified" attributeFormDefault="unqualified">


    <xs:include schemaLocation="definitions/rti_dds_qos_profiles_definitions.xsd"/>
    <xs:include schemaLocation="definitions/rti_dist_logger_definitions.xsd"/>
    <xs:include schemaLocation="definitions/rti_dds_topic_types_definitions.xsd"/>

   <!-- ================================================================== -->
   <!-- Main Elements -->
   <!-- ================================================================== -->

   <xs:element name="dds">
      <xs:annotation>
         <xs:documentation>
            Configuration of RTI Connext and RTI Queuing Service
         </xs:documentation>
      </xs:annotation>
      <xs:complexType>
         <xs:sequence>
            <!-- Definitions used by Queuing Service -->
            <xs:choice minOccurs="0" maxOccurs="unbounded">
               <!-- Type definitions -->
               <xs:element name="types">
                  <xs:annotation>
                     <xs:documentation>
                        Defines types that can be used by RTI Queuing Service
                     </xs:documentation>
                  </xs:annotation>
                  <xs:complexType>
                     <xs:group ref="moduleElements" />
                  </xs:complexType>
               </xs:element>
               <!-- QoS definitions -->
               <xs:element name="qos_library" type="qosLibrary">
                  <xs:annotation>
                     <xs:documentation>
                        Specifies a QoS library and  profiles. The  contents of this tag are specified in the same manner as for an [NDDS] QoS profile file
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>
               <!-- Queuing service configuration(s) -->
            <xs:element ref="queuing_service" minOccurs="1" maxOccurs="unbounded" />
            </xs:choice>
         </xs:sequence>
         <xs:attribute name="version" type="xs:string"/>
      </xs:complexType>
   </xs:element>


   <xs:element name="queuing_service">
      <xs:annotation>
         <xs:documentation>
            Configuration for RTI Queuing Service
         </xs:documentation>
      </xs:annotation>
      <xs:complexType>
          <xs:sequence>
             <xs:element name="administration"
                          minOccurs="0" maxOccurs="1"
                          type="administrationType">
                <xs:annotation>
                      <xs:documentation>
                          Remote access configuration.
                      </xs:documentation>
                   </xs:annotation>
             </xs:element>

             <xs:element name="monitoring" type="monitoringType" minOccurs="0" maxOccurs="1" />

             <xs:element name="statistics" type="statisticsType" minOccurs="0" maxOccurs="1" />

             <xs:element name="persistence_settings"
                         type="persistenceSettings"
                         minOccurs="0" maxOccurs="1"/>

              <xs:element name="replication_settings"
                         type="replicationSettingsType"
                         minOccurs="0" maxOccurs="1"/>

              <xs:element name="service_qos"
                         type="serviceQosType"
                         minOccurs="0" maxOccurs="1"/>

             <xs:element name="domain_participant"
                          minOccurs="1"
                          maxOccurs="unbounded">
                <xs:annotation>
                      <xs:documentation>
                          The settings for the DDS Domain Participant used in a QueuingService.
                      </xs:documentation>
                   </xs:annotation>
                   <xs:complexType>
                     <xs:choice maxOccurs="unbounded">
                        <xs:element name="domain_id" minOccurs="1" type="xs:integer">
                           <xs:annotation>
                                 <xs:documentation>
                                    The DDS Domain ID used by the RTI Queuing Service instance
                                 </xs:documentation>
                           </xs:annotation>
                        </xs:element>
                        <xs:element name="domain_participant_qos"
                                 minOccurs="0"
                                 type="domainParticipantQosProfileChild">
                              <xs:annotation>
                                 <xs:documentation>
                                    The QoS setting for the RTI Queuing Service Domain Participant.
                                 </xs:documentation>
                              </xs:annotation>
                        </xs:element>
                        <xs:element name="participant_qos"
                                 minOccurs="0"
                                 type="domainParticipantQosProfileChild">
                              <xs:annotation>
                                 <xs:documentation>
                                    The QoS setting for the RTI Queuing Service Domain Participant

                                    The participant_qos tag has been deprecated, in favor of the
                                    standard domain_participant_qos tag. Please use
                                    domain_participant_qos instead.
                                 </xs:documentation>
                              </xs:annotation>
                        </xs:element>
                        <xs:element name="memory_management"
                                 type="sampleMemoryManagement"
                                 minOccurs="0" maxOccurs="1"/>

                        <xs:element name="shared_subscriber"
                                 minOccurs="0" maxOccurs="unbounded" type="sharedSubscriberType" />
                     </xs:choice>
                      <xs:attributeGroup ref="entityNameAttrGroup">
                          <xs:annotation>
                              <xs:documentation xml:lang="en-US">
                                <![CDATA[
                                Name of this DomainParticipant configuration
                                ]]>
                              </xs:documentation>
                          </xs:annotation>
                      </xs:attributeGroup>
                   </xs:complexType>
             </xs:element>
          </xs:sequence>

          <xs:attributeGroup ref="entityNameAttrGroup">
              <xs:annotation>
                  <xs:documentation xml:lang="en-US">
                    <![CDATA[
                    Name of this Queuing Service configuration.
                    ]]>
                  </xs:documentation>
              </xs:annotation>
          </xs:attributeGroup>
      </xs:complexType>
   </xs:element>

   <xs:complexType name="administrationType">
       <xs:choice maxOccurs="unbounded">
           <xs:element name="domain_id"
                       type="xs:integer"
                       minOccurs="1" maxOccurs="1"/>
           <xs:element name="distributed_logger"
              type="distributedLogger"
              minOccurs="0" maxOccurs="1">
              <xs:annotation>
                  <xs:documentation>
                      Configuration settings for Distributed Logger.
                  </xs:documentation>
              </xs:annotation>
           </xs:element>
           <xs:element name="domain_participant_qos"
                       type="domainParticipantQosProfileChild"
                       minOccurs="0"
                       maxOccurs="1"/>
           <xs:element name="participant_qos"
                       type="domainParticipantQosProfileChild"
                       minOccurs="0"
                       maxOccurs="1">
                  <xs:annotation>
                     <xs:documentation>
                        The participant_qos tag has been deprecated, in favor of the
                        standard domain_participant_qos tag. Please use
                        domain_participant_qos instead.
                     </xs:documentation>
                  </xs:annotation>
            </xs:element>
           <xs:element name="publisher_qos"
                       type="publisherQosProfileChild"
                       minOccurs="0" maxOccurs="1"/>
           <xs:element name="subscriber_qos"
                       type="subscriberQosProfileChild"
                       minOccurs="0" maxOccurs="1"/>
           <xs:element name="datareader_qos"
                       type="dataReaderQosProfileChild"
                       minOccurs="0" maxOccurs="1"/>
           <xs:element name="datawriter_qos"
                       type="dataWriterQosProfileChild"
                       minOccurs="0" maxOccurs="1"/>
           <xs:element name="memory_management"
                       type="sampleMemoryManagement"
                       minOccurs="0" maxOccurs="1"/>
       </xs:choice>
   </xs:complexType>

    <xs:complexType name="historical_statistics">
      <xs:annotation>
        <xs:documentation>
          Use this tag to enable or disable the publication of
          statistics calculated within fixed time windows
        </xs:documentation>
      </xs:annotation>
        <xs:all>
          <xs:element name="five_second" type="statistics_window"
            minOccurs="0" maxOccurs="1" />
          <xs:element name="one_minute" type="statistics_window"
            minOccurs="0" maxOccurs="1" />
          <xs:element name="five_minute" type="statistics_window"
            minOccurs="0" maxOccurs="1" />
          <xs:element name="one_hour" type="statistics_window"
            minOccurs="0" maxOccurs="1" />
          <xs:element name="up_time" type="statistics_window"
            minOccurs="0" maxOccurs="1" />
        </xs:all>
    </xs:complexType>

    <xs:simpleType name="statistics_window">
      <xs:restriction base="xs:boolean">
          <xs:annotation>
        <xs:documentation>
            Enable the publication of statistics calculated in this
            time window
        </xs:documentation>
          </xs:annotation>
      </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="monitoringType">
      <xs:annotation>
          <xs:documentation>
        Configuration of the publication of entity status and statistics
          </xs:documentation>
      </xs:annotation>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="enabled" default="true" type="xs:boolean"
              minOccurs="0" maxOccurs="1"/>
        <xs:element name="domain_id" type="xs:integer"
              minOccurs="1" maxOccurs="1"/>
        <xs:element name="status_publication_period" type="duration"
              minOccurs="0" maxOccurs="1" >
              <xs:annotation>
                <xs:documentation>
                  Specify the frequency the status of this entity is published.
                  Set it to infinite to disable it.
                </xs:documentation>
              </xs:annotation>
        </xs:element>
        <xs:element name="domain_participant_qos"
                    type="domainParticipantQosProfileChild"
                    minOccurs="0"
                    maxOccurs="1"/>
        <xs:element name="participant_qos"
                    type="domainParticipantQosProfileChild"
                    minOccurs="0"
                    maxOccurs="1">
              <xs:annotation>
                 <xs:documentation>
                    The participant_qos tag has been deprecated, in favor of the
                    standard domain_participant_qos tag. Please use
                    domain_participant_qos instead.
                 </xs:documentation>
              </xs:annotation>
        </xs:element>
        <xs:element name="publisher_qos" type="publisherQosProfileChild"
          minOccurs="0" maxOccurs="1" />
        <xs:element name="datawriter_qos" type="dataWriterQosProfileChild"
          minOccurs="0" maxOccurs="1" />
      </xs:choice>
    </xs:complexType>

    <xs:complexType name="statisticsType">
      <xs:annotation>
        <xs:documentation>
          Configuration of the publication of entity status and statistics
        </xs:documentation>
      </xs:annotation>
      <xs:all>
        <xs:element name="statistics_sampling_period"
          minOccurs="0" maxOccurs="1" type="duration">
          <xs:annotation>
            <xs:documentation>
              Period in which the current averages are retreived
              and used for the calculation of the statistics. A smaller
              period will give more accurante historical statistics but
              a higher use of resources.
            </xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="historical_statistics" minOccurs="0"
          maxOccurs="1" type="historical_statistics" />
      </xs:all>
    </xs:complexType>


    <xs:complexType name="entity_monitoring">
      <xs:annotation>
        <xs:documentation>
          Override monitoring general configuration for this specific entity
        </xs:documentation>
      </xs:annotation>
      <xs:all>
        <xs:element name="enabled" default="true" type="xs:boolean"
          minOccurs="0" maxOccurs="1" />
        <xs:element name="status_publication_period"
          minOccurs="0" maxOccurs="1" type="duration"/>
      </xs:all>
    </xs:complexType>

    <xs:complexType name="persistenceSettings">
      <xs:annotation>
        <xs:documentation>
            Storage kind for the service and storage settings for persistent queues
        </xs:documentation>
      </xs:annotation>
      <xs:all>
        <xs:element name="filesystem" type="filesystemSettings" minOccurs="0" maxOccurs="1">
        </xs:element>
      </xs:all>
    </xs:complexType>

   <xs:complexType name="serviceQosType">
      <xs:annotation>
         <xs:documentation>
            Set the different QoS settings for the service.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="persistence" type="servicePersistencePolicyType" minOccurs="0" maxOccurs="1"/>
         <xs:element name="configuration_replication" type="adminReplicationType" minOccurs="0" maxOccurs="1"/>
         <xs:element name="shared_reader_queue_replication" type="replicationType" minOccurs="0" maxOccurs="1"/>
     </xs:all>
   </xs:complexType>

   <xs:complexType name="servicePersistencePolicyType">
     <xs:annotation>
      <xs:documentation>Sets the persistence settings for the service</xs:documentation>
     </xs:annotation>
     <xs:all>
      <xs:element name="kind" minOccurs="0" maxOccurs="1">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="PERSISTENT"/>
            <xs:enumeration value="VOLATILE"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="restore" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>If set to TRUE a persitent service will start from an existing database.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="TRUE"/>
            <xs:enumeration value="FALSE"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
     </xs:all>
   </xs:complexType>


  <xs:complexType name="filesystemSettings">
    <xs:annotation>
      <xs:documentation>
        Filesystem storage settings for persistent queues
      </xs:documentation>
    </xs:annotation>
    <xs:all>
      <xs:element name="directory" type="xs:string" minOccurs="0" maxOccurs="1">
          <xs:annotation>
              <xs:documentation>
                  The directory where the files to persist the data will be placed.
Default: current working directory
              </xs:documentation>
          </xs:annotation>
      </xs:element>
      <xs:element name="file_prefix" type="xs:string" minOccurs="0" maxOccurs="1" default="QS">
          <xs:annotation>
              <xs:documentation>
                  A prefix for all the files created by RTI Persistence Service.
Default: QS
              </xs:documentation>
          </xs:annotation>
      </xs:element>
      <xs:element name="synchronization" minOccurs="0" maxOccurs="1">
          <xs:annotation>
              <xs:documentation>
                  Determines the level of synchronization of the
                  data to store with the physical disk.
                  Default: OFF.
              </xs:documentation>
          </xs:annotation>
          <xs:simpleType>
              <xs:restriction base="xs:string">
                  <xs:enumeration value="FULL">
                      <xs:annotation>
                          <xs:documentation>
                              Every sample is written into physical disk as
                              RTI Persistence Service receives it
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="NORMAL">
                      <xs:annotation>
                          <xs:documentation>
                              Samples are written into physical disk at
                              critical moments
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="OFF">
                      <xs:annotation>
                          <xs:documentation>
                              No synchronization is enforced. Data will
                              be written to phyisical disk at the OS's
                              discretion
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
              </xs:restriction>
          </xs:simpleType>
      </xs:element>
      <xs:element name="journal_mode" minOccurs="0" maxOccurs="1">
          <xs:annotation>
              <xs:documentation>
                  Sets the journal mode.
                  Default: DELETE.
              </xs:documentation>
          </xs:annotation>
          <xs:simpleType>
              <xs:restriction base="xs:string">
                  <xs:enumeration value="DELETE">
                      <xs:annotation>
                          <xs:documentation>
                              The rollback journal is deleted at the conclusion
                              of each transaction.
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="TRUNCATE">
                      <xs:annotation>
                          <xs:documentation>
                              This mode commits transactions by truncating the
                              rollback journal to zero-length instead of deleting it.
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="PERSIST">
                      <xs:annotation>
                          <xs:documentation>
                              This mode prevents the rollback journal from being
                              deleted at the end of each transaction. Instead,
                              the header of the journal is overwritten with zeros.
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="MEMORY">
                      <xs:annotation>
                          <xs:documentation>
                              This mode stores the rollback journal in volatile RAM.
                              This saves disk I/O but at the expense of database
                              safety and integrity.
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="WAL">
                      <xs:annotation>
                          <xs:documentation>
                              The WAL journaling mode uses a write-ahead log instead
                              of a rollback journal to implement transactions.
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="OFF">
                      <xs:annotation>
                          <xs:documentation>
                              The OFF journaling mode disables the rollback journal
                              completely.
                              If the application crashes in the middle of a transaction
                              when the OFF journaling mode is set, then the files containing
                              the samples will very likely go corrupt.
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
              </xs:restriction>
          </xs:simpleType>
      </xs:element>
      <xs:element name="vacuum" minOccurs="0" maxOccurs="1">
          <xs:annotation>
              <xs:documentation>
                  Sets the auto-vacuum status of the storage.
                  Default: FULL.
              </xs:documentation>
          </xs:annotation>
          <xs:simpleType>
              <xs:restriction base="xs:string">
                  <xs:enumeration value="NONE">
                      <xs:annotation>
                          <xs:documentation>
                              When auto-vacuum is disabled and data is deleted from the storage files,
                              the files remain the same size.
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="FULL">
                      <xs:annotation>
                          <xs:documentation>
                              The storage files are compacted after every transaction.
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="INCREMENTAL">
                      <xs:annotation>
                          <xs:documentation>
                              &lt;NOT SUPPORTED&gt;
                          </xs:documentation>
                      </xs:annotation>
                  </xs:enumeration>
              </xs:restriction>
          </xs:simpleType>
      </xs:element>
      <xs:element name="trace_file" type="xs:string" minOccurs="0" maxOccurs="1">
          <xs:annotation>
              <xs:documentation>
                  Trace file for debug information.
                  Default: None
              </xs:documentation>
          </xs:annotation>
      </xs:element>
      <xs:element name="file_max_size" type="positiveIntegerUnlimited" minOccurs="0" maxOccurs="1">
      	  <xs:annotation>
              <xs:documentation>
                  The max size in kbytes for a persistence file (multiple files will be used if exceed)
                  Default: 1 GB  (one million kbytes)
              </xs:documentation>
          </xs:annotation>
      </xs:element>
  </xs:all>
  </xs:complexType>


   <xs:complexType name="sharedSubscriberType">
       <xs:annotation>
           <xs:documentation>
               The configuration for the RTI Queuing Service SharedSubscriber
           </xs:documentation>
       </xs:annotation>
       <xs:sequence>
           <xs:element name="session_settings" minOccurs="1"
                        maxOccurs="1" type="sessionSettingsType" />

           <xs:element name="publisher_qos" type="publisherQosProfileChild"
                        minOccurs="0" maxOccurs="1" />
           <xs:element name="subscriber_qos" type="subscriberQosProfileChild"
                        minOccurs="0" maxOccurs="1" />

           <xs:element name="dead_letter_shared_reader_queue"  type="deadLetterSharedReaderQueueType" minOccurs="0" maxOccurs="1" />

           <xs:element name="shared_reader_queue" minOccurs="0"
               maxOccurs="unbounded" type="sharedReaderQueueType" />
       </xs:sequence>

         <xs:attributeGroup ref="entityNameAttrGroup">
             <xs:annotation>
                 <xs:documentation xml:lang="en-US">
                    <![CDATA[
                    Name of this SharedSubscriber
                    ]]>
                 </xs:documentation>
             </xs:annotation>
         </xs:attributeGroup>
   </xs:complexType>

   <xs:complexType name="deadLetterSharedReaderQueueType">
      <xs:annotation>
         <xs:documentation>
         This element allows to configure a queue where the undelivered messages are sent
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="topic_name" minOccurs="1"
            maxOccurs="1" type="xs:string" >
            <xs:annotation>
               <xs:documentation>
               The topic name associated to a SharedReaderQueue
               </xs:documentation>
            </xs:annotation>
	     </xs:element>
         <xs:element name="datareader_qos" minOccurs="0"
            maxOccurs="1" type="dataReaderQosProfileChild" />
         <xs:element name="datawriter_qos" minOccurs="0"
            maxOccurs="1" type="dataWriterQosProfileChild" />
         <xs:element name="update_datareader_qos" minOccurs="0"
            maxOccurs="1" type="dataReaderQosProfileChild" />
         <xs:element name="update_datawriter_qos" minOccurs="0"
            maxOccurs="1" type="dataWriterQosProfileChild" />
         <xs:element name="master_election_datareader_qos" minOccurs="0"
            maxOccurs="1" type="dataReaderQosProfileChild" />
         <xs:element name="master_election_datawriter_qos" minOccurs="0"
            maxOccurs="1" type="dataWriterQosProfileChild" />
         <xs:element name="queue_qos" minOccurs="0"
            maxOccurs="1" type="queueQosType" />
      </xs:all>
      <xs:attribute name="name" type="resourceName"/>
      <xs:attribute name="session" type="elementReference"/>
   </xs:complexType>

   <xs:complexType name="sessionSettingsType">
      <xs:annotation>
         <xs:documentation>
            This element allows to define the session settings for a RTI Queuing Service instance.
         </xs:documentation>
      </xs:annotation>
      <xs:sequence>
         <xs:element name="session" type="sessionType" minOccurs="1"
            maxOccurs="unbounded"></xs:element>
      </xs:sequence>
   </xs:complexType>

   <xs:complexType name="sessionType">
      <xs:annotation>
         <xs:documentation>
            THis tag allows to define the different settings for a session
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="dequeue_period" minOccurs="0" maxOccurs="1"
            type="dequeuePeriodType" />
         <xs:element name="thread" minOccurs="0" maxOccurs="1"
            type="threadSettings">
            <xs:annotation>
               <xs:documentation>Thread settings for a certain session
               </xs:documentation>
            </xs:annotation>
         </xs:element>
      </xs:all>
      <xs:attribute name="name" type="xs:NCName"></xs:attribute>
   </xs:complexType>

   <xs:complexType name="dequeuePeriodType">
      <xs:annotation>
         <xs:documentation>
            Dequeue period for a certain session
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="sec" minOccurs="1" maxOccurs="1"
            type="xs:integer" />
         <xs:element name="nanosec" minOccurs="1" maxOccurs="1"
            type="xs:integer" />
      </xs:all>
   </xs:complexType>

   <xs:complexType name="masterTimeoutType">
      <xs:annotation>
         <xs:documentation>
            Slaves will search for the master if a timeout period elapsed since the last messages from the master was received.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="sec" minOccurs="1" maxOccurs="1"
            type="xs:integer" />
         <xs:element name="nanosec" minOccurs="1" maxOccurs="1"
            type="xs:integer" />
      </xs:all>
   </xs:complexType>

   <xs:complexType name="sampleTimeoutType">
      <xs:annotation>
         <xs:documentation>
            Timeout for messages enqueued without quorum.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="sec" minOccurs="1" maxOccurs="1"
            type="xs:integer" />
         <xs:element name="nanosec" minOccurs="1" maxOccurs="1"
            type="xs:integer" />
      </xs:all>
   </xs:complexType>

   <xs:complexType name="wait_set">
      <xs:annotation>
         <xs:documentation>
            Conditions and WaitSets provide another way for [NDDS] to communicate status changes (including the  arrival of data). While a Listener is used
            to provide a callback for synchronous access, Conditions and WaitSets provide asynchronous data access. In other words, Listeners
            are notification-based and Conditions are wait-based.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="max_event_count" minOccurs="1"
            maxOccurs="1" type="xs:positiveInteger" />
         <xs:element name="max_event_delay" minOccurs="1"
            maxOccurs="1" type="duration" />
         <xs:element name="timeout" minOccurs="0" maxOccurs="1"
            type="duration" />
      </xs:all>
   </xs:complexType>


   <xs:complexType name="sharedReaderQueueType">
      <xs:annotation>
         <xs:documentation>
            Shared Reader Queue configuration
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="entity_monitoring" minOccurs="0"
            maxOccurs="1" type="entity_monitoring"/>
         <xs:element name="entity_statistics" minOccurs="0"
            maxOccurs="1" type="statisticsType"/>

         <xs:element name="topic_name" minOccurs="1"
            maxOccurs="1" type="xs:string" >
            <xs:annotation>
               <xs:documentation>
               The topic name associated to a SharedReaderQueue
               </xs:documentation>
            </xs:annotation>
	     </xs:element>
         <xs:element name="type_name" minOccurs="1" maxOccurs="1"
            type="xs:string">
            <xs:annotation>
               <xs:documentation>
                  The type name of the toppic associated to a SharedReaderQueue
               </xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element name="reply_type" minOccurs="0"
            maxOccurs="1" type="xs:string" >
            <xs:annotation>
               <xs:documentation>
                  A shortcut to create a reply queue. This tag defines the type of the reply queue.
               </xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element name="reply_topic" minOccurs="0"
            maxOccurs="1" type="xs:string" >
            <xs:annotation>
               <xs:documentation>
                  A shortcut to create a reply queue. This tag defines the topic name of the reply queue.
               </xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element name="datareader_qos" minOccurs="0"
            maxOccurs="1" type="dataReaderQosProfileChild" />
         <xs:element name="redistribution_datawriter_qos" minOccurs="0"
            maxOccurs="1" type="dataWriterQosProfileChild" />
         <xs:element name="datawriter_qos" minOccurs="0"
            maxOccurs="1" type="dataWriterQosProfileChild" />
         <xs:element name="update_datareader_qos" minOccurs="0"
            maxOccurs="1" type="dataReaderQosProfileChild" />
         <xs:element name="update_datawriter_qos" minOccurs="0"
            maxOccurs="1" type="dataWriterQosProfileChild" />
         <xs:element name="master_election_datareader_qos" minOccurs="0"
            maxOccurs="1" type="dataReaderQosProfileChild" />
         <xs:element name="master_election_datawriter_qos" minOccurs="0"
            maxOccurs="1" type="dataWriterQosProfileChild" />
         <xs:element name="queue_qos" minOccurs="0"
            maxOccurs="1" type="queueQosType" />
      </xs:all>
      <xs:attribute name="name" type="resourceName" use="optional"/>
      <xs:attribute name="session" type="elementReference" use="required"/>
      <xs:attribute name="dead_letter_queue" type="xs:NCName" use="optional"/>
   </xs:complexType>

   <!-- Test -->

   <xs:complexType name="queueQosType">
      <xs:annotation>
         <xs:documentation>
            Set the different QoS settings for a certain SharedReaderQueue.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="resource_limits" type="queueResourceLimitsPolicyType" minOccurs="0" maxOccurs="1"/>

         <xs:element name="reliability" type="queueReliabilityQosType" minOccurs="0" maxOccurs="1"/>

         <xs:element name="distribution" type="distributionPolicyType" minOccurs="0" maxOccurs="1"/>

         <xs:element name="replication" type="replicationType" minOccurs="0" maxOccurs="1"/>

         <xs:element name="lifespan" type="lifespanPolicyType" minOccurs="0" maxOccurs="1"/>

         <xs:element name="redelivery" type="redeliveryPolicyType" minOccurs="0" maxOccurs="1"/>

         <xs:element name="persistence" type="persistencePolicyType" minOccurs="0" maxOccurs="1"/>
     </xs:all>
   </xs:complexType>

    <!-- RTI extension -->
    <xs:complexType name="watermarkSettings">
        <xs:annotation>
            <xs:documentation>
                Watermark settings. high_watermark, low_watermark represent percentages.
            </xs:documentation>
        </xs:annotation>
        <xs:all>
            <xs:element name="high_watermark"
                        type="xs:nonNegativeInteger"
                        minOccurs="0"
                        maxOccurs="1"/>
            <xs:element name="low_watermark"
                        type="xs:nonNegativeInteger"
                        minOccurs="0"
                        maxOccurs="1"/>
        </xs:all>
    </xs:complexType>

    <xs:complexType name="queueAllocationSettings">
        <xs:annotation>
            <xs:documentation>
                Resource allocation settings.
            </xs:documentation>
        </xs:annotation>
        <xs:all>
            <xs:element name="initial_count"
                        type="xs:nonNegativeInteger"
                        minOccurs="0"
                        maxOccurs="1"/>
            <xs:element name="max_count"
                        type="positiveIntegerUnlimited"
                        minOccurs="0"
                        maxOccurs="1"/>
            <xs:element name="max_in_memory_bytes"
                        type="positiveIntegerUnlimited"
                        minOccurs="0"
                        maxOccurs="1"/>
            <xs:element name="incremental_count"
                        type="xs:integer"
                        minOccurs="0"
                        maxOccurs="1"/>
        </xs:all>
    </xs:complexType>

   <xs:complexType name="queueResourceLimitsPolicyType">
      <xs:annotation>
         <xs:documentation>
            Sets the resource settings for a certain SharedReaderQueue.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="queue_allocation_settings"
            minOccurs="0" maxOccurs="1" type="queueAllocationSettings">
            <xs:annotation>
               <xs:documentation>
               The allocation settings for a certain SharedReaderQueue.
               </xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element name="queue_watermark_settings"
            minOccurs="0" maxOccurs="1" type="watermarkSettings">
            <xs:annotation>
               <xs:documentation>
               The watermark settings for a certain SharedReaderQueue.
               </xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element name="replacement_policy"
            minOccurs="0" maxOccurs="1" type="replacementPolicy">
            <xs:annotation>
               <xs:documentation>
               The replacement policy when the queue is full of messages.
               </xs:documentation>
            </xs:annotation>
         </xs:element>
      </xs:all>
   </xs:complexType>

   <xs:complexType name="replacementPolicy">
      <xs:annotation>
         <xs:documentation>
            The replacement policy when the queue is full of messages.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="kind" minOccurs="1" maxOccurs="1">
            <xs:annotation>
               <xs:documentation>
               The replacement policy kind when the queue is full of messages.
               </xs:documentation>
            </xs:annotation>
            <xs:simpleType>
               <xs:restriction base="xs:string">
                  <xs:enumeration value="REJECT_WITHOUT_REPLACEMENT" />
                  <xs:enumeration value="WAIT_WITHOUT_REPLACEMENT" />
               </xs:restriction>
            </xs:simpleType>
         </xs:element>
      </xs:all>
   </xs:complexType>


   <xs:complexType name="redeliveryPolicyType">
      <xs:annotation>
         <xs:documentation>
            Set the retry policy for messages
         </xs:documentation>
      </xs:annotation>
      <xs:all>
        <xs:element name="max_delivery_retries" minOccurs="0" maxOccurs="1" type="nonNegativeIntegerUnlimited"/>
        <xs:element name="response_timeout" minOccurs="0" maxOccurs="1" type="responseTimeoutPolicyType">
          <xs:annotation>
             <xs:documentation>
              The maximum time before a response can be considered timed out.
             </xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:all>
   </xs:complexType>


   <xs:complexType name="distributionPolicyType">
      <xs:annotation>
         <xs:documentation>
            Set the distribution policy for a certain SharedReaderQueue.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="kind" minOccurs="0" maxOccurs="1">
            <xs:annotation>
               <xs:documentation>
               The kind of distribution policy used to distribute samples amongst SharedReaderQueue subscribers
               </xs:documentation>
            </xs:annotation>
            <xs:simpleType>
               <xs:restriction base="xs:string">
                  <xs:enumeration value="ROUND_ROBIN" />
                  <xs:enumeration value="BROADCAST" />
               </xs:restriction>
            </xs:simpleType>
         </xs:element>
        <xs:element name="mark_last_undelivered_sample" minOccurs="0" maxOccurs="1">
          <xs:annotation>
            <xs:documentation>
              Mark the last undelivered sample of a queue for a Consumer
            </xs:documentation>
          </xs:annotation>
          <xs:simpleType>
            <xs:restriction base="xs:boolean"/>
          </xs:simpleType>
        </xs:element>
         <xs:element name="property" type="propertyQosPolicy" minOccurs="0" maxOccurs="1"/>
      </xs:all>
   </xs:complexType>

   <xs:complexType name="replicationType">
      <xs:annotation>
         <xs:documentation>
            Settings for producer updates, fail over and load balancing.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="enabled" type="xs:string" minOccurs="0" maxOccurs="1">
            <xs:annotation>
               <xs:documentation>
               Enabled should be 1, true or YES for synchronization to be set.
               </xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element name="replication_settings" type="replicationSettingsType" minOccurs="0" maxOccurs="1"/>
      </xs:all>
   </xs:complexType>

   <xs:complexType name="adminReplicationType">
      <xs:annotation>
         <xs:documentation>
            Settings for producer updates, fail over and load balancing.
         </xs:documentation>
      </xs:annotation>
      <xs:choice maxOccurs="unbounded">
         <xs:element name="enabled" type="xs:string" minOccurs="0" maxOccurs="1">
            <xs:annotation>
               <xs:documentation>
               Enabled should be 1, true or YES for synchronization to be set.
               </xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element name="replication_settings" type="replicationSettingsType" minOccurs="0" maxOccurs="1"/>
         <xs:element name="domain_participant_qos"
                     type="domainParticipantQosProfileChild"
                     minOccurs="0"
                     maxOccurs="1"/>
         <xs:element name="participant_qos"
                     type="domainParticipantQosProfileChild"
                     minOccurs="0"
                     maxOccurs="1"/>
      </xs:choice>
   </xs:complexType>

   <xs:complexType name="replicationSettingsType">
     <xs:annotation>
         <xs:documentation>
            Settings queues replicated across multiple queuing service instances.
         </xs:documentation>
     </xs:annotation>
     <xs:all>
     	 <xs:element name="synchronize_consumer_assignment" type="xs:string" minOccurs="1" maxOccurs="1">
            <xs:annotation>
               <xs:documentation>
               Ensure a quorum of queue instances agree on the message consumer before the message is sent.
               </xs:documentation>
            </xs:annotation>
         </xs:element>
	     <xs:element name="queue_instances" type="xs:nonNegativeInteger" minOccurs="1" maxOccurs="1">
	        <xs:annotation>
	           <xs:documentation>
	           The number of queue service instances running the same queue.
	           </xs:documentation>
	        </xs:annotation>
	     </xs:element>
	     <xs:element name="master_timeout" minOccurs="0" maxOccurs="1" type="masterTimeoutType" />
	     <xs:element name="sample_timeout" minOccurs="0" maxOccurs="1" type="sampleTimeoutType" />
	</xs:all>
   </xs:complexType>


   <xs:complexType name="lifespanPolicyType">
      <xs:annotation>
         <xs:documentation>
            Sets the maximum time a message can remain in a SharedReaderQueue.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="duration" minOccurs="0" maxOccurs="1" type="duration">
            <xs:annotation>
               <xs:documentation>
               </xs:documentation>
            </xs:annotation>
         </xs:element>
      </xs:all>
   </xs:complexType>

   <xs:complexType name="responseTimeoutPolicyType">
      <xs:annotation>
         <xs:documentation>
            Sets the maximum time a message can remain in a SharedReaderQueue.
         </xs:documentation>
      </xs:annotation>
      <xs:all>
         <xs:element name="duration" minOccurs="0" maxOccurs="1" type="duration">
            <xs:annotation>
               <xs:documentation>
               </xs:documentation>
            </xs:annotation>
         </xs:element>
      </xs:all>
   </xs:complexType>

   <xs:complexType name="persistencePolicyType">
     <xs:annotation>
      <xs:documentation>Sets the persistence settings for the SharedReaderQueue</xs:documentation>
     </xs:annotation>
     <xs:all>
      <xs:element name="kind" minOccurs="0" maxOccurs="1">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="PERSISTENT"/>
            <xs:enumeration value="VOLATILE"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="in_memory_state" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
           <xs:documentation>
           in_memory_state should be 1, true or YES for synchronization to be set.
           </xs:documentation>
        </xs:annotation>
     </xs:element>
     </xs:all>
   </xs:complexType>

   <xs:complexType name="queueReliabilityQosType">
    <xs:annotation>
      <xs:documentation>Set the reliability settings for a SharedReaderQueue</xs:documentation>
    </xs:annotation>
    <xs:all>
      <xs:element name="app_ack_sample_to_producer" minOccurs="0" maxOccurs="1" type="xs:boolean"/>
    </xs:all>
   </xs:complexType>

</xs:schema>
