Microservices

Socket Read/Write

Objective

Configure the SocketAdapter component as a Server in synchronous mode and configure it as a Client to invoke the server.

Prerequisites

  • Start Fiorano Enterprise Server (FES) and Fiorano Peer Server (FPS)

  • Login to eStudio application

  • Understand the basic menus and perspectives (panels) in eStudio application

Scenario

Create a Socket Server with a specific Port number and IP address to listen to Socket Client data. The server receives the data that is sent by the Client. Socket Server writes back the data to the Socket Client and indicates the successful write-back process through a status message.

Components used

Setting up the Example

Socket Server Configuration

To configure SocketAdapter component for the server, perform the following action in eStudio:

  1. Add a new Event Process with the name 'SocketRW_Server_Eg'.

  2. Drag the SocketAdapter component from Bridges category in the Micro Service Palette to the Fiorano Orchestrator.

    SocketRW_Server_Eg.png
    Figure 1: Adding SocketAdapter compoent to Fiorano Orchestrator
     

  3. Click the SocketAdapter component and do any of the following to rename the component from 'SocketAdapter' to 'SocketServer':

    1. Press F2, change the name, and click OK.

      worddav4d63869866897cf8467dbc5887c0edd1.png
      Figure 2: Renaming using Keyboard action 'F2'
       

    2. Go to Name property under General tab in Properties, change the name, and press ENTER.

      worddav8417fd7b37ee2f179579a98df877ab63.png
      Figure 3: Renaming using General Properties

    The name change is to distinguish it from the Socket that will be configured for the client.


  4. Double-click the SocketServer component in the Orchestrator to open the Configuration Property Sheet (CPS).

  5. Click the Attributes tab and provide the following values:

    1. Select the Create Socket ? check box.

    2. Server IP: 127.0.01 (retain default IP)

    3. Port: 5436 (retain default port)

    4. Decoding Type: None

    This will start SocketServer on the peer server machine at port 5436.

    worddav64c5daa6bd588ddec7a04551f7cd85ab.png


    Figure 4: SocketServer Configuration in CPS
     

  6. Click Finish to save the server configuration.

Socket Client Configuration

To configure SocketAdapter component for a client, perform the following action in eStudio:

  1. Add a new Event Process with the name 'SocketRW_Client_Eg'.

  2. Add SocketAdapter component to Fiorano Orchestrator and change the name to 'SocketClient' by following the steps mentioned in Socket Server Configuration section.

  3. Open SocketClient component CPS, click the Attributes tab, and provide the following values:

    1. Leave the Create Socket ? check box unchecked.

    2. Server IP: 127.0.01 (same IP as used in Server Configuration)

    3. Port: 5436 (same port as used in Server Configuration)

    4. Decoding Type: None

      worddavfad0e8a54bdd824017bdce7231045b0b.png
      Figure 5: SocketClient Configuration in CPS
       

  4. Click Finish to save the client configuration.

Composing Server Event Process

  1. In the SocketRW_Server_Eg Event Process Orchestrator, perform the following actions:

    1. Connect the SocketServer output port to the SocketServer input port

      worddav7a07176a04d8bde9a9cdd1dfb260b412.png
      Figure 6: Connecting SocketServer input port to output port

  2. Drag two Display components from Util category to the Orchestrator.

    worddav0b5ceb6d0a1b7f4fe4f69217db0232c0.png
    Figure 7: Adding Display components to SocketRW_Server_Eg event process

Connect the Display components to the SocketServer and rename them to match the SocketServer output port names in the following manner:

  1. Connect Display1 to SocketServer OUT_PORT and rename it to DisplayMessage.

  2. Connect Display2 to SocketServer STATUS_PORT and rename it to DisplayStatus.

    worddav284952d9bf537efbaa3f6987ba603d1b.png
    Figure 8: Connecting Display components to SocketServer

Composing Client Event Process

In the SocketRW_Client_Eg Event Process Orchestrator, perform the following actions:

  1. Drag one Feeder and one Display component from Micro Service Palette under Util category.

  2. Connect the components in the following manner:

    1. Feeder component output port to SocketClient input port.

    2. SocketClient output port to Display component input port.
       

    worddav8d65ae0da1ced3fc1ac5048fae173b01.png


    Figure 9: Adding Display components to SocketRW_Client_Eg event process

Understanding the Data Flow

Data flows in the following order:

  1. Feeder sends data to SocketClient.

  2. SocketServer receives the data from ServerClient and displays it in DisplayMessage.

  3. SocketServer redirects the data back to SocketClient and displays the successful write-back status in DisplayStatus.

  4. SocketClient receives the data back from the server and displays it in Display1.

worddav6e2bb6a6d18c1229f7cf5b320155473a.png
Figure 10: Data flow between SocketServer and SocketClient

Running the Example

Open SocketRW_Server_Eg Event Process Orchestrator and perform the following actions:

  1. Click Check Resource and Connectivity  icon (or press ALT+SHIFT+C) to check resource and connectivity.

  2. Click Run Event Process icon (ALT+SHIFT+R) to run the event process. DisplayMessage and DisplayStatus windows get open.

  3. Switch to SocketRW_Client_Eg Event Process Orchestrator and follow steps 1 and 2 above. Feeder1 and Display1 components get open.

  4. In the Client Feeder1 window, replace 'Input Text' with 'TestMessage' and click Send.

    worddav162127e2354686f00825fbfc1311bd9a.png
    Figure 11: Sending a message from Feeder
     

  5. DisplayMessage window displays the message from the client that is received by the server.

    worddav981e5b5a57bd4db4c7a0dfcaaba874c2.png
    Figure 12: Displaying Message received from client
     

  6. DisplayStatus shows the confirmation message 'Message Sent Successfully' as the server writes the message back to the client.

    worddavd1a0869cb68ff5c42ce3fd10274b765d.png
    Figure 13: Status message indicating that message is written back to the client
     

  7. Display1 receives the message that is sent back from the server.

    worddav255682dd4d6c721ca5639c31624509e9.png
    Figure 14: Message sent back by Server, received by the client

Reference