Chapter 2. Reference Architecture Environment

2.1. Project Modules

This reference architecture takes advantage of the provided Red Hat JBoss Intelligent Process Server and Enterprise Application Platform 7 container images and templates. The application discussed within this reference architecture consists of three modules:

  • ocp-credit-service: A simple web service which takes a mortgage loan applicant’s social security number and returns their credit score. The simple Credit Report Web Service source code has been included in the resources accompanying this document.
  • ocp-mortgage-rules: The rule repository, or Knowledge Store, which houses the rules and BPMN 2.0 process definitions, which together define the Mortgage Loan business process. The rule repository can also be found within the resources accompanying this document.
  • ocp-mortgage-dashboard: Each step within the Mortgage Loan business process (e.g., submitting an application, data correction, appraisal, final approval, and so forth) is represented as a tab in the user interface. Relevant information regarding the various steps is fetched, modified accordingly, and submitted via the UI in order to move the loan process along. While the final source code can be found within the resources accompanying this document, it’s recommended that the user follow the exercises outlined herein to establish a similar project of their own as this portion encapsulates the most pertinent information in working with BPM Suite capabilities on OpenShift Container Platform (OCP).

2.2. Credit Service

The Credit Service is a Java EE web service hosted on a JBoss Enterprise Application Platform 7 container image on the OpenShift Container Platform (discussed in further detail below). The Mortgage Loan business process which will reside on the Intelligent Process Server contains a step which will reach out to the credit service in order to determine the credit score of an applicant for inclusion in the application information prior to proceeding on to borrower qualification.

2.3. Mortgage Rules and Intelligent Process Server

As a review, Red Hat JBoss BPM Suite (BPMS) 6.3 is an open source BPM suite that combines business process management and business rules management, enabling business and IT users to create, manage, validate, and deploy business processes and rules. BPMS 6.3 provides advanced business process management capabilities compliant with the widely adopted BPMN 2.0 standard. The primary goal of BPMN 2.0 is to provide a notation that is readily understandable by all business users, from the business analysts that create the initial drafts of the processes, to the technical developers responsible for implementing the technology that will perform those processes, and finally, to the business people who will manage and monitor those processes. Thus, BPMN 2.0 creates a standardized bridge for the gap between the business process design and process implementation.

BPMS 6.3 includes Realtime Decision Server and Intelligent Process Server, both which serve as standalone, out-of-the-box components that can be used to instantiate and execute rules and processes, respectively, in provisioned containers through interfaces available for REST, JMS or a Java client side application. These self-contained environments encapsulate a compiled rule package and deployed rule instance, thus allowing for a looser coupling of rules and the execution code of the application. Both decision servers ship with default extensions for JBoss BRMS and BPM Suite via Intelligent Process Server. These servers, based on the KIE Execution Server, have low footprints, with minimal memory consumption, and therefore, can be deployed easily on a cloud instance. Each instance can open and instantiate multiple KIE Containers which allows execution of multiple rule services in parallel. Further reading on the KIE Servers' advantages of decoupling rules execution from authorship and maintenance, more information on the deployment, management, and interacting with the Realtime Decision and Intelligent Process Servers can be found in the Red Hat JBoss BRMS 6.3 User Guide.

Business rules, process definition files and other assets and resources created in BPM Suite’s Business Central during rule development phases are stored in the asset repository called the Knowledge Store. The Knowledge Store is a centralized repository for business knowledge which uses a Git repository to store its data. This document is not intended to cover the basics of authoring processes via BPM Suite functionality, already covered in length as part of the Business Process Management with Red Hat JBoss BPM Suite 6.3 Reference Architecture, and Mortgage Loan business process created via Business Central therein. This paper will, however, build on the concepts and rules developed within that project, using the Knowledge Store as the executable rule base that’s called by our new user interface and backend. With the process already authored, the new application will provide a means to progress a loan through the various steps included in the aforementioned business process. Given the relation, familiarity with the Business Central example from the linked paper will greatly increase the understanding of which components are emulated via REST and Java application interfaces herein, thus it’s recommended that you work through that project or, at the least, briefly familiarize yourself with the functionality it contains prior to proceeding.

2.4. Mortgage Dashboard

The User Interface is written in Java and JavaScript using the PatternFly and AngularJS frameworks. The Java portion of the application utilizes the kie-server’s REST and Java APIs to query, trigger, and manage steps throughout the Mortgage Loan business process.

2.4.1. PatternFly

PatternFly is an open source project that promotes design commonality and improved user experience. It’s a place where open source developers and designers can collaborate, create, and share user interface (UI) components and widgets. PatternFly is based on Bootstrap, a mobile-first front-end framework for creating web sites and applications. More information on the PatternFly library, including available styles and guides for working with the framework, can be found at the official PatternFly website.

2.4.2. AngularJS

According to the official AngularJS Documentation, "AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML’s syntax to express your application’s components clearly and succinctly. Angular’s data binding and dependency injection eliminate much of the code you would otherwise have to write. And it all happens within the browser, making it an ideal partner with any server technology." The JavaScript framework allows for declarative decoupling of DOM logic from application logic, thereby giving a clean, straight-forward approach to utilizing controllers and services to interact with the Mortgage Dashboard’s backend Java functionality.

2.4.3. Remote KIE Server API

JBoss BPM offers a number of Client classes in the org.kie.server.client package for accessing and manipulating business processes remotely via Java. Some of the most prominent classes available follow:

  • KieServicesConfiguration: used to specify configuration details, such as the REST URL, user name, user password, marshalling format, and more.
  • KieServicesClient: Base class for all clients which houses a few shared functionalities, such as container manipulation and server interaction.
  • KieServicesFactory: Factory class responsible for building KieServicesConfiguration objects as well as new use-specific KieServicesClient instances.
  • ProcessServicesClient: allows fetching of process details, process manipulation, and user task input/output definitions
  • QueryServicesClient: used for fetching of processes using a multitude of different search criteria as well as querying against the ruleset.
  • RuleServicesClient: useful when needing to perform command execution against the ruleset.
  • UserTaskServicesClient: responsible for fetching, claiming, starting, stopping, releasing, etc. tasks. Also can be used to fetch task Input/Output by taskId and manipulate comments and attachments related to a task.

Example client configuration and instantiation:

KieServicesClient client = null;
        try {

            KieServicesConfiguration conf = KieServicesFactory.newRestConfiguration(
                    Configuration.REST_BASE_URI,
                    user.username(),
                    user.password());

            conf.setMarshallingFormat(MarshallingFormat.JSON);

            client = KieServicesFactory.newKieServicesClient(conf);

        } catch (Exception e) {
            logger.error("ERROR in initializing REST client...", e);
        }
        return client;

2.5. OpenShift Container Platform 3.3

Red Hat OpenShift Container Platform 3.3, or OCP, provides compute services on-demand. It allows developers to create and deploy applications by delivering a consistent environment for both development and run-time life-cycle that requires no server management. It also enforces software management and aids in the development and operations management of services by providing visibility and stability for the users.

OCP is supported across multiple platforms, however, the infrastructural details and administration of the base OCP system is beyond the focus of this document, which is intended as a guide for developer-level usage of the OCP platform and its various features. Rather than delve into details on how to establish the OCP deployment with redundancy and interactivity on a host platform like RHOSP, this paper aims to assist with the usage of images and templates to generate container-capable server/application instances and describe other tooling available via the OCP command line interface which allows a developer to build, deploy, and test their application in the development phase. Once complete, the container can be promoted to other environments as-is so that others may utilize and experience the instances consistently with that which was used in development. Support documentation for installation on other platforms may also be found in the Red Hat Reference Architecture Catalog.

2.5.1. Command Line Interface

The OpenShift Container Platform provides a command line interface (CLI) for creating applications and managing OpenShift projects from a terminal. The CLI is ideal in situations where you are working directly with project source code, scripting OpenShift operations, have restricted bandwidth resources.

The CLI is available using the oc command:

$ oc <command>

For further information, refer to the official Red Hat OpenShift Documentation for installation and setup instructions.

2.5.2. Image Streams

Containers are based on images. An image is a binary that includes all of the requirements for running a single container, as well as metadata describing its needs and capabilities. You can think of it as a packaging technology. Containers only have access to resources defined in the image, unless you give the container additional access when creating it. As alluded to previously, by deploying the same image in multiple containers across multiple hosts and load balancing between them, OpenShift can provide redundancy and horizontal scaling for a service packaged into an image.

OpenShift also supplies builders that assist with creating an image by adding your code or configuration to existing images. An image stream can be used to automatically perform an action, such as updating a deployment, when a new image, such as a new version of the base image that is used in that deployment, is created. An image stream comprises one or more Docker images identified by tags. It presents a single virtual view of related images, similar to a Docker image repository, and may contain images from any of the following: its own image repository in OpenShift’s integrated Docker Registry, other image streams, or Docker image repositories from external registries. OpenShift components such as builds and deployments can watch an image stream to receive notifications when new images are added and react by performing a build or a deployment.

Example Image Stream Object Definition:

{
  "kind": "ImageStream",
  "apiVersion": "v1",
  "metadata": {
    "name": "origin-ruby-sample",
    "namespace": "p1",
    "selfLink": "/osapi/v1/namespaces/p1/imageStreams/origin-ruby-sample",
    "uid": "480dfe73-f340-11e4-97b5-001c422dcd49",
    "resourceVersion": "293",
    "creationTimestamp": "2015-05-05T16:03:34Z",
    "labels": {
      "template": "application-template-stibuild"
    }
  },
  "spec": {},
  "status": {
    "dockerImageRepository": "172.30.30.129:5000/p1/origin-ruby-sample",
    "tags": [
      {
        "tag": "latest",
        "items": [
          {
            "created": "2015-05-05T16:05:47Z",
            "dockerImageReference": "172.30.30.129:5000/p1/origin-ruby-sample@sha256:4d3a646b58685449179a0c61ad4baa19a8df8ba668e0f0704b9ad16f5e16e642",
            "image": "sha256:4d3a646b58685449179a0c61ad4baa19a8df8ba668e0f0704b9ad16f5e16e642"
          }
        ]
      }
    ]
  }
}

2.5.3. Source to Image (S2I)

Image Streams usage allows for applications to be injected into containers via source-to-image. S2I is a tool for building reproducible Docker images; the new image incorporates the base image (the builder) and built source and is ready to use with the docker run command. S2I supports incremental builds, which re-use previously downloaded dependencies, previously built artifacts, etc. In short, S2I allows us to take an EAP or Intelligent Process Server Image which establishes the base requirements for the container and inject our rules or application into the image.

2.5.4. Templates

A template describes a set of objects that can be parameterized and processed to produce a list of objects for creation by OpenShift. The objects to create can include anything that users have permission to create within a project, for example services, build configurations, and deployment configurations. A template may also define a set of labels to apply to every object defined in the template.

A template describes a set of related object definitions to be created together, as well as a set of parameters for those objects. For example, an application might consist of a front-end web application backed by a database; each consists of a service object and deployment configuration object, and they share a set of credentials (parameters) for the front-end to authenticate to the backend. The template can be processed, either specifying parameters or allowing them to be automatically generated (for example, a unique DB password), in order to instantiate the list of objects in the template as a cohesive application.

Example YAML Template Object Definition:

apiVersion: v1
kind: Template
metadata:
  name: redis-template
  annotations:
    description: "Description"
    iconClass: "icon-redis"
    tags: "database,nosql"
objects:
- apiVersion: v1
  kind: Pod
  metadata:
    name: redis-master
  spec:
    containers:
    - env:
      - name: REDIS_PASSWORD
        value: ${REDIS_PASSWORD}
      image: dockerfile/redis
      name: master
      ports:
      - containerPort: 6379
        protocol: TCP
parameters:
- description: Password used for Redis authentication
  from: '[A-Z0-9]{8}'
  generate: expression
  name: REDIS_PASSWORD
labels:
  redis: master

2.5.5. Intelligent Process Server xPaaS Image

This image provides a means for executing business processes on JBoss BPMS Intelligent Process Server 6.3, which is a modular, standalone server component that can be used to instantiate and execute rules and processes. It exposes this functionality through REST, JMS and Java interfaces to client applications. There are a variety of images available based on persistence and interconnectivity needs. For the purposes of this document, the basic image is utilized, which includes a simple H2 database, although images exist for inclusion of both MySQL and PostgreSQL with either HornetQ or ActiveMQ messaging functionality.

2.5.6. Enterprise Application Platform (JBoss EAP) xPaaS Image

JBoss EAP, Red Hat’s Java EE-based application server runtime, is utilized as the container for deployment of the credit check web service, PatternFly, and AngularJS-based front-end application. Various capabilities provided by the container are leveraged, such as Weld Contexts, Dependency Injection and more. It should be noted that there are significant differences in supported configurations and functionality in the JBoss EAP xPaaS image compared to the regular release of JBoss EAP. Some of these differences are as follows:

  • The JBoss EAP Management Console is not available to manage OpenShift JBoss EAP xPaaS images.
  • The JBoss EAP Management CLI is only bound locally. This means that you can only access the Management CLI of a container from within the pod.
  • Domain mode is not supported. OpenShift controls the creation and distribution of applications in the containers.
  • The default root page is disabled. You may want to deploy your own application to the root context (as ROOT.war).
  • A-MQ is supported for inter-pod and remote messaging. HornetQ is only supported for intra-Pod messaging and only enabled in the absence of A-MQ.