OSB Result Caching Best Practices

Different caching strategies that we have are :
 Out-Of-Process
             In-Process
§           

         In In-process strategy,  we are using the same JVM memory for cache,JDBC, JMS,transformations, Proxy Services and Business Services. If we increase our cache usage to a high volume, we can potentially run out of memory and thus compromise all other services in the Enterprise Service Bus, even the ones that are not using cache features. 

if your osb application consumes more heap space with Result Caching then we can go with out-of-process. In out-of-process Coherence server can be set up to run in their own JVMs to hold the cached results. They are termed “out-of-process” because they execute in a JVM different from the OSB JVM. The technique here is to allocate data off the OSB JVM letting the Coherence servers use their own heap space without affecting the heap space OSB uses to process messages. This technique is also called off-heap caching. 



Caching in OSB

As osb acts as integration layer between client and enterprise applications, often there will be requirement to store external system result to in-memory instead of invoking the external system again and again. In osb we can achieve this functionality by using Result caching feature in business service.


If you use business services that return results that do not change often, you can configure those business services to cache results. When you enable result caching, the service returns results from the cache rather than invoking the external service. This configuration improves performance by reducing network overhead to access the external service. Result caching also helps improve scalability by reducing the load on the back-end servers that host the external service.

Below Figure illustrates, a client invoking a business service and receiving a response from external service and that result will be cached into cache. In the next subsequent requests result will be fetched from cache instead of invoking external service.





How Result Caching Works



Each cached result is uniquely identified by a cache key that is made up of the ServiceRef, the operation being invoked, and a cache token string. The cache token helps to uniquely identify a single cache result among other cache results for one business service. You control the value of the cache token. You can set the cache token either by configuring the cache token expression in the result caching configuration for the business service or by using the cache-token metadata element in $transportMetaData using the pipeline.

  • Cache Token - The token configured in Business Service (e.g - Customer ID)
  • ServiceRef - Service Type (i.e - BusinessService) + Fully qualified path name of the service (e.g - <OSBProjectName>/<Business>/<BusinessServiceName>)
  • Operation - Operation name of the business service.

If the business service locates cached results through a cache key, it returns those cached results to the client instead of invoking the external service directly.






Application creation in PRPC

PRPC Tool after installation

                            Default Credentials Login Id and password

                                 Login Id : administrator@pega.com
                                 Password: install

                          In this we can create New Application under the 'PegaRules'

Creates an application in PRPC Tool following this steps 


STEP - 1 : Identify and create all the required properties.

STEP - 2 :  Design UI by creating ' sections' drag and drop the above created properties on to the 
                   layouts of sections .

STEP - 3 : Create a Flow Action, call the above created sections into this flow actions.

STEP - 4 : Create a flow, call the above created Flow Action into the flow by using an assignment 
                  shape create a Work Object for the above created flow, save the flow and Run it.


PRPC BASICS 


 CLASS :


              Class is a unit under which we define the objects 

     Types of Classes:


                              1. Abstract Class

                              2. Concrete Class

Abstract class: 

                             In abstract class we can create the objects but we can cannot implement our business. i.e we can create the reusable business logic that can be shared by its sub classes (child class)
    
                          I.e, Abstract classes meant for re usability and can't be instantiated.

Concrete class:

                             In concrete class we can create the objects and we can run the business. If we want to run the business concrete class is must and concrete classes can be instantiated.


Understanding inheritance in pega 

Inheritance :

                          Maintain the parent and child relationship between the classes.

                 EX: If we have two classes ABC and XYZ, If XYZ is inherited from ABC, 

Then XYZ is a Child class and ABC is a Parent class.

Child class can utilize all the properties of parent class, but parent class can't utilize the properties of child class.
                                                ABC  ( Abstract Class)
                                                    |         (Inheritance)
                                                    |       
                                       ABC - XYZ  ( Abstract Class)
                                                    |        Inheritance)
                                                    |
                                      ABC - XYZ - Work  (Concrete class)

 Two types of inheritance in PEGA
     
                1. Direct Inheritance  2. Pattern Inheritance

Pattern Inheritance :

                                           This identies the parent class of current class by it's class name i.e For work class "ABC-XYZ-Work" Pattern parent is "ABC-XYZ" for the class "ABC-XYZ" Pattern parent is "ABC".

Direct Inheritance:

                          Direct Inheritance is the method by which a class is inherits characteristics directly from a specified parent class, regardless of any defined pattern inheritance.

 When we create an application in  PRPC automatically class group will be created by following this structure 



 PRPC makes the combination of like this 

                                 Org-Div-Unit  in order frame your class group

                          1. Organization is the top level
                          2. Division is the middle level
                          3. Unit is the bottom level 

Organization :

                         It is the top most entity for any business, which will have multiple divisions and units under it.

Division:

                 The purpose of division is to build common functionalities of specifics units which are associated with the respective division.

Unit:

            It is the place where actually business processing is done.

For Example :


           (Abstract class)      PNC [organization] (can be created reusable comp)
                                                (Cust Details)

           (Abstract class)     PNC-PNCloans    [ Division] (Can be created the reusable comp)
                           (Loan Details)                                 (Insurance Details)
                                     Loan                                    Insurance 

         Concrete class)   PNC-PNCLoans-Work  [Unit] (we can run the business i.e concrete                                                                                              class, it is also called implementation class)                                                                
                Auto Loan    Home Loan              Personal insurance   Auto insurance 

In PRPC each concrete class will have a table connector. All the work instances will be store in the table which is connect to this work class(PNC-PNCLoans-work) work class is also called a class group.

Class Group:

                          Class group is the collection of abstract classes. All the business runs under the class group i.e work object gets created under work object.

When we create a new application it creates given component:

                  1. Application
                  2. Operator Id with Default Password 'rules'
                  3. Classgroup
           
                       

What we need to create in  PRPC application 


                              * One or more Rule set
                              * One class Model , including a unique top level class
                              * One or more HTML-based forms, tailored for your work
                              * One or more Flows 
                              * Multiple Activities 

                              * Multiple Properties, Sections, Flow Action, Decision Tables, Decision Trees                                          based on the business Rules.

What we need to configure :

                                                Organizational Hierarchy 
                                                Authorized Users 
                                                One or more access group
                                                One or more access roles


         PRPC provides the different access group for different Operators.

      

OPERATOR:


                      The person who is going to login into PRPC application is called Operator.

Access group:

                       when login with PRPC, as an operator.Each operator will be associated with an access group.
                   Access group identifies what application the operator can access.

                  Portal ------> Developer 
                       
                 Roles--------> The level of access ( Administrator( Save the Instances, Delete the instances, Update the instances and all), manager(He can access only the business Rules) )

              Application Design and Development

 When we develop a application in PRPC there are two types of layers 
   
                            1. Framework layer
                            2. Implementation layer

Frame Work Application:

                               
                                        It is an application where we built common  functionality of entire business, those can be reuse different type of business implementation.

Implementation Application:

                                  It is an application where we built specific functionality of specific business process.

EX:
      In a Bank

    Entire bank is frame work .

  Personal Banking, commercial Banking mortgage Banking etc.... Are different implementation, where the actual business process of transaction happens.

 Framework and implementation application  should be created from same organisation.


RULES:     

               Rule are building blocks of an application and that influence the application behavior.

                EX: Application = building 
                          Rules = Bricks

                Pega is s Rule based architecture 

RULE SET:

                       Rule set is a container which holds all the rules. While creating any Rule, we need to make sure to place rule into a rule set. The main purpose of rule set is for deployment and security.  

 Every rule must be associated with the below three
                      1. Application 
                      2. Class
                      3. RuleSet + Version   


FLOW ACTION:


                             It is a process rule, which allows us to perform an action on the assignment, and moves the case from current assignment to next level in the flow.

TWO TYPES OF FLOW ACTION:

1. Connector Flow action:


                                          It is a process rule, which allows us to perform an action on the assignment, and moves the case from current assignment to next level in the flow.

2. Local Action:

                               It is a process rule, which allows us to perform an action on the assignment, but the case will be still on same assignment even after the action performed.

EX: Pop up forms, Attached documents to case etc.

Local action can be called from:

    1. HTML controls like buttons, text inputs etc (Sections)
    2. assignment shape.
    3.Under design tab of flow.

Local action that we can call on assignment shapes or design tab of flow, can be accessed using the action drop down of work object forms.

Assignment level Local Action:
                           

                    When we call a local action on assignment shape, it will be available to access on when the case at the specific  assignment

Flow wide  Local Action :

                   When we call a local action on under design tab of flow, it will be accessible at all the assignments of that flow.
                                       

                                     


































































PEGA Introduction


                                           PEGA

What is meant by PEGA?

                                   PEGA is a business process management tool (BPM) that primary focuses on work flows or integrations capabilities.

PEGA PRPC (Pega Rules Process Commander)

                                  PegaRules Process Commander is a software product by using which we build and developing the application and deploy.

BPM+BRE = PRPC 

BPM(Business process management )

                           BPM is a methodology(set of instructions) to manage process and work flows in an organization.BPM which provides the ability to have end-to-end visibility and control over all parts of multi stepped transaction that spans multiple application and multiple people in one or more organization.



 FOR EXAMPLE :

                            ATM CARD FLOW CHART 

                                                           START
                                                                |
                                            PUT The card in ATM machine 
                                                                 |
                                             Enter the PIN number
                                                                |                match
                                             Verify the pin number ----------- Process the transaction 
                                                                | un match                            | 
                                                           END                                      END 

        This is called End-To-End process.

                                In above flow chart one transaction perform different task. In a BPM implement unit of work represent it in the form of flow diagram.
                                   
                             Development representation of unit of work in the form of flow diagram by dividing into multiple steps at each and every step going to perform a task. This is what a multiple step transaction in BPM.
                              
                                  So many BPM tools are available in market like ORACLE BPM, IBM BPM, AL BPM, LOMBARD, TIBCO. When compare to the other BPM tool PEGA is most advanced tool.

                                We can develop an application in JAVA, .NET. C ........... etc. In java lot of coding is required. But we develop a application in PEGA no need to write a single line of code every thing is generated automatically.  PEGA back end is developed by using java language.

BRE( Business Rule engine)

                            BRE is a software system that executes one or more business rules in a run time product environment.
     

Traditional Application Development VS BPM Application development 

Traditional Application development:

                                    They are three layers 

                                           User interface Layer

                                            Logic Layer 

                                            Database Layer

When we develop application in programming language we design UI, define logic and access data keeping all these elements are separate for re-usability.

BPM Application development  

                               We have to develop

                                    UI Layer

                                    Business Logic    { All these three integrated to work flow or process in BPM}

                                     Data Base

 First implement a flow we need to add every thing into the work flow.When we access the BPM Application first it will trigger the flow. Work flow trigger the ' START ' position to 'END' position based on the decision.

 In BPM tool we have 

                 
                                  Enterprise Level Scalability
                                  Standard based User Interface
                                  Integration with other business platform                                   

Process:

            Process is unit of work that can be completed either by acceptances or rejection.

                                    
                        To developed an application we need an IDE. For example Applications developing by using JAVA we need ECLIPSE IDE for .NET we need MICROSOFT VISUAL STUDIO like that in a BPM we need a IDE to develop application called BPM SUITE.

BPM SUITE:

                       BPM suite is environment which design develop the application and deploy the application by considering Build-in business rules.

BUSINESS RULES:

                                For example :
Considering the financial transaction business process for credit card. the simple business rule is. The total amount can due by a customer should not excite customer credit limit 
                                 EX: my credit Card limit is 3 Lakhs

                            I purchased up to 4 Lakh it immediate stop it says yours transaction limit is 3lakh it will decline. 

                           Here 3Lakh limit is business rules. All the Business Rules will be saved in a DB called "Business Rules DataBase"(it holds the business rules).When we access the card it will go to the database and get the business rules.


                            PRPC has building blocks that are common to most business process management application.

PEGA TOOL

           Developer Portal / Designer Studio Skeleton 7.2 Version 

        

HEADER

    PEGA 7 ---- Home Page

   Designer studio ------- Landing Menu

   PegaRules ---------- Application Menu 

   Launch ----------- Developer portal , Manger Portal , End User Portal

   Private --------- Private link is useful for developer to know what are the checkout rules.

   Resources ----- What are the resources are available in pega we can see here 

   Administrator ---- All the operators id are seen here.


LEFT NAVIGATION 


 Recent ------- All the recent rules are seen here 

 Cases ------ Application are divided into modules 

  Data ------ Data Pages are done here 

  App-------- Complete structure of application

  Records ---- System kind of information   


ALL THIS ARE CALLED EXPLORER 


FOOTER 


                 Footer contains all the debugging tools 

  Trace ---  one of the debugging tool

 Clipboard ---- Collection of pages

 Live UI ----- One of the debugging tool help doing run time





   









































DB Adapter Select Query Dynamic IN Parameters

                
I came across a scenario where we need to pass IN parameters dynamically and number of parameters are not fixed. If we design query like below it will accept only one argument

Select * from CUSTOMER where CITY IN(#IN_City)


As we don't know the number of arguments at design time, one option we  tried is inject multiple arguments as comma separated string ( Pune,Banglore,Hyderabad). But DB adapter tries to read the argument as a bind parameter and not SQL string. Then we changed query as below 


Select * from CUSTOMER where CITY IN (
select regexp_substr(#IN_City,'[^,]+', 1, level) from dual
    connect by regexp_substr(#IN_City, '[^,]+', 1, level) is not null
           );

Now we can pass the same comma separated string as argument at both the places. 

Select * from CUSTOMER where CITY IN (select regexp_substr('Pune,Banglore,Hyderabad','[^,]+', 1, level) from dual

    connect by regexp_substr('Pune,Banglore,Hyderabad', '[^,]+', 1, level) is not null
);



To design argument as comma separated string we will use “oraext:create-delimited-string” function in BPEL. Design Synchronous BPEL which takes array of arguments and use DB adapter pure SQL operation to execute the query. I am using SOA 12.2.1.3 version and Oracle DB 11g.

Create a SOA Project 




Create Synchronous BPEL process




Change the input xsd to take multiple arguments so added maxOccurs="unbounded" for input element



Right click on the External References -> Insert Adapters -> Database



Select Execute Pure SQL as Operation Type



Enter the query in the SQL box, it will automatically generate a XSD based on the query.



We can see the input and output elements. If we observe for input elements type is empty 


 Provide the type as xs:String



Keep default settings as it is and click FinishJoin BPEL and DB Adapter. In BPEL use invoke activity and create DB input and output variables.



Drag and drop transform activity between receive activity and invoke activity





In transformation take Source as input variable and Target as DB adapter input variable.


In transformation pass same expression for both arguments


Now deploy the code and test. While testing give array value as 2 so input will take two values


If you observe the flow trace we can see DB input as comma separated string



Service virtualization using OSB


service virtualization is one of the main feature of OSB. Service virtualization is the abstraction of a physical service through a proxy or intermediary service. In service virtualization, the service intermediary interacts with the service consumer and hides the physical location of the service provider. In other words, communication between the service provider and service consumer is done through a service intermediary, creating a gateway for application integration.






 In this Use case we will use one of the external web service which is available over web and will call that webservice from OSB. There are numerous webservices which are available in Online one  such kind webservice is Bank BLZ Service (http://www.thomas-bayer.com/axis2/services/BLZService?wsdl). By using this webservice we can fetch Bank Sort Codes (called Bank BLZ codes) for banks in Germany. In the request, you need to pass the BLZ code for any bank in Germany and it comes back with the bank details.


Create new project named BLZ service





Create folder structure like below


Copy the WSDL file from location http://www.thomas-bayer.com/axis2/services/BLZService?wsdl and place under WSDL folder

Creating Business Service

Drag and drop HTTP component from Technology palate to External Services lane.



Service Name: BS_BLZService
Location: browse through “BusinessService” folder we created in earlier step

Transport: http



Select “WSDL” from available options and browse to wsdl location

populates wsdl file with port after reading the WSDL file we have chosen in the previous step


populates the endpoint URI for the exposed web service to be invoked

Click Finish


Business Service is created on the External Services lane and this exists under “BusinessService” folder

Create Proxy Service


Drag and drop HTTP component from Technology palate to Proxy Services




 Fill up the mandatory details
Service Name: PS_BLZService
Location: browse through “ProxyService” folder we created in earlier step
Transport: http

Checking “Generate Pipeline” check box will create pipeline along with Proxy Service


We will use the same WSDL that we used to create business service



populates endpoint URI





Proxy Service is created on the Proxy Services lane and this resides under “ProxyService” folder





Connect Pipeline with business service


Double-click on the PS_BLZServicePipeline which opens up in new editor with .pipeline extension. Here Routing node inside route node is created automatically when we wire pipeline with business service


Testing the Service Bus project deploying into the IntegratedWeblogicServer





Request


Response