Chapter 1. Introduction

1.1. Scope and target audience

This is a tutorial that introduces the Process Virtual Machine library to Java developers.

1.2. Processes and executions

With this library you can build executable process graphs. The key features of this library are

  • Create executable processes that are based on a diagram structure
  • Runtime behaviour of the nodes can be provided as Activity implementations
  • Activities can be wait states
  • There are no constraints on the process graph structure
  • Processes diagrams can be based on composition (aka block structured)
  • Processes diagrams can be a mix of graph based and composition
  • During wait states, the runtime state of a process execution can be persisted
  • Persistence is optional

Process definitions are static and define an execution analogue to a Java class. Many executions can be run against the same process definition. One execution is also known as a process instance and that is analogue to a Java object. An execution maintains the current state for one execution of the process, including a pointer to the current node.

1.3. Overview

1.3.1. Part One

The first part of this manual gives a thorough introduction on how to implement Activity's. This means creating the runtime implementation for the process constructs (aka activity types) that are defined in the process languages.

Chapter 2, Basic graph execution explains how to create process graphs, how process graphs are executed and how Activities can be build that implement the runtime behaviour of nodes in the process graph.

Chapter 3, Examples uses the basic graph execution techniques to show how concrete activities are implemented in meaningfull setting.

Chapter 4, Advanced graph execution explains the more fine grained details of graph execution like the relation to threads, looping, sub processes and so on.

Chapter 5, Delegation classes are Java classes that are used as part of the process execution, but are not part of the pvm library.

Chapter 6, Variables captures contextual information related to a process execution. Think of it as a Map<String, Object> that is associated with a process execution.

Chapter 7, History shows the infrastructure for generating auditable events from the process. This is the information that will be fed into the history database that can be queried for statistical information about process execution (aka Business Intelligence).

1.3.2. Part Two

The second part explains the embeddable infrastructure. That infrastructure makes it possible to use multiple transactional resources inside the process execution and configure them to operate correctly in standard and enterprise Java.

Chapter 8, Environment is the core abstraction layer for the specific Java environment in which the process operates. Transactional resources can be fetched from the environment. The environment will take care of the lazy initialization of the transactional resources based on the configuration.

Chapter 9, Persistence shows how process definitions and process executions can be stored in a relational database. It is also explained how hibernate is integrated into the environment and how concurrency is handled.

Chapter 10, Services are the session facades that are exposed to programmatic clients using the PVM functionality. They are based on commands and use the environment infrastructure.

1.3.3. Part Three

Part three explains two PVM infrastructure features that are based on transactional resources and require the execution in separate a thread. The job executor that is part of the PVM can execute jobs in a standard Java environment. Alternatively, there are implementations for messaging and timers that can be bound to JMS and EJB Timers respectively in an enterprise environment.

Chapter 11, Asynchronous continuations are declarative transaction demarcations in a process. This functionality depends on an asynchronous messaging service.

Chapter 12, Timers can fire pieces of user code, related to an execution in the future.

1.3.4. Part Four

In pPart four, Chapter 13, Process languages describes the main steps involved in building a complete process language implementation.

1.4. JVM version

jbpm-pvm.jar requires a JVM version 5 or higher.

1.5. Library dependencies

For building and executing processes the jbpm-pvm.jar does not have any other dependencies then on the JVM. If you're using DB persistence, then there is a dependency on hibernate and it's dependencies. More information about the optional depedencies can be found in the lib directory.

1.6. Logging

All jBPM modules use standard java logging. If you don't like the verbosity of the 2-line default logging output, Here's how you can configure a single line logging format in the code without using the -Djava.util.logging.config.file=... command line parameter:

InputStream stream = YourClass.class
        .getClassLoader()
        .getResourceAsStream("logging.properties");

try {
  LogManager.getLogManager().readConfiguration(stream);
} finally {
  stream.close();
}

Typically such code would be put in a static block in one of the first classes that is loaded in your application. Then put a logging.properties file in the root of the classpath that looks like this:

handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = FINEST
java.util.logging.ConsoleHandler.formatter = org.jbpm.util.JbpmFormatter

# For example, set the com.xyz.foo logger to only log SEVERE messages:
# com.xyz.foo.level = SEVERE

.level = SEVERE
org.jbpm.level=FINEST
org.jbpm.tx.level=FINE
org.jbpm.wire.level=FINE

1.7. Debugging persistence

When testing the persistence, following logging configurations can be valuable. SQL shows the SQL statement that is executed and type shows the values of the parameters that are set in the queries.

org.hibernate.SQL.level=FINEST
org.hibernate.type.level=FINEST

And in case you get a failed batch as a cause in a hibernate exception, you might want to set the batch size to 0 like this in the hibernate properties:

hibernate.jdbc.batch_size = 0

Also in the hibernate properties, the following properties allow for detailed logs of the SQL that hibernate spits out:

hibernate.show_sql = true
hibernate.format_sql = true
hibernate.use_sql_comments = true