Initiating BPM from JMS

Up to now, for all the phases of the BPM development lifecycle, you have used Human Tasks to initiate the BPM SalesToContract process. However, in real-time scenarios, this is rare case. Initiation of the BPM process takes place through either exposing the BPM process as a web service, through BPM reading a JMS, or through BPM PAPI APIs. Other mechanisms may include processes instantiated with e-mails/file/batch (that is, from enterprise information systems) and scheduled mechanisms, such as using timers. In this section, you will explore how to initiate a BPM process through JMS queue.

The SalesToContract process is a part of the supplier process. Supplier_ABCS will be created, which will produce the QuoteRequest message on a JMS queue. Your SalesToContract process will consume those messages by subscribing to the same JMS queue. This will eventually lead to initiation of the SalesToContract BPM process.

You will create a JMS queue and a Supplier_ABCS BPEL service to produce QuoteRequest, and finally, you will modify your SalesToContract BPM process to subscribe to this queue.

How to do it...

In this section, you will learn how to initiate the BPMN process using JMS:

  1. Create a JMS Queue.
  2. Log in to Oracle EM console as weblogic user.
  3. In the domain structure, expand Services | Messaging and click on JMS Modules.
  4. In the JMS Modules list, on the right-hand side of the domain structure, click on SOAJMSModule:
    How to do it...
  5. You will create a JMS Queue. These queues are configured and stored as modules.
  6. This will open the SOAJMSModule settings page. Click on the New button, in the Summary of Resources section, as shown in the following screenshot, to create a new queue resource:
    How to do it...
  7. On the Create a New JMS System Resource page, place a check next to Queue and click on the Next button, as you are going to create a queue resource.
  8. Enter QuoteReqQueue as queue Name and eis/jms/QuoteReqQueue as JNDI Name. Let the Template be None, as set by default, and click on Next:
    How to do it...
  9. Select SOASubDeployment from the Subdeployments drop-down. You have to target this queue to a server instance. By using subdeployments, you can target a queue to SOA Server Instance. The server already has a subdeployment created with the name SOASubDeployment. However, you can create a new subdeployment, too.
  10. When you select SOASubDeployment, a list of targets is presented. Select SOAJMSServer and click on Finish:
    How to do it...
  11. Go back to SOAJMSModule | Configuration tab. In the list of resources, you will find QuoteReqQueue listed. Verify the Subdeployment and Targets:
    How to do it...
  12. Create Supplier_ABCS BPEL service Message Producer Service.
  13. Open JDeveloper in default mode.
  14. Create a new project. Select projects from the categories, select the SOA project from the items list, as shown in the following screenshot, and click on OK.
  15. In the Create SOA Project dialog, enter Supplier_ABCS as the Project Name, make sure SOA is selected, and click on Finish:
    How to do it...
  16. This will open a blank composite.xml designer.
  17. Import Quote.xsd into the project.
  18. Go to Component Palette | SOA | Service Adapters and drag-and-drop JMS Adapter into the reference swimlane. This will open the JMS Adapter Configuration Wizard.
  19. On the wizard, supply QuoteRequest as Service Name for the JMS adapter service:
    How to do it...
  20. Click on the Next button.
  21. In the JMS Provider, select Oracle Weblogic JMS and click on Next.
  22. Select the application server connection and click on Next twice.
  23. By now, you must be aware of having a SOA application server connection.
  24. Select Produce Message as the operation from the Operation Type list. The Supplier_ABCS service will produce messages to QuoteReqQueue— a JMS queue. Click on Next.
  25. Enter other parameters for Produce Message, such as Destination Name and JNDI.
  26. On the Produce Operation Parameters dialog, click on the "browse" button next to Destination Name and select QuoteReqQueue from the list of resources .You can find QuoteReqQueue in the SOAJMSModule resource list:
    How to do it...
  27. You are aware that the JNDI Name for JMS connection is eis/wls/Queue by default. You will use the same one. Once you are done, click on Next.
    How to do it...
  28. Click on the "browse" button next to the message URL, and as you have imported Quote.xsd into the project, you can browse the schema in the project. Select the QuoteRequest element from the schema. Click on OK in the Type Chooser dialog, and Next in the JMS Wizard dialog.
  29. The schema you have chosen here will define the message payload for the JMS destination.
    How to do it...
  30. Click on Finish in the last dialog.
  31. You will find that a JMS Adapter is created on the reference swimlane in the composite designer.
  32. Go to Component Palette | SOA | Service Component. Drag-and-drop BPEL from the component list into composite designer's component middle swimlane. This will open the Create BPEL Process dialog.
  33. Choose BPEL 1.1 Specification. Enter Supplier_ABCS as the name of the BPEL service, and expose it as a service. Let the service be an asynchronous service. Browse for the input schema type and select QuoteRequest from the Schema Element type list, as shown in the following screenshot:
    How to do it...
  34. Create a wire between the Supplier_ABCS and JMS Adapter services in the composite designer.
  35. Double-click on the BPEL Service Supplier_ABCS. This will open the Supplier_ABCS.bpel designer.
  36. Go to Component Palette | BPEL 1.1 | BPEL Constructs | Webservice, drag-and-drop Invoke between ReceiveInput and Call-Back Client, and rename it to Invoke_QuoteRequest.
  37. Create a Partner Link with the QuoteRequest JMS service. Produce Message will auto-appear as an operation.
  38. Click on the green plus (+) icon, to create an input variable and click on OK:
    How to do it...
  39. Go to Component Palette | BPEL 1.1 | SOA Extensions and drag-and-drop the Transform activity between receive input and invoke QuoteRequest.
  40. Rename it to Transform_Input_QuoteRequest and create a transformation between input variable and QuoteRequest_ProduceMessage_Inputvariable.
  41. Name transformation file Transformation_Input_QuoteRequest.xsl and create the transformation between source and target:
    How to do it...
  42. When you have finished this, click on Save.
  43. Deploy the Supplier_ABCS service to SOA server.
  44. Modify the SalesToContract BPM process.
  45. Go to the SalesToContractDemo project in JDeveloper and click on composite.xml.
  46. Go to Component Palette | SOA | Service Adapter and select JMS Adapter from the list.
  47. Drag-and-drop JMS Adapter to the exposed services swimlane. This will open the JMS adapter configuration wizard:
    How to do it...
  48. Enter name of the JMS Adapter service as ReadQuoteRequest and click on Next.
  49. Select Oracle Weblogic JMS from the JMS provider list and click on Next.
  50. Select Application Server from the drop-down list and click on Next twice.
  51. Select Consume Message from the operation type list.
  52. In the Consume Operation Parameters, click on the "browse" button next to Destination Name and select QuoteReqQueue from the resource list. This was you are configuring the Adapter Service to be a consumer:
    How to do it...
  53. Let JNDI Name be eis/wls/Queue, which you have used for the produce operation also.
  54. Click on Next.
  55. In the Messages dialog, click on the Browse button to choose the message type for the JMS payload. Select Quote | QuoteRequest from Quote.xsd in the project schema:
    How to do it...
  56. Click on OK.
  57. Click on Next, on the Messages dialog.
  58. Click on Finish.
  59. When you have finished this, click on Save.
  60. This will create a service in the exposed service swimlane.
  61. Click on the SalesToContract process in the project.
  62. Right-click on Start | Change Trigger Type | Message:
    How to do it...
  63. In Properties, go to the Implementation tab and select Interface from Catalog from the Implementation drop-down.
  64. Click on the "browse" button next to Name and select the JMS service ReadQuoteRequest created as consumer from the list:
    How to do it...
  65. Click on OK and an operation consume message will automatically pop up.
  66. Check the data association and click on the pencil button next to it.
  67. In the Data Associations editor, drag-and-drop quote from the data object list into the Output section:
    How to do it...
  68. Click on OK.
  69. Check the Use Transformation checkbox and click on the pencil edit button ahead of it.
  70. In the Create Transformation dialog, click on the green plus (+) icon to select the source. Select QuoteRequest as the source and quote as the target.
    How to do it...
  71. Select the Create radio button, enter Transform_QuoteRequest_Quote as the transformation name, and click on OK twice.
  72. Click on the OK button on the Properties dialog, too.
  73. Create the transformations, as shown in the following screenshot and click on Save All:
    How to do it...
  74. You are now at the SalesToContract process designer.
  75. Remove the Enter Quote task and initiate Quote Script.
  76. An auto link will be created between the Start message and the CustomerCheck decision rule.
  77. Click on the Start activity and rename it to QuoteRequest.
  78. Change the sequence flows.
  79. There are two instances when, if the quote gets rejected, it returns to the salesrepresentative user through the EnterQuote task when the customer check outcome fails and when the deal or term is rejected.
  80. Go to Component Palette | BPM | Activities | Error End Event.
  81. Click on Next to CustomerCheckOutcome gateway on the salesrepresentative swimlane.
  82. Rename Error End Event to EndCustomerCheck.
  83. In the Implementation tab, select BusinessReviewRejectFault and create a data association for it. Remember, you have created BusinessReviewRejectionFault in the Handling Business Exception in a Sub process section in Chapter 8, Exception Management.
  84. Hence, whenever customer check is equal to reject, it would lead to a business fault and would be handled by the Event subprocess, which you have created in Chapter 8, to handle BusinessReviewRejectFault:
    How to do it...
  85. Create a conditional sequence flow from CustomerCheckOutcome to EndCustomerCheck and name it CustomerRejected with a simple condition, as follows:
    CustomerCheck == "REJECT"
    
  86. Go to Component Palette | BPM | Activities and click on Error End Event.
  87. Click on in the Contracts swimlane, just above the Approval Outcome gateway
  88. Rename Error End Event to EndDealORTerms.
  89. In the Implementation tab, select BusinessReviewRejectFault and create a data association for it. Remember, you created BusinessReviwRejectionFault in Chapter 8.
  90. Hence, whenever a deal or term is equal to reject, it would lead to a business fault and would be handled by the Event subprocess, which you have created in Chapter 8, to handle BusinessReviewRejectFault.
  91. Point Deal or Terms Rejected sequence flow to EndDealORTerms End Event.
  92. When you have finished this, click on Save.
  93. Deploy and test.
  94. Deploy the project. Refer to the Deploying the BPM project section in Chapter 3, Process Deployment and Testing if required.
  95. Run the Supplier_ABCS service. This will post quote message on QuoteReqQueue JMS Queue
  96. Once the message is on the QuoteReqQueue JMS Queue, an instance will be created for the SalesToContract process, too, as your SalesToContract process is subscribed to the queue and it's listening to it.
  97. You can verify the same by viewing the instance flow from Oracle EM console
  98. Log in to Oracle EM Console and click the instance ID created for the SalesToContract process
  99. This will open the flow trace page.
  100. In the Audit Trail Tab, you can find the process activity list.
  101. You can verify that an instance has been created for the Start activity, and quote payload can be verified by clicking on the activity details, too:
    How to do it...

How it works...

Web services, such as BPEL/Mediator Service or OSB, can post messages on JMS Queues, and Oracle BPM can subscribe and listen to those queues. A message on the queue will result in instance creation, based on the incoming message.

When Supplier_ABCS puts a Quote Message on QuoteReqQueue, SalesToContract process is listening to the same queue and hence an instance gets created. You can carry forward the process movement the way you did every time. Log in as a Business Analyst user and approve/reject the queue.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.235.62