Enterprise JBoss JBPM: Creating A Scalable, Standards-Compliant and Cost-Effective SOA Environment

This excerpt from the upcoming book, Open Source SOA, addresses the Service Component Architecture (SCA), and its sister technology, Service Data Objects (SDO), emerging standards used in service-oriented architecture for creating multi-protocol, multi-language services based on reusable components.

By Jeff Davis

PAGE 2

Exception Handling

Exception handling within jBPM is a bit different than what one might imagine. When managing exceptions within jBPM, you are only dealing with those that result from any handler classes that you have created. They are not used for any sort of internal jBPM error that may have been resulted from processing within the engine itself. So, for example, if you are extending functionality with an action or assignment handler, you can trap and manage those errors using the exception handling techniques we will describe.

A source of common misunderstanding about exception handling within jBPM is whether you can use this mechanism to directly alter the flow of the process. The official documentation is rather contradictory on this matter. The upshot is this: While technically you can redirect the[m], this is strongly discouraged. Instead, the proper approach is to instead set a process instance variable, which can then direct subsequent flows by way of a decision node. In addition, you can issue an alert or notification through JMS, email etc., so that someone can perform remedial actions. In chapter 7 of the book, we illustrate how exceptions can be used in tandem with process variables to achieve what is likely the desire affect — notification of the exception to an appropriate party.

While not an advanced feature, per se, we'll next look at how Beanshell scripts can be used in lieu of Java classes for more rapid development.

Beanshell Scripting

There are times when authoring a jBPM business process that having to resort to creating a Java class for required functionality seems overkill. This is particularly true when you just need to introduce a few lines of programming logic. In the situations, you can use Beanshell scripts, which maybe more convenient and allow for more rapid application development. In addition, Beanshell expressions are also used in a variety of capacities within jBPM, such as within decision node logic. For those unfamiliar with Beanshell, it was one of the earliest Java scripting implementations, and recently has initiated the Java Community Process to become a JSR-compliant standard. It has enjoyed fairly wide support, and is included in a variety of applications as a lightweight scripting alternative to Java (visit the official web site for more details and usage documentation). The syntax and usage closely mirrors that of standard Java, so Java developers can generally pick it up quickly.

Beanshell scripts are supported in most cases where Java handler classes can be used. Thus, they can be used for actions, events, or setting process variables. In addition, Beanshell scripts are used by decision nodes. In this instance, they are a one-line statement that must evaluate to true or false (this is also true for anytime an expression attribute is also allowed).

Regardless of whether you extend jBPM functionality with Beanshell or Java, inevitably you will want the ability to log and monitor the activity that occurs within your process instance. This is whether jBPM audit logging comes into place. We also see in the next chapter how this capability can be used to generate events which can be consumed by an event stream processor, thus providing real-time metrics and monitoring into your jBPM process instances.

Audit Logging

By default, there are a variety of audit logs that are produced as a result of process instance execution. Collectively, these logs will provide you complete insight into every activity that has occurred within a process instance. How can this information be beneficial? For example, you could load it into a data warehouse for reporting and analysis. Or, perhaps monitor the data in real-time for business activity monitoring dashboards, and the like. Like nearly all aspects of jBPM, you can also extend the logging features with your own required capabilities. For example, you may wish to do this if you wanted to dynamically filter the logs for only content you deem relevant. Detailing how this can be accomplished is outside the scope of this excerpt, but is address in chapter 7 of the book.

We will now conclude our discussion of jBPM advanced features by looking into asynchronous continuations, which enables process execution to be asynchronously performed by a server process.

Asynchronous Continuations

You have likely noticed through the exercises thus far that, when you signal the execution of a process instance, it will continue to execute within the thread you are running until it encounters a wait state, such as a state or task node. At that point, you could consider the transaction to be completed. While generally this doesn't cause any problems because most transactions complete within milliseconds, there are times when that may not be the case. Do any scenarios come to mind? How about when you have a node node-type that performs a web service call to a remote system using a traditional request/reply message exchange. In that scenario, the node will block and wait until the reply is received (or it timeouts). This could have highly undesirable consequences for your process if, for example, an immediate response is anticipated (maybe it's a web order being kicked off through the BPM process, and the user is awaiting a response with an order identifier). Fortunately, there is already a built-in approach for managing this scenario directly within jBPM. It is called asynchronous continuations. How this works is best illustrated through a simple example.

Figure 3

In the process shown in Figure 3, let's assume nodes 1, 2, and 3 include Java action handlers which perform some external action. In nodes 1 and 2, those action handlers perform their work synchronously within the same transaction that the process is initiated (this is the default behavior). However, the 3rd node is specified using @async=true. What this means is that the node, and within it any Java action handlers, will be processed by an external command executor. Since node 3 is processed asynchronously, the transaction is completed and placed in a wait state (i.e., persisted) until the join node receives node 3's signal.

The jBPM Enterprise version, which runs within the context of an application server, is, by default, configured to support asynchronous continuations by way of its build-in Job Executor. The Job Executor receives its command message through a JMS queue that is automatically configured when jBPM Enterprise is run. In our example, what this means is that the jBPM Job Executor will asynchronously process node 3. Once completed, node 3's action handler instruction to signal continuance of the execution will be performed. Figure 7.6 shows the process instance just after initiation, where nodes 1 and 2 have been completed and now wait in the join node for the conclusion of node 3.

Figure 4

As Figure 4 illustrates, the asynchronous processing of node 3 occurs in three steps: 1) a JMS message that includes the action handler to be executed is sent to a JMS queue; 2) the jBPM Enterprise Server's command listener is listening for new messages submitted to the queue; and 3) once a message is received it then is sent to the command executor for processing. The command executor will initiate a new transaction from which the action handler is run, and will forward the execution onward. Although not shown, all 3 nodes will then have then completed, the join consummated, and execution moved to the end to complete the process instance.

We have now completed our coverage of some of jBPM advanced features. Others, such as how to create your own node types and integration of jBPM console security, are not covered. The jBPM User Guide does provide some guidance on these matters, and the forum and source code can be indispensable as well. We will now look at a very exciting topic, and that is how to integrate jBPM with SCA and SDO, which was the topic of chapters 3 and 4, and a key cornerstone for creating a SOA environment.


Loading...
Applications MarketSpace
Practical Approaches for Securing Web Applications
Enterprises understand the importance of securing web applications to protect critical corporate and customer data. What many don't understand, is how to implement a robust process for integrating security and risk management throughout the web application software development lifecycle. Learn more »
An Executive's Guide to Web Application Security
Since so many Web sites contain vulnerabilities, hackers can leverage a relatively simple exploit to gain access to a wealth of sensitive information, such as credit card data, social security numbers and health records. It's more important than ever to examine your Web application security, assess your vulnerability and take action to protect your business. Learn more »
Web Application Vulnerabilities
Security managers may work for midsize or large organizations; they may operate from anywhere on the globe. But inevitably, they share a common goal: to better manage the risks associated with their business infrastructure. Increasingly, Web application security plays a significant role in achieving that goal. Learn more »
Using ERP To Gain Competitive Advantage in a Tough Economy
For midsize enterprises, now is the perfect time to invest in a significant IT expansion - despite the economic climate. Learn more »
Why BI is Ripe For Businesses of Any Size
Oracle's range of offerings to mid-size and emerging companies reflects its vision that BI and EPM solutions can be embraced by companies of all sizes. Learn more »
Oracle Accelerate
Ovum has been following Oracle's Accelerate program over the last couple of years because they thought it is a smart strategy for penetrating the upper mid-market. Learn more »
The New Age of ERP
Not only can small and mid-sized companies reap the renowned ERP benefits of greater agility, increased business visibility and measurable ROI. Learn more »
 
SPONSORED LINKS
 

CRM Built for IT: The Executive Guide to Selecting CRM that Meets IT Needs

ROI of Application Delivery Controllers

White Paper: 4 Customer Service Myths

White Paper: Improve Agility with Operational Responsiveness

Removing the Barriers to IT Governance: How On-Demand Software Changes the Game

Cloud Computing--Latest Buzzword or a Glimpse of the Future?

A Balanced Approach to an Application Development Platform

Adobe® LiveCycle®solutions for intuitive user experience

10 Ways Excel Drives More Value from Your SAP Investment

What's New in SOA Suite 11g?

Unleash the Power of Java with Oracle JRockit Real Time

SOA Best Practices and Design Patterns

Application Grid: Ideal Platform for IT Consolidation

Ready to virtualize tier one applications? Check your virtualization maturity.

Learn how to provide complete Business Service Management.

Increase ROI of Your Application Portfolio

Return on Information: Google Enterprise Search pays you back. Get the facts.

VMware. The source for Business Infrastructure Virtualization.

ShoreTel tells businesses to untangle from competitors' complexity and turn to its brilliantly simple UC solution

See how AT&T can help protect your network.

Streamline IT Costs. Boost Performance with WAN Optimization.

Build your 1st app FREE with Force.com

TDWI checklist helps define data readiness for analytics. Download report.

eZine: A Roadmap to Reducing IT Complexity

Reduce risk, gain agility. See how Progress can help your business.

What's Next for Enterprise Resource Planning?

Gartner Magic Quadrant, Application Delivery Controllers 2009

White Paper: Managed Security for a Not-So-Secure World

SharePoint - Unchecked growth of content is unsustainable.

Focus Under Pressure: Why IT Governance Becomes Mission-Critical in a Down Economy

Should Your Email Live In The Cloud? A Comparative Cost Analysis

Adobe® LiveCycle® solutions for business process automation

Architecting Business Intelligence Applications for Change: The Open Solution

Increase UPS efficiency without sacrificing protection.

Unlocking the Mainframe: Modernizing Legacy System to SOA

State of the Data Integration Market

Enhance Customer Loyalty through Higher Responsiveness

Achieving Business Agility with Application Grid

Seven Ways ITIL Can Help You in an Economic Downturn

Four steps to populate your CMDB.

"Enterprise-Proven" is the Prerequisite for Enterprise SaaS Portal Solutions

AT&T Synaptic Storage as a Service. Expand on demand

Trend Micro ranked #1 against real-world malware. Read more.

Webinar: Jump-start your in-house e-discovery with Ringtail QuickCull from FTI Technology

Top Five CIO Challenges

Read the RSA report: Security for Business Innovation

64-page prescriptive guide to security, compliance, and IT operations.

A Clear View Toward Virtualization

Virtualization Technology as a Business Solution

The rules of infrastructure management just changed.

 
 
RESOURCE CENTER