Docstoc

Integrating with Ensemble

Document Sample
Integrating with Ensemble Powered By Docstoc
					Integrating with Ensemble

Maxim Vershinin
Goal of the academy

 • Present an overview of the technology
    – Ensemble components
 • Give you a feel for how it can be used
    – Building a simple production
What we will be doing

 • High level concepts
 • Concrete examples
 • Hands on with GUI tools
 • Real live coding
Ensemble Architecture
Four Aspects of Integration
  Application    Business Process   Composite      Business Activity
  Integration      / Work Flow      Applications     Monitoring




    Ensemble Universal Integration Platform



                Data        Application       Technology
   The Integration of Power and Ease

   Ensemble Architecture
                                     Single Development Environment
                  Projections

    Objects
      SQL                                        Metadata Repository
  Web Serv                                                                                     Data
                                Transformation         Rules           Workflow
                                    Engine             Engine           Engine
    Data                                                                                       Apps




                                                                                    Adapters
              Adapters




    Apps                         Business             Business          Business
    Tech                          Service             Process           Operation
                                                                                               Tech
  Custom
                                                 Messaging Engine
Dashboards                                                                                     Custom
                                                 Message Warehouse
                 Metrics




     Alerts
   Custom                             End-to-End Management Portal
Exercises
Distribution, Warehouse, Transport

Sales                             Customer Db



                                  Warehouse

        ????




                       Shipping
Distribution, Warehouse, Transport

Sales                              Customer Db



                                   Warehouse
             Ensemble
    Eureka




                        Shipping
Part 1 – A very simple production
Basic Components of Ensemble

 • Business Services
 • Business Processes
 • Business Operations
 • Messages – Requests and Responses
 • Adapters
 • Production
Exercise 1

 • Right click on blue ‘E’ – start Ensemble
 • From blue ‘E’ – Start Ensemble Management Portal
 • Start Distribution Production
 • Examine a Production
 • Use the Testing Service
 • Verify that everything is working
Business Operations

 • Allows Ensemble to invoke external resources
 • Often used with an Outbound Adapter
 • Encapsulates the external functionality
    – BO receives a request object
    – BO returns a response object
    – BP or BS knows nothing about the inner workings of the
      BO
The inner workings of BO Class

 • Message map
 • One or more methods
 • Outbound Adapter Parameter
 • View sample code
Exercise 2 – Business Operation

 • Create new BO to query customer database and return the
   shipping address
     – Select SQL adapter
     – Define the query
     – Execute query
     – Get the result and pass it back
 • Add BO to the production
 • Use the testing service again
Business Process

 • Orchestrates the business process
 • Implements business logic
 • Receives request – normally from BS
 • Sends request to BOs or other BPs
 • Invokes data transformations, rules engine etc.
 • Returns response to BS
Workings of a BP

 • Written in graphical BPEL or written in custom code
 • Represents a ‘business process’ in an enterprise
 • The heart of many Ensemble applications
 • Run by an ‘Actor’ job
 • Job wakes up, services requests and goes to sleep
 • BPs can run for weeks – spanning system restarts
Execution Context

 • Objects instantiated at all times in a BP
    – request          = the message sent to the BP
    – response         = the reply that will be returned
    – context          = context object for working storage


 • Objects instantiated in a call activity
    – callrequest      = the request being sent
    – callresponse = the response that will be received
Exercise 3 – Business Process

 • Open existing Business Process
 • Add call to the CustomerOperation
 • Add Business Process to Production
 • Use the testing service again
Business Services

 • Allows Ensemble to be invoked
 • Often used with Inbound adapter
 • Projects functionality to outside world
 • Called from COS, CSP, VB, Java etc.
 • When invoked
    – Creates request, sends to BO or BP
    – Receives response
    – Hides nature of client from rest of Ensemble
    – Hides nature of Ensemble from the client
With an adapter

 • The adapter listens or polls periodically
 • When there is work to do it calls ProcessInput()
 • You implement OnProcessInput()
    – Build a request
    – Send request to BO or BP
    – Get response
    – Return value through By Ref argument
Without an adapter

 • Application code
    – Creates Business Service instance
    – Calls ProcessInput()
    – You implement OnProcessInput() as before
Directly Invoking a BS

 • Create instance of BS
 • Construct an input object
 • Call ProcessInput()
 • Deal with output object
 • Could be done from any client…
 • …better to build technology appropriate wrapper.
Exercise 4 – Business Service

 • Create BS with no adapter
 • Write OnProcessInput () to send a message synchronously
   to BP
 • Add to the production
 • Use a routine to call the BS
Requests and Response

 • Messages are just objects – instances of a class
 • Normally extend Ens.Request or Ens.Response
 • All messages are stored in the database
 • Can have rich structure but …
    – All referenced classes must be persistent
    – All referenced classes should support XML projection
 • Messages can be searched with SQL
Synchronous v. Asynchronous

 • All requests can be Sync or Async
  e.g from a BS
  set sc=..SendRequestSync("OrderProcess",tRequest,.tResponse)
 • A BS or BP will wait for a Sync response
 • If a BS sends an Async request it can NOT receive a
   response
 • A BP can carry on processing and receive an Async
   response later
Adapters

 • Simplify access to external resources
 • Business Operations use Outbound adapters
 • Business Services use Inbound adapters
 • Hundreds of adapters available
    Technology – e.g. TCP/IP,SOAP, HL7
    Data – e.g. SQL,Files
    Applications – e.g. SAP,PeopleSoft
InboundAdapter

 • BS starts when production starts
 • BS calls adapter to listen or poll for work
 • When there is work to be done the adapter calls
   ProcessInput()
 • Each Inbound adapter passes appropriate object to
   ProcssInput()
    – Eg. EnsLib.File.InboundAdapter passes
      %FileBinaryStream or %FileCharacterStream
Outbound Adapter

 • Business Operation method must call the methods of the
   adapter
 • BS and BO both have Adapter property referring to the
   adapter instance
    – E.g. ..Adapter.ExecuteQuery(…)
Review of Part 1

 • Business Operations encapsulate external resources
 • Business Processes orchestrate calls to Business
   Operations
 • Business Services allow Ensemble production to be
   invoked by outside applications
 • Messages are passed between components
 • All messages are persisted
Part 2

I understand the theory, but how do you use
it?
Composite app – a personal opinion

 • Start with the user
    – What will appear on the screen?
    – What Business Services are needed for that?
    – What data will the BS need?
    – Where does the data come from?
    – Define the BOs
    – BP comes last
Implementing a Business Operation

 • A BO is associated with a single resource
    – What do you want that resource to do for you?
    – Write the method signatures
    – Don’t worry about how it does it
 • Define the methods and the messages
 • Code plausible dummy responses
    – Allow other people to build the BP
    – Separate the internal workings from the interface
Implementing a Business Service

 • A BS is used to expose the functionality
    – Keep it simple – avoid real business logic
    – Convert input/output arguments to/from messages
    – Add extra methods to simplify calls from specific
      technologies
Implementing Messages

 • Keep them simple
    – Use object references for complex data.
 • Don’t duplicate business classes
 • Think of these like APIs – critical design elements, not just
   an afterthought
 • Accept that there will be lots of message classes
    – Don’t try and squeeze multiple messages into one
      message
Part 3 – Invoking Ensemble
Invoking a Business Service

 • Adapters do it for you automatically
 • No Adapter?
    – ##class(Ens.Director).CreateBusinessService()
        • Examine the return code
    – Setup the input parameters (if needed)
    – tService.ProcessInput(<input>,.<output>)
        • Examine the return code
    – Pass back the output parameter
Part 4– More Complex Production
More Components of Ensemble

 • Business Metrics
 • Dashboards
 • More BPL
 • Business Rules
Distribution, Warehouse, Transport

Sales                                Customer Db



                                     Warehouse
               Ensemble
        ????




                          Shipping
Distribution, Warehouse, Transport

Sales                              Customer Db



                                   Warehouse
             Ensemble
    Eureka




                        Shipping
Production Phase 2
Exercise 5 - Create a Web Service

 • Use the Wizard
 • New->General>Web Service
 • Consistent Naming:
    – Package Name: Shipping
    – Class Name: Shipment
    – Service Name: Shipping
    – Service Method: GetDeliveryDate
Create a Web Service (cont’d)

 • Parameter: pAddress As %String
 • Body of the Method:
    Quit $SYSTEM.SQL.DATEADD("dd",$random(5)+1,$NOW())
Exercise 6-Create SOAP Client & BO

 • Use the Wizard
 • Tools->Add Ins->SOAP Client Wizard
 • http://localhost:57772/csp/symposium/Shipping.Shipment.cls?WSDL
 • Add BO to production and test
Shipping Process
Exercise 7 - Shipping Process

 • Create a new Business Process to handle the Shipping
    – Call it ShippingProcess
       • Receives a GetDeliveryDateRequest
       • Delivers a GetDeliveryDateResponse
    – Use the Editor
       • Create an Async Call to the ShippingOperation
           – callrequest.pAddress gets request.pAddress
           – response.GetDeliveryDateResult gets callresponse.GetDeliveryDateResult
       • Create a Sync point
           – Calls Get Delivery Date
           – 30 second timeout
           – Wait for all
Adding to OrderProcess
Exercise 8

 • Add a “Sync” call to OrderProcess Business Process to call
   ShippingProcess
    – Be careful with callrequest/callresponse vs.
       request/response
        • callrequest.pAddress gets context.ShippingAddress
        • response.ExpectedDelivery gets callrequest.GetDeliveryDateResult

 • Add assign to set the response.Confirmed=1 (extra credit)
Business Rule

 • Non-Technical users can change behavior of BP
 • GUI based
 • No need to compile or modify production
 • Changes take effect immediately
    – Stored in the database
    – Evaluated at runtime
 • Only properties of “context” are available
 • Log, Version, Reason, …
Business Rule (cont.)

 • Value, Condition, Return Value, Action
    – Logical Operators (&&, ||)
    – Comparison Operators (=,<,>,<=.>=,!=)
    – Arithmetic Operations (+,-,*,/)
    – String Concatenation (&)
    – Built-in Functions (Min,Max,Round)
    – User Defined Functions
       • Extend Methods of Ens.Rule.FunctionSet
Exercise 9 - Create a Business Rule

 • Use Management Portal
    – Rule Set: CustomerNote
    – If OrderedQuantity >= 5 return “Thanks, you are a great
      customer”
    – Default return “Thanks for your order”
Ex. 9 (cont) - Add a Business Rule

 • Change Order Process
    – Remove “Success Response”
    – Save request.Quantity to the “context.OrderedQuantity”
    – Add the rule “CustomerNote”
       • Put the result in response.CustomerNote
Part 4 – More features
Host and Adapter Settings

 • SETTINGS allow for runtime configuration
 • Automatically presented on Configuration screen
 • Examples
    – DSN of database
    – URL of web service
    – Address and port number for TCP/IP connections
 • Set in Adapter, or in Business Host
Data Transformations

 • Convert data from one format to another
 • Graphical or code definition
 • Invoke anywhere especially from BPL
DTL – Simple Transformation
Workflow Engine

 • Where BP needs human action
 • Tasks to be routed to roles or individuals
 • Mix workflow calls with other BPL
Business Activity Monitoring (BAM)

 • Browser based “Corporate Dashboard”
 • Real-Time Information
 • Incorporate Third Party BAM (ODBC,JDBC,WS,…)
 • Components
    – Business Metric (Special Business Service)
    – Dashboard
       • Meters
       • Layout
                                 Introduction to Ensemble Exercises

All work is going to happen in SYMPOSIUM namespace.

There is SYSTEM ODBC DSN pre-created.

And also SYMPOSIUM Credentials pre-created in SYMPOSIUM namespace.




Description:


You are working on a project for a wholesale company that supplies automotive parts. Currently the
process for entering orders requires a customer relationship management system for retrieving
customer details, a warehouse management system, and a 3rd party shipping system. Each system
has its own client user interface and there is no connectivity between them. Management reports are
produced by generating flat file exports from the CRM and the WMS overnight and importing them
into a spreadsheet. You will use Ensemble to connect to all three applications which fortunately do all
have a published API. A business process will coordinate the entry of a new order by making calls to
the three applications and a business rule to determine what the confirmation note should say to the
customer. The final phase (not included in the academy) would be to create a client composite
application for order entry and a dashboard for live management reporting.



Exercise 1

    1.   Open Management Portal (Right click on blue „E‟ cube in the system tray).
    2.   Switch to SYMPOSIUM namespace
    3.   Go to Ensemble->Configure->Production and click „Go‟ button
    4.   If Distribution.Production is not opened, then open it by using „Open‟ button
    5.   Start production by clicking „Start‟ button
    6.   Test WarehouseOperation:
              a. Select WarehouseOperation business operation
              b. Select „Actions‟ tab on the right hand side
              c. Click „Test‟ button
              d. Enter e.g. 5 as „PartNumber‟ value and press „Invoke‟ button
              e. View Visual Trace.



Exercise 2

    1. Open Studio (Right click on blue „E‟ cube in the system tray).
          a. Switch to Symposium namespace (File -> Change Namespace… [F4])
    2. Create Distribution.CustomerOperation business operation:
          a. Select File->New…
          b. Select Production (tab) -> Business Operation
          c. Enter Distribution as a package name and CustomerOperation as a class name.
              Press „Next‟ button.
          d. Select EnsLib.SQL.OutboundAdapter as outbound adapter.
             e. Click on the    icon. Add a GetAddress method with
                Distribution.GetAddressRequest as a request type and
                Distribution.GetAddressResponse as a response type. Press „Finish‟ button.
             f. Review generated class and message map in it.
             g. Replace content of GetAddress method, so it looks like this:

                Method GetAddress(pRequest As Distribution.GetAddressRequest, Output
                pResponse As Distribution.GetAddressResponse) As %Status
                {
                       set pResponse=##class(Distribution.GetAddressResponse).%New()

                      set tQuery="Select ShippingAddress from Marketing.Customer where
                CustomerID=?"

                        set sc=..Adapter.ExecuteQuery(.RS, tQuery,pRequest.CustomerID)

                        if sc {
                              if RS.Next() {
                              set pResponse.ShippingAddress=RS.Get("ShippingAddress")
                             }
                    }

                        Quit sc
                }

          h. Compile Distribution.CustomerOperation class. [Ctrl]+[F7]
   3. Go to production configuration page in Management Portal (see Exercise 1)
   4. Add Distribution.CustomerOperation to production
          a. Click „+‟ button next to „Operations‟ header
          b. Set following values in the opened dialog:
              Operation Class: Distribution.CustomerOperation
              Operation Name: CustomerOperation
              Enable Now: checked
   5. Select CustomerOperation on the diagram
          a. On the right hand side, select „Settings‟ tab and set the following values

                DSN: SYMPOSIUM
                Credentials: SYMPOSIUM

          b. Click „Apply‟ button
   6. Test CustomerOperation (see Exercise 1 for reference, and use CustomerID=1)

Exercise 3

   1. In the Management Portal, go to List>>Business Processes and double-click on
      Distribution.OrderProcess.
   2. Delete „Dummy Place Order‟ component (click on the X icon).
   3. Add a „call‟ activity by selecting it in „Add Activity‟ dropdown list
   4. Name added activity as „Get Shipping Address‟
   5. Connect it with „if‟ and „Success Response‟ components
   6. In the <call> Activity tab, untick the Asynchronous box.
   7. Edit „Target‟ property of new component as following:

       Production: Distribution.Production
       Business Operation: CustomerOperation

   8. Edit Request related parameters

       Request Message Class: Distribution.GetAddressRequest
   9. Use Request Builder to set following values:

       Request Action: Action=set | Property=callrequest.CustomerID | Value=request.CustomerID

   10. Edit Response related parameters

       Response Message Class: Distribution.GetAddressResponse

   11. Use Response Builder to set following values:

       Response Action: Action=set | Property=context.ShippingAddress |
       Value=callresponse.ShippingAddress
   12. Compile the business process.
   13. Still in the management portal, go to Configure>>Production
   14. Add OrderProcess to production („+‟ button next to „Processes‟ column header)

       Business Process Class: Distribution.OrderProcess
       Business Process Name: OrderProcess
       Enabled: checked

   15. Test this business process (see Exercises 1 and 2 for reference, enter a small quantity, and
       leave shipping address blank)

Exercise 4

   1. Go to Studio.
   2. Create Distribution.OrderService Business Service
          a. Select File->New
          b. Select Production->Business Service
          c. Enter Distribution as a package name and OrderService as a class name. Press
              „Finish‟ button.
          d. Edit OnProcessInput method to look like this:

               Method OnProcessInput(pInput As CustomerOrder, pOutput As OrderConfirmation)
               As %Status
               {

                       set tRequest=##class(Distribution.PlaceOrderRequest).%New()

                       set tRequest.CustomerID=pInput.CustomerID
                       set tRequest.PartNumber=pInput.PartNumber
                       set tRequest.Quantity=pInput.Quantity

                       set sc=..SendRequestSync("OrderProcess",tRequest,.tResponse)

                       set pOutput=##class(Distribution.OrderConfirmation).%New()
                       set pOutput.CustomerNote=tResponse.CustomerNote
                       set pOutput.Confirmed=tResponse.Confirmed
                       set pOutput.ExpectedDelivery=tResponse.ExpectedDelivery

                       Quit $$$OK
               }

          e. Compile Business Service
   3. Go to Management Portal and add OrderService to production:

       Service Class: Distribution.OrderService
       Service Name: OrderService
       Enabled: true

   4. In Studio, Create a routine to call this business service with a code below:
          a. File->New->(General Tab)->Caché ObjectScript Routine
          b. Make sure that starts with a space or tab.

        set sc = ##class(Ens.Director).CreateBusinessService("OrderService", .serviceObject)

        if ($IsObject(serviceObject)) {
                 set request = ##class(Distribution.CustomerOrder).%New()
                 set request.CustomerID = 1
                 set request.PartNumber = 1
                 set request.Quantity = 10

                 set sc = serviceObject.ProcessInput(request, .response)
        }

             c. Compile the routine [Ctrl]+[F7]
             d. You should already be in the Distribution package, and call it InvokeService.

   5. Invoke routine from the terminal.
          a. Right-click Ensemble „E‟ and Terminal
          b. USER>zn “SYMPOSIUM”
          c. SYMPOSIUM>do ^Distribution.InvokeService
   6. View message trace in Management Portal:
          a. View>>Message Viewer
          b. Click on top message, the Trace tab in the right frame, and View Full Trace
          c. Click on PlaceOrderResponse and view the contents

Exercise 5

   1. Create WebService
   2. Use the Wizard
   3. New->General->Web Service

       Consistent Naming:
       Package Name: Shipping
       Class Name: Shipment
       Service Name: Shipping
       Service Method: GetDeliveryDate

   4. Edit GetDeliveryDate method to look like this:

   Method GetDeliveryDate(pAddress As %String) As %String [ WebMethod ]
   {
      Quit $SYSTEM.SQL.DATEADD("dd",$random(5)+1,$NOW())
   }

Exercise 6

   1. Create WebService proxy client
   2. Use the Wizard
   3. Tools->Add Ins->SOAP Client Wizard

       WSDL URL: http://localhost:57772/csp/symposium/Shipping.Shipment.cls?WSDL

   4. Click Next.
   5. Fill in the Form to create the client and business operation
            a. Proxy Class Package: Shipping
            b. Tick Create Business Operation
             c.   Business Operation Package: Distribution
             d.   Request Object Package: Distribution
             e.   Response Object Package: Distribution
             f.   Click Next, and again Next, and Finish (once the classes have compiled).

   6. Add BO to the production

       Operation Class: Distribution.ShippingSoap
       Operation Name: ShippingOperation
       Enable Now

       WebServiceURL: http://localhost:57772/csp/symposium/Shipping.Shipment.cls
       WebServiceClientClass: Shipping.ShippingSoap

   7. Test BO

Exercise 7

   1. In the Management Portal, create Distribution.ShippingProcess Business Process

             a. Build>>Business Processes -> New

                  Package: Distribution
                  Name: ShippingProcess

             b. In the Context tab, change from the default request and response classes to:

                  Request class: Distribution.GetDeliveryDateRequest
                  Response class: Distribution.GetDeliveryDateResponse

   2. Add „call‟ activity to call ShippingOperation

       Name: Get Delivery Date
       Target: ShippingOperation

       Request: Distribution.GetDeliveryDateRequest
       Response: Distribution.GetDeliveryDateResponse

       callrequest.pAddress gets request.pAddress
       response.GetDeliveryDateResult gets callresponse.GetDeliveryDateResult


   3. Add „Sync‟ Activity

       Name: Wait for Answer
       Calls: Get Delivery Date
       Timeout: 30

   4. Connect it with „Get Delivery Date‟ and „End‟
   5. Compile BP
   6. Add it to the production and test it

Exercise 8

   1. Add a call to „ShippingProcess‟ From OrderProcess (after „Get Shipping Address‟ call)

       (To delete the link to Success Reponse, click on it and then the X icon).

       Name: Coordinate Shipping
         Target: ShippingProcess
         Asynchronous: false
         Request class: Distribution.GetDeliveryDateRequest
         (callrequest.pAddress=context.ShippingAddress )
         Response class: Distribution.GetDeliveryDateResponse
         (response.ExpectedDelivery=callresponse.GetDeliveryDateResult)

   2. Add „assign‟ activity after „Coordinate Shipping‟

         Name: Confirm Order
         Action: set
         Property: response.Confirmed
         Value: 1

   3. Connect all the unlinked activities.
   4. Compile BP and test it

Exercise 9

   1. Create CustomerNote business rule
   2. In Management Portal go to Ensemble->Build->Business Rules

         Package: Distribution.OrderProcess
         Name: CustomerNote
         Context Class: Distribution.OrderProcess.Context

   3.    Click on ruleSet and add new „rule‟ by pressing green „+‟ button (select rule from dropdown).
   4.    Edit when condition to have „OrderedQuantity>=5‟ value (type this in if necessary)
   5.    Select „when‟ and add „return‟ element
   6.    Assign "Thanks, you are a great customer" (with quotes) value to „return‟ element (click OK)
   7.    Select „rule1‟ and add „return‟ element to it
   8.    Select „return‟ element and assign "Thanks for your order" (with quotes) value (click OK)
   9.    Save the rule
   10.   Go to OrderProcess in the Management Portal
   11.   Edit „Success Response‟ assign element:

         Name: Set Ordered Quantity
         Property: context.OrderedQuantity
         Value: request.Quantity

   12. Delete exit link of Set Ordered Quantity
   13. Add „Rule‟ activity after „Set Ordered Quantity‟

         Name: Customer Note
         Rule Name: Distribution.OrderProcess.CustomerNote
         Result Location: response.CustomerNote

   14. Link Set Ordered Quantity to Customer Note and then Customer Note to the triangle (end of
       if)
   15. Compile BP
   16. Test OrderProcess

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:15
posted:2/6/2012
language:English
pages:65