Unknown macro: {next_previous_links}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

In this sample scenario, you will use a Sequence Template and reuse it in multiple places of the medation flow. You can reuse the mediation flow that was defined in the /wiki/spaces/EI6xx/pages/49614279 tutorial and then replace its sections with the sequence template. See Creating Templates for details on how to work with templates using WSO2 Integration Studio.


Before you begin,

  1. Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the JAVA_HOME environment variable.
  2. Download the product installer from here, and run the installer.
    Let's call the installation location of your product the <EI_HOME> directory. This is located in a place specific to your OS as shown below:
    OSHome directory
    Mac OS/Library/WSO2/EnterpriseIntegrator/6.6.0
    WindowsC:\Program Files\WSO2\EnterpriseIntegrator\6.6.0\
    Ubuntu/usr/lib/wso2/EnterpriseIntegrator/6.6.0
    CentOS/usr/lib64/EnterpriseIntegrator/6.6.0
  3. Select and download the relevant WSO2 Integration Studio ZIP file based on your operating system from here and then extract the ZIP file.
    The path to this folder will be referred to as <EI_TOOLING> throughout this tutorial.

    Getting an error message? See the troubleshooting tips given under /wiki/spaces/EI6xx/pages/49612293.

  4. If you did not try the /wiki/spaces/EI6xx/pages/49614337 tutorial yet, open the WSO2 Integration Studio, click File, and then click Import. Next, select Existing WSO2 Projects into workspace under the WSO2 category, click Next and upload the pre-packaged project. This contains the configurations of the /wiki/spaces/EI6xx/pages/49614337 tutorial so that you do not have to repeat those steps.
  5. Download the MSF4J service from here and copy the JAR file to <EI_HOME>/wso2/msf4j/deployment/microservices folder. The back-end service is now deployed in the MSF4J profile of WSO2 EI.

Let's get started!

Configuring a sequence template

  1. Once you have exported the ESB project as described above, the project directory will appear with the artifacts as shown below.

  2. Right-click on SampleServices and navigate to New -> Template. The New Template Artifact dialog will open.

  3. Select the Create a New Template and click Next.

  4. Enter the following details and click Finish.

    Template NameHospitalRoutingSeq
    Template TypeSequence Template


  5. The template artifact will open in the canvas as shown below.


  6. Open the Properties tab of the sequence template by clicking on the canvas (outside the sequence box).

  7. Click the  icon to start adding parameters.


  8. In the Template Parameter dialog that opens, enter 'sethospital' as the parameter name and click Finish

  9. Add a Log mediator to the sequence template as shown below. This will print a message indicating to which hospital a requested message is routed. 

  10. Open the Properties tab of the log mediator and specify the following:

    Log CategoryINFO
    Log LevelCUSTOM
  11. Click the  icon to start defining a property. Then add the following details for the property:

    Namemessage
    TypeEXPRESSION
    Property Expressionfn:concat('Routing to ', get-property('Hospital'))

    We select EXPRESSION because the required properties for the log message must be extracted from the request, which we can do using an XPath expression.

  12. Add a Property mediator just after the Log mediator to store the value for uri.var.hospital.


  13. With the Property mediator selected, access the Properties tab and enter the information given below:

    Property Name

    Select New Property

    New Property Name

    uri.var.hospital

    URI Template

    Select set

    Value Type

    Select EXPRESSION

    Property Data Type

    Select STRING

    Value Expression

    $func:sethospital

    Description

    Set Hospital Variable

Using the sequence template in the REST API

  1. Open the design view of the HealthcareAPI.xml and delete 'GrandOak'Log mediator by right clicking the mediator and selecting Delete from Model.

  2. Delete the 'Set Hospital Variable' Property mediator.

  3. Add a Call Template mediator to the sequence as shown below.

  4. Open the Properties tab of the Call Template mediator and select 'HospitalRoutingSeq' from the list of available templates.

  5. Click the  icon to start adding parameters. Enter the following parameter details and click Finish.

    Parameter Name

    sethospital

    Parameter Type

    value

    Value/Expression

    grandoaks

  6. Repeat the above steps to add Call Templates for 'Clemency' and 'Pine Valley' hospitals. Add clemency and pinevalley as the respective parameter values.

  7. Save the configuration.

Deploying the artifacts

  1. Open the pom.xml file under the SampleServicesCompositeApplication project from the project explorer. 

  2. See that the newly added 'HospitalRoutingSeq' artifact is listed under Dependencies. Select this artifact to add it to the composite application project.

    Screen Shot 2016-10-14 at 10.38.42 AM.png

  3. Save your changes.

  4. Open the Getting Started view and click Miscellaneous →Add New Server to open the New Server dialog. 

  5. In the New Server dialog, expand the WSO2 folder and select the version of your server.
  6. Click Next. In the CARBON_HOME field, provide the path to your product's home directory, and then click Next again.
  7. Review the default port details for your server and click Next.

  8. To deploy the CApp project to your server, select the SampleServicesCompositeApplication project from the list, click Add to move it into the configured list, and then click Finish.

  9. On the Servers tab, note that the server is currently stopped. Click the 'play' icon on the tool bar. If prompted to save changes to any of the artifact files you created earlier, click Yes

  10. As the server starts, the Console tab appears. Note messages indicating that the composite app was successfully deployed.

Invoking the ESB sequence

Send a request to the ESB as shown below and see that the response is successfully received.

  1. Open a command line terminal and execute the following command from the location where the request.json file you created is saved:

    curl -v -X POST --data @request.json http://localhost:8280/healthcare/categories/surgery/reserve --header "Content-Type:application/json"
  2. You will see the response in the command line terminal.

  • No labels