Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
In this tutorial, you will use a BPMN process defined in the Business Process profile of WSO2 EI to
Panel
Panel

In this tutorial, you will use a BPMN process defined in the Business Process profile of WSO2 EI to manage the process of canceling a doctor's appointment. The appointment cancellation process should be designed according to the following requirement:

  • The patient should be allowed to cancel the appointment (unconditionally) if the appointment date is at least two days away.
  • The patient should not be allowed to cancel the appointment if the appointment date is less than two days away.
  • If the appointment date falls on the second day from the current date, the patient can request for appointment cancellation, which should be manually approved by an administrator.
  • The patient should receive email notifications informing if the appointment cancellation is accepted or rejected.
Note

See the Business processes topic for a description of the concepts that you need to know when creating the artifacts:

Tip

Before you begin,

Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the JAVA_HOME environment variable.

  1. Download the WSO2 EI ZIP file product installer from here, and then extract run the ZIP file.
    The path to this folder will be referred to as <EI_HOME> throughout this tutorial.installer.
    Insert excerpt
    Installing the Product
    Installing the Product
    nopaneltrue
  2. Select and download the relevant EI tooling 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.

    Info
  3. You need to try out the Using the Gmail Connector tutorial before trying out this tutorial as the Gmail connector that is used in this tutorial is configured using your client ID and secret.
  4. 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.
  5. Create STMP an email account to send out emails to users that want to cancel an appointment using WSO2 Business Process Server (e.g., no-reply@foo.com).

...

  1. In WSO2 EI Tooling, open the Developer Studio dashboard by clicking the Developer Studio menu and choosing Open Dashboard, and select BPMN Project .
  2. Create a new project named AppointmentCancellation.
  3. Click Finish.
  4. Click Open Perspective in the Open Associated Perspective? window.
  5. In Developer Studio Dashboard, select BPMN Diagram
  6. Select the AppointmentCancellation/src/main/resources/diagrams directory as the parent folder, and enter AppointmentCancellation.bpmn for the File name.
  7. Click Next, select the option to create an empty diagram as shown below, and click Finish.
  8. Let's start drawing the BPMN process diagram for the appointment cancellation process. The AppointmentCancellation canvas. The Palette on the right side of the AppointmentCancellation canvas contains all the activity symbols that will be used for drawing the process as shown below.

    Let's get started. You can easily drag and drop the activities from the Palette the canvas, and then update the properties and configurations of each activity as explained below.
    1. Add a StartEvent from the Start Event palette.
    2. Select the Properties tab, click Form, click New, update the following and click OK.

      IdpatientName
      NameName of the Patient
      Typestring
      RequiredTrue

    3. Repeat clicking New and adding the following to add the other form properties one by one.

      IdNameTypeRequired
      appointmentNoAppointment NumberlongTrue
      doctorName of the DoctorstringTrue
      reasonReason for cancellationstringTrue
      emailEmail AddressstringTrue

    4. Add a REST Task from the WSO2 Tasks palette.

      Select the Properties tab, click General and give the Name as Get Appointment, then click Main config and update the following:

      Service URLhttp://localhost:9090/healthcare/appointments/validity/${appointmentNo}
      HTTP methodGET
      Output Variable MappingsnoOfDays:$.status


    5. Add an Exclusive Gateway from the Gateway palette.
    6. Add a User Task from the Task palette and name it Appointment Control Task.
    7. Click Properties, click Main config  and give admin as the Assignee.
       
    8. In the Properties tab click Form, click New and add the following.

      IdNameTypeVariableReadableWritableRequired
      approveCancellationDo You Approve the
      Appointment Cancellation Request?
      enumappointmentNoTrueFalseTrue

      Click New next to Form values and add the following:

      IdName
      approveApprove
      rejectReject

    9. Repeat clicking New and adding the following to add the other form properties one by one.

      IdNameTypeVariableReadableWritableRequired
      AppNoAppointment NumberlongappointmentNoTrueFalseTrue
      cancellationReasonReason For The CancellationstringreasonTrueFalseTrue
      doctorNameName of the DoctorstringdoctorTrueFalseTrue

    10. Add another Exclusive Gateway from the  Gateway  palette.
    11. Add a REST Task from the  WSO2 Tasks palette.

      Select the Properties tab and click Main config and update the following:

      Service URLhttp://localhost:9090/healthcare/appointments/validity/${appointmentNo}
      HTTP methodDELETE
      Output Variable namestatus

    12. Add a MailTask from the Task palette below the second Parallel Gateway and name it Reject cancellation Task.

      Select the Properties tab and click Main config and update the following:

      To${email}
      FromEnter a valid SMTP email address.
      SubjectAppointment cancellation rejected
      HtmlAppointment cancellation request with Appointment Number ${appointmentNo} has been rejected. Thank you.
      Administration Department 

    13. Add another MailTask above the second Parallel Gateway and name it Approve Cancellation Task.


      Select the Properties tab and click Main config and update the following:

      To${email}
      FromEnter a valid SMTP email address.
      SubjectAppointment cancellation successful
      HtmlAppointment cancellation request with Appointment Number ${appointmentNo} has been approved. Thank you.
      Administration Department 

    14. Link each activity by hovering over the element, selecting the arrow sign and dragging it to the connecting element as shown below.
  9. Click on the arrow leading from the first Exclusive Gateway to the Approve Cancellation Task, and in the Main config section of the Properties tab add the ${noOfDays >2} condition.
  10. Anchor
    reject
    reject
    Click on the arrow leading from the first Exclusive Gateway to the Reject Cancellation Task, and in the Main config section of the Properties tab add the ${noOfDays<2} condition.
  11. Click on the arrow leading from the second Exclusive Gateway to the Rest Task, and in the Main config section of the Properties tab add the  ${approveCancellation == 'approve'}  condition.
  12. Click on the arrow leading from the second Exclusive Gateway to the Reject Cancellation Task, and in the Main config section of the Properties tab add the ${approveCancellation == 'reject'} condition.
  13. Click the arrow leading to the Appointment Control Task, open the General tab that is under properties and note the Id.
    Example:
  14. Click the first exclusive gateway, open the General tab that is under properties, and select the ID you noted in the above steps as the value for Default flow.

  15. Save all the changes you have made.
  16. Click Window -> Show View -> Other in the top menu of Tooling.
  17. Type Package Explorer in the search bar, select it and click Open.
  18. In the Package Explorer, right-click the AppointmentCancellation project and select Create deployment artifacts

    This will create a AppointmentCancellation.bar file in the deployment folder:

...

<property name="mailServerHost" value="smtp.gmail.com

the business process profile:

  1. Copy the following JARs to the <EI_HOME>/lib directory.
  2. Open the activiti.xml file in the <EI_HOME>/wso2/business-process/conf directory and add the following properties under <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> as shown below to enable the Gmail configurations.

    • Replace the mailServerHost and mailServerPort property values as follows:

Info

Before you begin, apply the following configurations to the business process profile:

  • Copy the following JARs to the <EI_HOME>/lib directory.
  • Open the activiti.xml file in the <EI_HOME>/wso2/business-process/conf directory and add the following properties under <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> as shown below to enable the Gmail configurations.

    Replace the mailServerHost and mailServerPort property values as follows:

    Code Block
    Code Block
    <property name="mailServerHost" value="smtp.gmail.com"/>
    <property name="mailServerPort" value="587"/>
  • Add the following properties:

    Code Block
    <property name="mailServerDefaultFrom" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/>
    <property name="mailServerUseTLS" value="true"/>
    <property name="mailServerUsername" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/>
    <property name="mailServerPortmailServerPassword" value="587"/>
  • Add the following properties:

    Code Block
    <property name="mailServerDefaultFrom" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/>
    <property name="mailServerUseTLS" value="true"/>
    <property name="mailServerUsername" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/>
    <property name="mailServerPassword" value="<ENTER_THE_EMAIL_PASSWORD>"/>
  • You can now deploy the .bar file of the BPMN process using the management console of the business process profile in WSO2 EI.

    ...

      • "<ENTER_THE_EMAIL_PASSWORD>"/>

    You can now deploy the .bar file of the BPMN process using the management console of the business process profile in WSO2 EI.

    1. Open a terminal and navigate to the <EI_HOME>/wso2/business-process/bin directory.
    2. Start the Business Process profile:

      Panel
      borderColor#542989
      bgColor#ffffff
      borderWidth1
      Localtabgroup
      Localtab
      activetrue
      titleOn MacOS/Linux/CentOS

      Open a terminal and execute the following command:

      Code Block
      wso2ei-6.3.0-business-process
      Localtab
      titleWindows

      Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.3.0 Business Process. This will open a terminal and start the Business Process profile.

    3. Open the management console from https://localhost:9445/carbon/.
    4. Log in using admin as the username and password.
    5. Go to Main -> Manage -> Add ->BPMN and upload the AppointmentCancellation.bar file by browsing in the workspace directory of your Tooling instance as shown below. 

    ...

    Let's start the Message Broker profile:

    Panel
    borderColor#542989
    bgColor#ffffff
    borderWidth1
    Localtabgroup
    Localtab
    activetrue
    titleOn MacOS/Linux/CentOS

    Open a

    ...

    terminal and execute the following command:

    Code Block
    wso2ei-6.3.0-broker
    Localtab
    titleOn Windows
    Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.3.0 Broker. This will open a terminal and start the Message Broker profile.

    Anchor
    start_integration
    start_integration
    Deploying the ESB artifacts in the ESB profile

    Info

    Before you start the ESB profile, configure the profile so that it can connect to the Message Broker profile for reliable messaging. To do this, open the <EI_HOME>/conf/jndi.properties file and update the connection factories and queues at the beginning of the file so that it now looks like this:

    Code Block
    # register some connection factories
    # connectionfactory.[jndiname] = [ConnectionURL]
    connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5675'
    connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5675'
    # register some queues in JNDI using the form
    # queue.[jndiName] = [physicalName]
    queue.MyQueue = example.MyQueue
    queue.PaymentRequestJMSMessageStore=PaymentRequestJMSMessageStore

    Now, let's start the ESB profile in WSO2 EI and upload the ESB artifacts:

    On the Servers tab of Developer Studio, expand the WSO2 Carbon server, right-click SampleServicesCompositeApplication, and choose Redeploy. The Console window will indicate that the CApp has deployed successfully.

    Tip

    If you do not have a server added in Eclipse, refer this tutorial.

    Info

    You can also deploy the artifacts to the ESB profile of WSO2 EI using a Composite Application Archive (CAR) file.

    ...

    To be able to send requests to the back-end service (which is an MSF4J service deployed in the MSF4J profile of WSO2 EI), you need to first start the MSF4J runtime:

    ...

    Start the runtime by executing the MSF4J startup script as shown below.

    ...

     using the form
    # queue.[jndiName] = [physicalName]
    queue.MyQueue = example.MyQueue
    queue.PaymentRequestJMSMessageStore=PaymentRequestJMSMessageStore

    Now, let's start the ESB profile in WSO2 EI and upload the ESB artifacts:

    On the Servers tab of Developer Studio, expand the WSO2 Carbon server, right-click SampleServicesCompositeApplication, and choose Redeploy. The Console window will indicate that the CApp has deployed successfully.

    Tip

    If you do not have a server added in Eclipse, refer this tutorial.

    Info

    You can also deploy the artifacts to the ESB profile of WSO2 EI using a Composite Application Archive (CAR) file.

    Anchor
    start_msf4j
    start_msf4j
    Starting the back-end service

    To be able to send requests to the back-end service (which is an MSF4J service deployed in the MSF4J profile of WSO2 EI), you need to first start the MSF4J runtime:

    Panel
    borderColor#542989
    bgColor#ffffff
    borderWidth1
    Localtabgroup
    Localtab
    titleOn MacOS/Linux/CentOS

    Open a terminal and execute the following command:

    Code Block
    wso2ei-6.3.0-msf4j
    Localtab
    titleOn Windows

    Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.3.0 MSF4J. This will open a terminal and start the MSF4J profile.

    The system is now ready to receive appointment reservation requests.

    ...