Thursday, 7 November 2013

Transaction handling in osb


Enabling Transactions
1. Make sure the source JMS transport URI is using an XA enabled Connection Factory.

2. In Proxy Service Configuration –> JMS Transport –> Advanced Settings –> Check Is XA Required
3. In Proxy Service Configuration –>Message Handling Configuration –>CheckTransaction Required.
This will instruct the underlying OSB JMS Transport to start a transaction before executing the proxy service code. The transaction will be committed/rolled back based on how the proxy service code executes.
Committing transaction on non-recoverable exception
1. Transaction will commit implicitly if proxy service code executes successfully.
2. In case of error and if proxy flow enters an error handler , the transaction can still be committed by using a reply action ( “Reply With Success” or “Reply with Failure”)

It can look contradicting that a reply with failure action can in fact commit a transaction, but that’s how it works!

Request Transaction Manager to rollback the transaction

A transaction can be marked to be rolled back by the transaction manager by allowing an error to propagate all the way up to the system error handler.

OSB’s error pipeline can consist of either of the following sequence :
  • Route Error Handler –> Service Error Handler –> System Error Handler (Comes into picture when an error occurs in a route node)
  • Stage Error Handler –> Pipeline (request or response) Error Handler –> Service Error Handler –> System Error Handler (Comes into picture when an error occurs in a stage).
If a particular error handler is not present the error is propagated to the next available parent in the chain until it reaches system error handler. This propagation can be stopped by using a ‘reply’ action in any of the error handlers. The developer can mark a transaction to rollback by allowing an error to propagate all the way to the system error handler byNOT configuring a reply action in any of the intermediate error handlers.
Enlist the target business service within the same transaction
1. The target business service to which the message is routed (using Route Node) or published (using Publish Action) can be enlisted within the same transaction. For this the business service endpoint should be transactional i.e. if JMS should use a XA enabled connection factory.
2. Within the route node or publish action request action, set Quality of Service to “Exactly-Once” using a routing options action.

If the outbound transport is HTTP, there will be a design decision you will need to make on what type of errors to be marked for rollback. OSB’s HTTP transport commits all transaction if it gets a HTTP response code back from the server. So even if it gets a 404 Page Not Found or 500 Internal Server Error , HTTP transport doesn’t mark the transaction for rollback. This will result in message loss if the target service is frontended by webservers. You will get a http error back from the webserver even if the backend app servers hosting the service is down. The transaction then gets committed as HTTP transport didn’t mark it for rollback.
On the other end if you are sending a faulty message and service keeps on returning a soap:Fault which will be returned with a HTTP response code of 500, this will be non retriable fault and you would want to commit the transaction after publishing to an error destination. As noted before this is a designer decision to be taken depending upon your error handling requirements.
To override the default behaviour and make the HTTP transport commit the transaction only on receiving a success response from server ( HTTP response code 200 or 202) , make sure you check the ‘Same Transaction for Response’ checkbox.

Sunday, 2 June 2013

Preference in BPEl

Setting and Getting Preference Properties:
page20image4280 page20image4364
Preference Properties :
from front end, not while deploying the sar.
For eg Datasource Value of jca file can be modified using these properties from front end. In composite.xml ,
where the component name tag is there , add the following tag for bpel preference.

<property name="bpel.preference.name">value</property>
Eg:
<component name="BPELProcess1"> <implementation.bpel src="BPELProcess1.bpel"/>
<property name="bpel.preference.name">value</property> </component>Object 1
This can be used to make any run time changes in parameters

 Now we can use the function ora:getPreference(“name”)in our bpel process to retrieve the value of the preference.
Watch the naming convention. It expects it to start with “bpel.preference”.
Also please check the ora:getPreference should contain “” or will throw xpath invalid error
Setting the Property value from emconsole as a configuration change:
On the left go to :
  • Farm_soa_domain > Weblogic Domain > soa_domain > right mouseclick and select ‘System MBean Browser’.
  • Navigate to Application Defined MBeans > oracle.soa.config > Server : soa_server1 > SCAComposite > your_project > SCAComposite.SCAComponent > your bpel_process.
  • Select the Attribute ‘Properties’
  • Change the value of our preference and click apply.
  • After clicking ‘Apply’ click ‘Return’.
  • To persist the new value of the preference after server restart
  • Go to the ‘Operations’ tab and click on the ‘save’ operation. Click ‘Invoke’ and ‘Return’
    If you now restart the service the changed value of your preference with still be there. 

BPEL 1.1 vs BPEL 2.0

BPEL 1.1 vs BPEL 2.0
If you already have BPEL 1.1 in a BPEL project it wont accept BPEL 2.0 in the same BPEL service. But in a composite you can have two services one with BPEL 1.1 and another with BPEL 2.0.
<forEach> activity to repeat the set of activities . Replace the FlowN activity in BPEL 1.1 version.
<repeatUntil> - Use this activity if the body of an activity must be performed at least once. The XPath expression condition in the repeatUntil activity is evaluated after the body of the activity completes.
<if>-<elseif>-<else> - Replaces the switch activity in BPEL 2.0 - This activity enables you to define conditional behavior for specific activities to decide between two or more branches. Only one activity is selected for execution from a set of branches.
Changed <terminate> to <exit>
<compensateScope> - to compensate the specified child scope
A <rethrow> activity has been added to fault handlers this activity enables you to
rethrow a fault originally captured by the immediately enclosing fault handler.
BPEL 2.0 adds a new simplified XPath notation ($variableName) replacing the
getVariableData() function.
The fbelow three activities has been removed in BPEL 2.0 and validate activity has been changed to a BPEL Construct in BPEL 2.0
page1image16060 page1image16144
Bind Entity Create Entity Remove Entity 
page1image17468 page1image17552 page1image17636 page1image17720 page1image17804 page1image17888 page1image17972 page1image18056

Friday, 31 May 2013

Why Oracle Service Bus 11g ? Key Benefits and Advantages

This blog covers key benefits and advantages we can achieve with the implementation of Oracle Service Bus 11g. Actually I have been asked by Client to list down the capabilities they will get with the Oracle Service Bus 11g Implementation and this is what they got from me and lead to this blog finally.

1. Service Virtualization :

                      A core principle of SOA is to ensure that any service consumer can access any service provider - and from any platform. This has been considered as key principle in OSB and it provides robust way of Vitalizing the Service. It’s a great value add in SOA Architecture.

2. Loose Coupling

                     OSB provides loose coupling by mediating between Service provided and Consumer. Without mediation Service consumer and provider will create dependency to each other. A change in single side provider/consumer will lead to the change dependent consumer/provider respectively. OSB bridges the gap of transport, message format, security technology etc.

3. Location Transparency

                     It’s a strategy to hide physical location of actual physical location of service endpoints from the Service Consumer. All Service consumers should know only single logical machine & port name for each service. This allows for greater flexibility when managing your services. You can add, move, prioritize and remove service endpoints as needed without needing to recompile your service consumer again.

4. Seamless Connectivity

                     While newer applications may expose services over standard, easily consumable interfaces such as SOAP, an overwhelming majority of the services available in enterprises are still locked in legacy systems, from mainframes to custom applications. The first task of an OSB is to ensure that all these existing assets can be easily accessed and integrated. An OSB offers rich and comprehensive connectivity options to standard interfaces (SOAP, messaging, etc.) and also to packaged applications and legacy systems via adapters such Siebel Adapter, Peoplesoft Adapter etc.

5. Routing

                     After having a seamless connectivity next task is that data and messages need to flow reliably. OSB offers efficient, secure and reliable transport options. OSB also provides advance routing facilities to determine where the data needs to go. Such routing can be done based on headers, content or other external rules.

6. Performance

                      OSB is stateless & light weight; hence provide the excellent performance result under stress conditions as well.

7. Transformation

                       Oracle Service Bus provides run time transformation capability and support industry standard for middleware :XML, XSLT, XQuery & XPath.

8. Support for Event Driven Architecture

                       Oracle Service Bus support Oracle’s latest Event Driven Architecture.

9. Security & Policy

                        OSB provides centralized way of implementing the Security for Integration which results into highest level of standardization and control on security issues. Security is best enforced using policy driven framework because it allows to implement security details outside of the Application & easy to maintain. This makes it complete pluggable component & highly Agile which can be changed without modifying the actual application as per the organization policy’s and compliance.

10. Service Polling

                       Oracle Service Bus supports service polling. This allows to OSB to automatically detect live service and remove others from the list. This has a significant impact in performance.

11. Load balancing & Failover

                       Oracle Service Bus supports multiple load balancing algorithms to load balance between endpoints. It automatically detects a failover and removes it from Load balanced urls.

12. Service Throttling

                       Service throttling is a new feature in Oracle Service Bus which allows to restrict the load for particular service. This has great value when it comes to Service up time.

13. Monitoring

                       Oracle Service Bus provides two way monitoring.
Proactive Monitoring: Here Integrator can monitor the dashboard and check the performance of the service bus which can help to tune the server effectively. Tracking the server performance over time can help to plan capacity planning well in advance.

Reactive Monitoring: Here OSB will monitor the Server and look for specific conditions to occur and it will automatically sends the Alert to users, Admin etc. Alert can be in the form of Email, JMS, SMS etc.

14. Message Validation

                       Oracle Service Bus support normal data level value check validation as well as Schematron Validation.

15. Value Added Feature

                  a. Support for Domain Value Map

                  b. Support for Cross Reference

                  c. Support for Package application Adapters

                  d. Support for Advance message formats such as SWIFT and FIX in financial Service Domain.

Difference between $body variable and other variable in osb

As I am new to the OSB , I got stuck with this problem while developing an interface in my current project. My objective was to capture a unique ID from incoming SOAP request message. My SOAP request message is as follows

My Objective is to capture the ProjId value from the SOAP message. So I have created a variable to capture the <soapenv:Body> value and using an assign activity I have captured the entire body value in that variable. My Assignment statement xpath is “$body” and I have used a variable named “varResponseBody” .
image
I was surprised at next step when while trying to capture the <ahs:ProjId> value from $varResponseBody using an Assign activity. The Xpath was given as “$varResponseBody/cus:SampleUpDispStInput/ahs:ListOfSampleUpDispSt/ahs:Action/ahs:ProjId/text()”. Because my understanding was as I have copied the “body” variable in “varResponseBody” it would have everything as the body variable has, which was correct because as per our testing in OSB console to print the “varResponseBody” it gives us below output.
image


But I was unaware of the fact that the difference lies in the context of $body and $varResponseBody . Please find below snapshot.
image


image

So If we are trying to capture ProjId value based on $body then the xpath will be “$body/cus:SampleUpDispStInput/ahs:ListOfSampleUpDispSt/ahs:Action/ahs:ProjId/text()” and If we are trying to capture ProjId value based on $varResponseBody then the xpath will be  “$varResponseBody/ahs:ListOfSampleUpDispSt/ahs:Action/ahs:ProjId/text()”

OSB Context Variables


Below is a list of predefined context variables
  
header - For SOAP messages the header will contain the SOAP header.  For any other  type of message the header will contain an empty SOAP header element.
body - Information held in the body will vary based on the type of message.
SOAP Messages - Contains the SOAP Body
Non-SOAP, Non-binary Messages - Will wrap the entire message content in a SOAP:Body element.
Binary Message - Contains a reference to the in memory copy of the binary message wrapped in a SOAP:Body element
Java Objects - Contains a reference to the in memory copy of the Java Object wrapped in a SOAP:Body element
attachments - Contains the MIME attachments
inbound - Contains the inbound transport headers and information on the proxy service that received the message.
service 
providerName - Specifies the name of the service provider(Read-only)
transport
uri - URI by which the message arrived
request - transport specific metadata about the request(Read-only)
response - transport specific metadata about the response
mode - communication style request (one-way) or request-response (two-way)
qualityOfService - specifies the expected quality of service when receiving a message. (Read-only)
Security
transportClient - specifies authenticated transport level user information.  
messageLevelClient - specifies the message level user information.

outbound - Contains the outbound transport headers and information about the target to which the message is being sent.
Service 
providerName - Specifies the name of the service provider (Read-Only)
operation - The name of the operation to be invoked on the target Business Service(Read-Only)
Transport
uri - URI used when sending message
request - transport specific metadata about the request
response - transport specific metadata about the response (read-only)
mode - communication style request (one-way) or request-response (two-way)
qualityOfService - specifies the expected quality of service when receiving a message.
retryCount - Specifies the number of retries to attempt when sending a message from Oracle Service Bus.
Security
doOutboundWss - can be used to disable outboutn WS-Security
fault - Contains information on errors that occurred.    is defined only in error handler pipelines and is not set in request and response pipelines
errrorCode - Specifies the error code as a string value
reason - Contains a text description of the error
details - Contains user-defined XML content related to the error
location -
Identifies the node, pipeline and stage in which the error occurred. Also identifies if the error occurred in an error handler. The sub-elements include:
node—the name of the pipeline, branch, or route node where an error occurred; a string.
pipeline—the name of the Pipeline where an error occurred (if applicable); a string.
stage—the name of the stage where an error occurred (if applicable); a string.
error-handler—indicates if an error occurred from inside an error handler; a boolean.

Oracle Service Bus Interview Questions



Q) What is Proxy Service ?
A) It is exposed to the calling applications or services. Proxy services are Oracle Service Bus definitions of intermediary Web services that Oracle Service Bus implements locally on WebLogic Server.
Q) What is Business Service?
A) It connects to the EIS layer. Business services are Oracle Service Bus definitions of the enterprise services that exchange messages during business processes.
Q) What is the EAI architecture OSB follows ?
A) OSB follows the BUS architecture in EAI.
Q) What does it mean by VETRO concept?
A) VETRO stands for
V – Virtualisation
E – Enrichment
T – Transform
R – Route
O – Operate
Q) Can we expose any Business Service to external clients or subscribers?
A) No, we can not expose Business Services to external clients or subscribers. We need Proxy Services to expose to external world.
Q) Can we have Proxy Services without Business Services?
A) Yes we can have Proxy Services without Business Services , but that will be just a dummy service. EIS layer can not be connected using that Proxy Service.
Q) What is the message flow in Proxy Services ?
A) Message flow in OSB is the most important part. It defines the request message flow from Start Node to Route activity and also defines the response message flow from Route to Start Node. It contains Pipeline Pairs, Branch Nodes, Route Nodes , Stages, Actions etc.
Q) What are stages ?
A) Stages are OSB Message Flow component to contain the actions.
Q) How we can connect to Database from OSB?
A) We need to first create one JCA based DB adapter to connect to the database. Then we need to create that JCA based Business Service. We need to call that Business Service to perform database operations.
Q) Is there any other way to connect to Database without using JCA adapters?
A) Yes we can use XQuery execute-sql() function to connect to database. But it is better to use JCA adapters.
Q) How we can achieve parallel processing in OSB?
A) SPLIT JOINS are meant for parallel processing. So we need to implement Split – Join resources to achieve parallel processing.
Q) What are the transformation resources available in OSB?
A) In OSB we can use XQuery or XSLT for transforming messages.
Q) How to poll file in OSB?
A) The proxy service should be using file transport, and also define the required components like File Mask,Polling Interval, Read Limit, Post Read Action etc.
Q) Can we achieve REST implementation in OSB?
A) Yes we can achieve REST service implementation in OSB. It can be implemented using Branch Nodes.
Q) What is Pipeline Error Handler?
A) Pipeline Error Handlers are used to handle the errors occurred in Request or Response Pipleline.
Q) How can you end a Proxy flow without using if then else logic ?
A) You have to use Reply (with Success)action to end the Proxy Flow where you want.
Q) For a JMS Queue Subscriber Proxy Service  how can you ensure that the JMS Message is retried if an error occurs during processing?
A) One XA Connection Factory should be created to access that JMS queue and that Connection Factory should be used in the URL.
Q)How can you jump control from one stage to next stage without using if then else logic?
A) You have to use Skip action at the end of the stage.

Thursday, 30 May 2013

Routing,Publish and Service Callout




When you are first starting with OSB it can be a little tricky to determine when to use a Route, Service Callout or a Publish node.  All three can be used to call either a Business service or a local Proxy service.  You can use the following lists to determine which will best fit your needs.

Route
  1. Last node in request processing.  It can be thought of as a bridge between request pipeline processing and the response pipeline processing.
  2. You can only execute one route in your Proxy Service.
  3. Can only be created in a route node.
  4. OSB will wait for the Route call to finish before continuing to process.
    1. If you are calling a Business service and you specify Best Effort for QoS (Quality of Service), then OSB will release the thread it is holding while the business service executes.
    2. If you are calling a Business service and you specify Exactly Once or At Least Once for QoS, then OSB will hold onto the thread while the business service executes.
    3. If you are calling a local Proxy service, then OSB will hold onto the thread until the Proxy service finishes executing.
Service Callout
  1. Can have multiple Service Callout nodes in a Proxy service.
  2. Pipeline processing will continue after a Service Callout.
  3. Can be invoked from the request and/or response pipelines.
  4. Used to enrich the incoming request or outgoing response. For example, a call to get a country code.
  5. Used for real time request/response calls (Synchronous calls).
  6. OSB will hold a thread and not continue until the Service Callout completes.
  7. Can tie up resources and degrade performance under heavy loads.
Publish
  1. Can be synchronous or asynchronous
    1. If you are calling a business service with a Quality of Service of Best Effort , then it will be an asynchronous call.
    2. If you call a business service with a Quality of Service of Exactly Once or At Least Once, OSB will wait until the processing completes in the business service completes before proceeding and it is effectively a synchronous call.
    3. If you are calling a local proxy service, OSB will wait until the processing in the local proxy service completes and it is effectively a synchronous call.
  2. Can be invoked from the request and/or response pipelines.
  3. Best to use when you do not need to wait for a response from the process you are calling (Fire and Forget.... Asynchronous Calls)