There are several types of start events available in BPMN. First of all if you are not much familiar with BPMN processes here is some summary information about Start events, summarized from BPMN specification
Start Enevts
- The Start Event simply indicates where the process start (entry points to process)
- When trigger for start event occurs, a new process instance get created
- There are 7 types of start events for top-level BPMN processes: None, Message, Timer, Conditional, Signal, Multiple, and Parallel
- All the start events, except None Start Event, only applicable to processes used as top level process. None Start Event may used to invoke process from Call Activity
Start BPMN Process by Listening to a Message Queue/Topic
WSO2 BPS 3.5.0/3.5.1 do not support starting bpmn process by listening to a message queue. But that feature will be available OOTB in a future release. At the moment we have to achieve that with the help of WSO2 ESB.Things you need:
- WSO2 Enterprise Service Bus (WSO2 ESB 4.9.0 used for this post)
- WSO2 Business Process Server (WSO2 BPS 3.5.1 used for this post. You must have BPS 3.5.0 or higher version for BPMN support)
- ActiveMQ (5.12.0 used for this post or you can use WSO2 Message Broker too)
Architecture diagram
BPMNProcess_start_proxy is ESB proxy that consumes messages from the queue, create relevant message to start the bpmn process and make REST call to start the bpmn process. In this case ESB acts as message consumer of the queue.
Step 01 : Create BPMN process
Follow [1] for basic guide to create BPMN processHere is the BPMN process that I'm going to use
You can download it from [2]
This sample process shows approval process for placing a stock order. If the entire investment is greater that $100,000 and administrator should approve it.
Stem 02 : Configure WSO2 ESB
- First you have to enable JMS transport of WSO2 ESB. You can find instruction in [3] to configure WSO2 ESB for ActiveMQ and [4] for WSO2 Message Broker. Refer [5] for other popular massage brokers.
- Create BPMNProcess_start_proxy proxy service
- This proxy service receive stock order message and start order approval BPMN process deployed in WSO2 BPS. The proxy extract relevent information and create JSON request including those data as variables and invoke BPMN REST API available in WSO2 BPS.
Step 03 : Start Servers
Start ActiveMQStart WSO2 ESB (default port, portOffset=0, 9443)
Start WSO2 BPS (portOffset=1, 9444): start $ sh bin/wso2server.sh -DportOffset=1
Step 04 : Make Stock order
Make Stock order request to "StockOrderInQueue" message queueExecute StockQuote Client : navigate to
ant stockquote -Dmode=placeorder -Dtrpurl="jms:/StockOrderInQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.ContentTypeProperty=Content-Type&transport.jms.DestinationType=queue"
User tasks can be completed using bpmn-explorer webapp (https://localhost:9444/bpmn-explorer) and login as ‘admin’
As shown above you can start BPMN process by listening to message queue. By integration with WSO2 ESB you can start BPMN process, using any type of transport that WSO2 ESB support for example: JMS, Kafka[6].
[1] https://docs.wso2.com/display/BPS350/BPMN+Guide
[2] https://github.com/milindaperera/MilisLogBlog/tree/master/WSO2BPS/BPMN/BPMN_ESB_MQ_Integration
[3] https://docs.wso2.com/display/ESB490/Configure+with+ActiveMQ
[4] https://docs.wso2.com/display/ESB490/Configure+with+WSO2+Message+Broker
[5] https://docs.wso2.com/display/ESB490/Configuring+JMS+Transport
[6] https://docs.wso2.com/display/ESB490/Kafka+Inbound+Protocol
If this post is useful to you, any questions, corrections or for any suggestion, please leave a comment below :)
No comments:
Post a Comment