Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

Request-response UDP tutorial



This tutorial reuse the request-response tutorial, but the two modules are in two different framework instances.

Overview

In the request-response tutorial, we specified two modules:
  • One module received a request with an int and replies with the value multiplied by 10
  • Another module allows to set an int value, and sends a request with this value to the other butotn on a click of a button

tutorequest
We will put each of these modules in a separate framework instance, and the two instances will communicate through UDP.

Architecture

We won't change anything for the services or types configuration of the request-response tutorial, but we will separate the modules in two applications configurations. We will: And two applications:
  • Put the ResponseModule in one framework instance
  • Put the RequestModule in another framework instance
And specify the Network UDP communication between these two frameworks:
tutorequestnetwork

XML configuration

Only the applications.xml XML files has to be modified. We will define one file for each framework. The code is not impacted.

Response framework instance

The first framework instance only has the ResponseModule:
      <applications>
         <application name="responseAppli" id="2">
            <deployment>
               <lib url="samplesResponse.jar" />
            </deployment>
            <modules>
               <module name="ResponseModule" id="1" > 
                  <implementation path="org.da.samples.protoframework.response.ResponseModule" >
                     <initEntryPoint method="init" />
                     <defaultReceiveEntryPoint method="subscribe" />
                  </implementation>
                  <interfaces>
                     <requestReceived service="request" />
                  </interfaces>             
               </module>
            </modules>
         </application>           
      </applications>

tutorequestnetwork3
We will call it from a specific filelist configuration:
      <files>
         <file url="applicationResponse.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
      </files>

Request framework instance

The second framework instance only has the RequestModule:
      <applications>
         <application name="requestAppli" id="1">
            <deployment>
               <lib url="samplesRequest.jar" />
            </deployment>
            <modules>
               <module name="RequestModule" id="1" > 
                  <implementation path="org.da.samples.protoframework.request.RequestModule" >
                     <initEntryPoint method="init" />
                     <defaultReceiveEntryPoint method="subscribe" />
                  </implementation>
                  <interfaces>
                     <requestSend service="request" timeOut="200000ms"/>
                  </interfaces>             
               </module>
            </modules>
         </application> 
      </applications>

tutorequestnetwork2
We will call it from another specific filelist configuration:
      <files>
         <file url="applicationPublish.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
      </files>

Start the two frameworks

To start the Response framework instance, we use our first filelist configuration file for our configuration:
      java -jar protoframework.jar config=filelistResponse.xml
To start the Request framework instance, we use our second filelist configuration file for our configuration:
      java -jar protoframework.jar config=filelistRequest.xml
However as the two framework instances do not communicate, nothing happens on the GUI for the moment when we send a request because it is not received by the reponse module.

Specify the Network configuration between the two framework instances

To allow the two framework instances to communicate, we will define a network configuration for each of the instances.

Response framework instance

We will create a network configuration for the Response framework instance. We need to create two Channels:
  • One Channel to receive the request for the request Service
  • One Channel to send the response for the request Service

tutorequestnetwork4
The network configuration will be:
      <network>
         <channel name="request" type="input" port="8080" size="1000">
            <service name="request" />
         </channel>  
         <channel name="response" type="output" port="8081" size="1000">
            <service name="request" />     
         </channel>  
      </network>
We also need to specify the Network file on our first filelist configuration file:
      <files>
         <file url="applicationResponse.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
         <file url="networkResponse.xml" />
      </files>

Request framework instance

We will create a network configuration for the Request framework instance. We need to create two Channels:
  • One Channel to send the request for the request Service
  • One Channel to receive the response for the request Service

tutorequestnetwork5
The network configuration will be:
      <network>
         <channel name="request" type="output" port="8080" size="1000">
            <service name="request" />
         </channel>  
         <channel name="response" type="input" port="8081" size="1000">
            <service name="request" />     
         </channel>  
      </network>
We also need to specify the Network file on our first filelist configuration file:
      <files>
         <file url="applicationRequest.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
         <file url="networkRequest.xml" />
      </files>

Start the two frameworks with the Network configuration

To start the Response framework instance, we use our first filelist configuration file for our configuration:
      java -jar protoframework.jar config=filelistResponse.xml
To start the Request framework instance, we use our second filelist configuration file for our configuration:
      java -jar protoframework.jar config=filelistRequest.xml
Now the two applications are behaving exactly as for the request-response tutorial.

See also


Categories: tutorials

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence