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.
In this section, you will learn how to initiate the BPMN process using JMS:
- Create a JMS Queue.
- Log in to Oracle EM console as weblogic user.
- In the domain structure, expand Services | Messaging and click on JMS Modules.
- In the JMS Modules list, on the right-hand side of the domain structure, click on SOAJMSModule:
- You will create a JMS Queue. These queues are configured and stored as modules.
- 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:
- 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.
- 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: - 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. - When you select SOASubDeployment, a list of targets is presented. Select SOAJMSServer and click on Finish:
- Go back to SOAJMSModule | Configuration tab. In the list of resources, you will find QuoteReqQueue listed. Verify the Subdeployment and Targets:
- Create Supplier_ABCS BPEL service Message Producer Service.
- Open JDeveloper in default mode.
- 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.
- In the Create SOA Project dialog, enter
Supplier_ABCS
as the Project Name, make sure SOA is selected, and click on Finish: - This will open a blank
composite.xml
designer. - Import
Quote.xsd
into the project. - 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.
- On the wizard, supply
QuoteRequest
as Service Name for the JMS adapter service: - Click on the Next button.
- In the JMS Provider, select Oracle Weblogic JMS and click on Next.
- Select the application server connection and click on Next twice.
- By now, you must be aware of having a SOA application server connection.
- 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.
- Enter other parameters for Produce Message, such as Destination Name and JNDI.
- 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:
- 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. - 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. - The schema you have chosen here will define the message payload for the JMS destination.
- Click on Finish in the last dialog.
- You will find that a JMS Adapter is created on the reference swimlane in the composite designer.
- 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.
- 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: - Create a wire between the Supplier_ABCS and JMS Adapter services in the composite designer.
- Double-click on the BPEL Service Supplier_ABCS. This will open the
Supplier_ABCS.bpel
designer. - 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
. - Create a Partner Link with the QuoteRequest JMS service. Produce Message will auto-appear as an operation.
- Click on the green plus (+) icon, to create an input variable and click on OK:
- Go to Component Palette | BPEL 1.1 | SOA Extensions and drag-and-drop the Transform activity between receive input and invoke
QuoteRequest
. - Rename it to
Transform_Input_QuoteRequest
and create a transformation between input variable and QuoteRequest_ProduceMessage_Inputvariable
. - Name transformation file
Transformation_Input_QuoteRequest.xsl
and create the transformation between source and target: - When you have finished this, click on Save.
- Deploy the Supplier_ABCS service to SOA server.
- Modify the SalesToContract BPM process.
- Go to the SalesToContractDemo project in JDeveloper and click on composite.xml.
- Go to Component Palette | SOA | Service Adapter and select JMS Adapter from the list.
- Drag-and-drop JMS Adapter to the exposed services swimlane. This will open the JMS adapter configuration wizard:
- Enter name of the JMS Adapter service as
ReadQuoteRequest
and click on Next. - Select Oracle Weblogic JMS from the JMS provider list and click on Next.
- Select Application Server from the drop-down list and click on Next twice.
- Select Consume Message from the operation type list.
- 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:
- Let JNDI Name be
eis/wls/Queue
, which you have used for the produce operation also. - Click on Next.
- 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:
- Click on OK.
- Click on Next, on the Messages dialog.
- Click on Finish.
- When you have finished this, click on Save.
- This will create a service in the exposed service swimlane.
- Click on the SalesToContract process in the project.
- Right-click on Start | Change Trigger Type | Message:
- In Properties, go to the Implementation tab and select Interface from Catalog from the Implementation drop-down.
- Click on the "browse" button next to Name and select the JMS service ReadQuoteRequest created as consumer from the list:
- Click on OK and an operation consume message will automatically pop up.
- Check the data association and click on the pencil button next to it.
- In the Data Associations editor, drag-and-drop quote from the data object list into the Output section:
- Click on OK.
- Check the Use Transformation checkbox and click on the pencil edit button ahead of it.
- 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.
- Select the Create radio button, enter
Transform_QuoteRequest_Quote
as the transformation name, and click on OK twice. - Click on the OK button on the Properties dialog, too.
- Create the transformations, as shown in the following screenshot and click on Save All:
- You are now at the SalesToContract process designer.
- Remove the Enter Quote task and initiate Quote Script.
- An auto link will be created between the Start message and the CustomerCheck decision rule.
- Click on the Start activity and rename it to
QuoteRequest
. - Change the sequence flows.
- 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. - Go to Component Palette | BPM | Activities | Error End Event.
- Click on Next to CustomerCheckOutcome gateway on the salesrepresentative swimlane.
- Rename
Error End Event
to EndCustomerCheck
. - 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.
- 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:
- Create a conditional sequence flow from CustomerCheckOutcome to EndCustomerCheck and name it CustomerRejected with a simple condition, as follows:
- Go to Component Palette | BPM | Activities and click on Error End Event.
- Click on in the Contracts swimlane, just above the Approval Outcome gateway
- Rename
Error End Event
to EndDealORTerms
. - In the Implementation tab, select BusinessReviewRejectFault and create a data association for it. Remember, you created BusinessReviwRejectionFault in Chapter 8.
- 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.
- Point Deal or Terms Rejected sequence flow to EndDealORTerms End Event.
- When you have finished this, click on Save.
- Deploy and test.
- Deploy the project. Refer to the Deploying the BPM project section in Chapter 3, Process Deployment and Testing if required.
- Run the
Supplier_ABCS
service. This will post quote message on QuoteReqQueue JMS Queue - 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.
- You can verify the same by viewing the instance flow from Oracle EM console
- Log in to Oracle EM Console and click the instance ID created for the SalesToContract process
- This will open the flow trace page.
- In the Audit Trail Tab, you can find the process activity list.
- 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 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.