Hello Friends I would like to share scenario
on
usage UCA’s in BPM.
Scenario :-( Order Submit Process)
This Scenario aim to know about how
to integrate existing web application with new Process App, An external user submits
the Order from web page and it will invoke Process Application in process
center and send Order id back to end user.
Please post any issues/query’s related to BPM,WODM and DATAPOWER to "mdondetisbit@gmail.com
About Usage
of UCA’s:-
The
UCA creates a bridge between external systems and business process definitions
(BPDs). You can manage inbound and outbound communication with external systems
using UCAs. The UCA listens for events from external systems through a message
or specific schedule. If you want to post a message to the JMSlistener, the
Event Manager has a defined XML message structure that it must receive from an
external system. The UCA is responsible for firing either a Start Message Event
or an Intermediate Message Event that is contained within a BPD.
The following
queues are associated with a UCA:
Async queue:
Allows Event Manager jobs to run at the same time.
SYNC_QUEUE_1:
Forces one job to finish before the next job can start. Bydefault, three
synchronous queues are available.
SYNC_QUEUE_2:
Forces one job to finish before the next job can start. Bydefault, three
synchronous queues are available.
SYNC_QUEUE_3:
Forces one job to finish before the next job can start.
By default, three synchronous queues
are available. All of these queues gets initialized at the time of server start
up.
General System Service for UCA:-(UCAService)
We can call
it as event handler service,In this application Created general system service with name “UCAService” which transfers data(Order Details ) from external
app to Process App as shown in below
fig.
An event handler service is nothing
but a General System service, which is the heart of a UCA. This service
receives the data from external stimulus and sends it to a BPD process through
the UCA. You need to define and map output data to input data explicitly for
this service, otherwise the output data would be null. The data defined for
this service should be same as the input data required by the BPD process.
Variables
Used in UCA Service:-
Input output variables: UcaComplexInput,
UcaComplexOutput
Creating OrderUCA:-
You must create the UCA before it
can be referenced. To create a UCA and associate it with the General System
service
Scheduler Type:OnEvent
Event Message: OrderBOUCA(This name will be used in coding)
Creating BPD in Process Application:-
This BPD receive order details from
external webpage and do business logic and returns Order Id to end user.
Used Message Start event to receive
the events from web application and configures
created OrderUCA as shown in fig.
Finally Expose this BPD and Business
Data to Start for required user in my
case AllUsers.
Web Application (Order
Submit client):-
Send
a message to the Event Manager:-
To invoke a BPD process by sending
application data through the UCA, you need to encapsulate data in a predefined
XML structure with event msg as the root, as shown in the following listing
String
data="<eventmsg><event processApp=\"ODUT\"
snapshot=\"OrderSnap1\"
ucaname=\"OrderUCA\">OrderBOUCA</event><parameters><parameter><key>UcaComplexInput</key><value><itemNo>"+itemNo+"</itemNo><itemName>"+itemName+"</itemName><price>"+price+"</price><quantity>"+quantity+"</quantity><cname>"+cname+"</cname><address>"+address+"</address></value></parameter></parameters></eventmsg>";
Notice that you need the following information available to
include in the XML header:
snapshot: Process snapshot name; created through Process
Center. in this case OrderSnap1.
ucaname: UCA name; available in the UCA editor in Process
Center.in this case, OrderUCA.
processApp: The process name; this acronym is provided when
you create a new process app.in this case ODUT.
event: The event name; in this case, OrderBOUCA.
key : The input object name defined in the UCA service.( UcaComplexInput).
For more information about
MessageStructure go through below link.
Servlet code(Jms
Client App to send event to Queue):-
package com.eai.jms;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
/**
* Servlet
implementation class OrderSubmitServlet
*/
public class OrderSubmitServlet extends HttpServlet {
private static
final long serialVersionUID = 1L;
/**
* @see
HttpServlet#HttpServlet()
*/
public OrderSubmitServlet() {
super();
// TODO
Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest
request, HttpServletResponse response)
*/
protected void
doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
// TODO
Auto-generated method stub
doPost(request,response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest
request, HttpServletResponse response)
*/
protected void
doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
// TODO
Auto-generated method stub
try{
String
itemNo=request.getParameter("itemNo");
String
itemName=request.getParameter("itemName");
String
price=request.getParameter("price");
String
quantity=request.getParameter("quantity");
String
cname=request.getParameter("cname");
String
address=request.getParameter("address");
String
data="<eventmsg><event processApp=\"ODUT\"
snapshot=\"OrderSnap1\"
ucaname=\"OrderUCA\">OrderBOUCA</event><parameters><parameter><key>UcaComplexInput</key><value><itemNo>"+itemNo+"</itemNo><itemName>"+itemName+"</itemName><price>"+price+"</price><quantity>"+quantity+"</quantity><cname>"+cname+"</cname><address>"+address+"</address></value></parameter></parameters></eventmsg>";
System.out.println("UCA
Servlet Invoked" +"\n"+data);
InitialContext
ctx=new InitialContext();
//QueueConnectionFactory
ucaqcf=(QueueConnectionFactory)ctx.lookup("javax.jms.QueueConnectionFactory");
QueueConnectionFactory
ucaqcf=(QueueConnectionFactory)ctx.lookup("javax.jms.QueueConnectionFactory");
Queue
ucaqueue=(Queue)ctx.lookup("jms/eventqueue");
System.out.println("ucaqueue::
"+ucaqueue);
QueueConnection
connection=ucaqcf.createQueueConnection();
System.out.println("QCF::
" +ucaqcf +" queueconnection:: " +connection);
Session
session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
System.out.println("session::
" +session);
MessageProducer
producer = session.createProducer(ucaqueue);
//ObjectMessage
message = session.createObjectMessage();
TextMessage
message = session.createTextMessage();
message.setText(data);
System.out.println("Message:: " +message);
producer.send(message);
System.out.println("Message Sent");
//}
}catch(Exception
t){
t.printStackTrace();
}
}
}
Running application:-
- Click on Submit Order Button on below webpage .And check the created new Process instance id in Inspector view in Designer or By Login into Process Portal.
- We can also monitor and clear eventQueues by using Process Admin Console.
Trouble Shooting :-(Resolving JMS Security Exception)
Common error with JMS client program.Go through the below link to resolve it
I hope this
post helps you. So far this is my best effort to explain. Please correct me if
I do anything wrong.
Please
share your valuable suggestions and feedback to my mail id"mdondetisbit@gmail.com" to
improve myself.
Please post any issues/query’s related to BPM,WODM and DATAPOWER to "mdondetisbit@gmail.com
Congratulation for the great post. Those who come to read your Information will find lots of helpful and informative tips. Business Process Management
ReplyDelete