Thursday 31 March 2011

JTA Transactions - Local and Global Transaction. And example with Oracle BPEL Application.

This Blog is about understanding the basics of transaction in J2EE level and how this can be translated to Oracle, BPEL conceptually. This does not limit the interpolation of this concept in simple Java projects as well.

Now lets dig in...


Transactions

J2EE supports two kinds of transactions:
  • Local Transactions - A local transaction is internal to a single resource.
  • Global Transactions - A global transaction is created by an external transaction manager (JTA) and is used to scope work on multiple resources.

Local Transactions

When a managed data source is configured for local transactions it returns connections that can participate in local transactions but cannot participate in global transactions. This means that the connections will not be enlisted in global transactions. The data source will set the auto commit to true for retrieved connections. However, it is up to the client to determine how the connections will be used in local transactions. That is, the client can change the auto-commit mode by using setAutoCommit() on a connection.


Local transactions are transactions associated with a particalar data source (means they are resource-specific). the most common example would be a transaction associated with a JDBC connection.

Global Transactions (XA)

When a managed data source is configured for global transactions, it returns connections that can participate in global transactions. A global transaction (also called a distributed transaction) enlists more than one resource in the transaction.

Global Transactions provide the ability to work with multiple transactional resources (typically relational databases and message queues).

Sources:
Oracle® Containers for J2EE Services Guide 10g (10.1.3.1.0)
Question: Difference between local and global transaction ? - AllInterview


Now putting this in SOA, Concept for better understanding:


Diag Source: Oracle® Containers for J2EE Services Guide 10g (10.1.3.1.0)Part Number B28958-01

So with the above image, lets make some assumptions,

hint: BPEL needs a JDBC connection for its dehydration purpose.

The client Tx is the main BPEL process and the new Tx is probably the adapter / another BPEL process invocation process with in the main BPEL process.


In a local transaction setup, client Tx will be a separate transaction and new Tx will be on its own.
In a global transaction setup, new Tx will be a part of or will participate with client Tx.

In another scenario, we can have one client Tx as local and two new Tx as XA. In this scenario the BPEL process will be on tis own and the two new  Tx will be part of one global Tx.

for example this case will apply where you have one BPEL process and you have two or more DB adapters in the BPEL process. Which means, all the DB adapter Tx will roll back if any one of the DB adapters fail with an error.


Additional Info:

Source: Local and global transaction considerations - IBM docs


Local and global transaction considerations

Applications use resources, such as Java Database Connectivity (JDBC) data sources or connection factories, that are configured through the Resources view of the administrative console. How these resources participate in a global transaction depends on the underlying transaction support of the resource provider.

For example, most JDBC providers can provide either XA or non-XA versions of a data source. A non-XA data source can support only resource manager local transactions (RMLT), but an XA data source can support two-phase commit coordination, as well as local transactions.

If an application uses two or more resource providers that support only RMLTs, atomicity cannot be assured because of the one-phase nature of these resources. To ensure atomic behavior, the application should use resources that support XA coordination and should access them within a global transaction.
If an application uses only one RMLT, atomic behavior can be guaranteed by the resource manager, which can be accessed in a local transaction containment (LTC) context.

An application can also access a single resource manager in a global transaction context, even if that resource manager does not support the XA coordination. An application can do this because the application server performs an "only resource optimization" and interacts with the resource manager in a RMLT. In a global transaction context, any attempt to use more than one resource provider that supports only RMLTs causes the global transaction to be rolled back.

At any moment, an instance of an enterprise bean can have work outstanding in either a global transaction context or an LTC context, but not both. An instance of an enterprise bean can change from running in one type of context to the other (in either direction), if all outstanding work in the original context is complete. Any violation of this principle causes an exception to be thrown when the enterprise bean tries to start the new context.

Tuesday 29 March 2011

What is a durable subscription - JMS.

 A durable subscription saves messages for an inactive subscriber and deliveres these saved messages when the subscriber reconnects. In this way, a subscriber will not loose any messages even though it disconnected. A durable subscription has no effect on the behavior of the subscriber or the messaging system while the subscriber is active (e.g., connected). A connected subscriber acts the same whether its subscription is durable or non-durable. The difference is in how the messaging system behaves when the subscriber is disconnected.

Use a Durable Subscriber to make the messaging system save messages published while the subscriber is disconnected.

Source:  http://www.eaipatterns.com/DurableSubscription.html

The durable subscription only apply to the topic of the JMS.


JMS Queue - Difference between a Queue and a Topic.

This is a typical interview question: What is the difference between a Queue and a Topic ( or Queue Vs Topic).

Before you go for the comparisons you need to learn the basics such as what is a JMS Queue what was the purpose of this technology and so on...

I would like to point you to this wiki page:

Topic: Java Message Service


After you have reviewed the above page you might have understood what is the difference already. But for those who are time short... read on.

First Elements of an JMS Queue:

JMS provider
    An implementation of the JMS interface for a Message Oriented Middleware (MOM). Providers are implemented as either a Java JMS implementation or an adapter to a non-Java MOM.

JMS client    An application or process that produces and/or receives messages.

JMS producer/publisher    A JMS client that creates and sends messages.

JMS consumer/subscriber
    A JMS client that receives messages.

JMS message
    An object that contains the data being transferred between JMS clients.

JMS queue
    A staging area that contains messages that have been sent and are waiting to be read. Note that, contrary to what the name queue suggests, messages have to be delivered in the order sent A JMS queue only guarantees that each message is processed only once.

JMS topic    A distribution mechanism for publishing messages that are delivered to multiple subscribers. 

Source: Java Message Service

The comparison: Queue VS Topic

Queue:

  • Point-to-point model
  • Only one consumer gets the message
  • Messages have to be delivered in the order sent
  • A JMS queue only guarantees that each message is processed only once.
  • The Queue knows who the consumer or the JMS client is. The destination is known.
  • The JMS client (the consumer) does not have to be  active or connected to the queue all the time to receive or read the message.
  • Every message successfully processed is acknowledged by the consumer.


Descriptive example: A JMS queue is a channel through which users "pull" messages they want to receive using the p2p model, instead of automatically receiving messages on a particular topic. The producer submits messages to the queue, and recipients can browse the queue and decide which messages they wish to receive. In the p2p model, users can see the contents of the messages held in the queue before deciding whether or not to accept their delivery.



 
Topic:

  • Publish/subscribe model
  • Multiple clients subscribe to the message
  • There is no guarantee messages have to be delivered in the order sent
  • There is no guarantees that each message is processed only once. -- As this can be sensed from the model 
  • The Topic, have multiple subscribers and there is a chance that the topic does not know all the subscribers. The destination is unknown.
  • The subscriber / JMS client needs to the active when the messages are produced by the producer, unless the subscription was a durable subscription.
  • No, Every message successfully processed is not acknowledged by the consumer/subscriber.
Descriptive Example: A JMS topic is the channel through which users subscribe to receive specific messages from a producer in the publish-and-subscribe model of JMS messaging. The model can be compared to subscribing to a newspaper; for example, if John Doe subscribed to "The New York Times," he would receive the paper every day from the newspaper producer. Similarly, if John Doe used JMS messaging to subscribe to a particular topic, he would receive all sent messages from a producer regarding that topic.

Wednesday 23 March 2011

How to Collect Thread dump for Oracle Applications - In this Case B2B 10g in Linux.

The command to perform a thread dump on linux is kill -3 <pid>. 


The <pid> can be found using opmnctl status for the midtier. 


Example of the output:


-------------------+--------------------+---------+---------
ias-component      | process-type       |     pid | status -------------------+--------------------+---------+---------
LogLoader          | logloaderd         |     N/A | Down   dcm-daemon         | dcm-daemon         |     N/A | Down   OC4J               | home               |    1648 | Alive  HTTP_Server        | HTTP_Server        |    1646 | Alive  B2B                | B2BServer          |    1647 | Alive  B2B                | OC4J_B2B           |    1649 | Alive  DSA                | DSA                |     N/A | Down   


In the above example, the <pid> is 1647.


The thread dumps are located in file $ORACLE_HOME/opmn/logs/B2B~B2BServer~*  or B2B~OC4J_B2B~* file. 


This needs to be done a least three times at interval about 15-30 seconds each after the issue (what ever you are debugging) has been re-produced. 


Example of a thread dump:


Full thread dump Java HotSpot(TM) Server VM (1.4.2_14-b05 mixed mode):

"Thread-9" prio=1 tid=0x088d0110 nid=0x22b8 runnable [0x857ab000..0x857ac228]
       at java.net.SocketInputStream.socketRead0(Native Method)
       at java.net.SocketInputStream.read(SocketInputStream.java:129)
       at oracle.net.ns.Packet.receive(Unknown Source)
       at oracle.net.ns.DataPacket.receive(Unknown Source)
       at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
       at oracle.net.ns.NetInputStream.read(Unknown Source)
       at oracle.net.ns.NetInputStream.read(Unknown Source)
       at oracle.net.ns.NetInputStream.read(Unknown Source)
       at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:978)
       at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:950)
       at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:447)
       at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:183)
       at oracle.jdbc.driver.T4CCallableStatement.execute_for_rows(T4CCallableStatement.java:872)
       at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
       at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3000)
       at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3042)
       - locked <0x91feaae8> (a oracle.jdbc.driver.T4CCallableStatement)
       - locked <0x91e29b38> (a oracle.jdbc.driver.T4CConnection)
       at oracle.jms.AQjmsConsumer.dequeue(AQjmsConsumer.java:1601)
       at oracle.jms.AQjmsConsumer.receiveFromAQ(AQjmsConsumer.java:922)
       at oracle.jms.AQjmsConsumer.receiveFromAQ(AQjmsConsumer.java:835)
       at oracle.jms.AQjmsConsumer.receive(AQjmsConsumer.java:776)
       at oracle.tip.adapter.b2b.data.MsgListener.run(MsgListener.java:366)
       at java.lang.Thread.run(Thread.java:534) 

Tuesday 22 March 2011

ServerURL and Callback Server URL in SOA 11g, 10G

This question or need for setting property really arises when you want a cluster setup or predominantly when you have a software or a hardware load-balancer which takes the requests and routs.


In 10g We would configure this Call back url and server URL by following steps:


  1. Set the soapServerURL and the soapCallbackUrl to the same value as the load balancer URL:
    1. Open the ORACLE_HOME/bpel/system/config/collaxa-config.xml file.
    2. Set the soapServerUrl and soapCallbackUrl to the HTTPS URL, so that the entries resemble the following:
      ...
          <property id="soapServerUrl">
              <name>BPEL soap server URL</name>
                 <value>https://soa.mycompany.com</value>
      ...
          </property>
      ...
          <property id="soapCallbackUrl">
              <name>BPEL soap callback URL</name>
                 <value>https://soa.mycompany.com</value>
      ...
          </property>
      
  2. Restart the OC4J_SOA instances on both computers.

Source: Oracle® Application Server Enterprise Deployment Guide 10g Release 3 (10.1.3.1.0)
Part Number B28939-03
Section: Section: 3.1.12 Configuring the Cluster of BPEL Instances

Now the same can be achieved in 11g by following the steps from:

1. Right Click on SOA-INFRA component in the left navigation tree. Go to Soa Administration --> Common Properties 



2. Set the CallBackServerURL and the ServerURL to  http://deskLinux:8001 and click Save button


3. Restart SOA server to activate the changes . The URL should now be modified for all composites.


Source: Thanks to Mihai's Blog.
ServerURL and Callback Server URL in SOA 11g

Reference:
Document: Oracle® Fusion Middleware Enterprise Deployment Guide for Oracle SOA Suite 11g Release 1 (11.1.1)
Part Number E12036-01

Section: 5.17 Setting the Frontend HTTP Host and Port - Callback URL


Sunday 20 March 2011

Configurable Properties and Reference Binding for Oracle JCA adapters 11g

If you would like to know what are all the configurable properties and reference binding for oracle JCA adapters 11g

Please refer this document:

Oracle® Fusion Middleware Administrator's Guide for Oracle SOA Suite
11g Release 1 (11.1.1)

Section: 33 Configuring Service and Reference Binding Components


Source: Oracle Documentation. OTN.

This included, but not limited to, configuration properties for: DB adapter, File Adapter, FTP Adapter, AQ Adapter, MQ Series Adapter, Oracle Socket Adapter, Oracle JCA Adapters Endpoint Properties.

Thursday 17 March 2011

Difference between Sync and Async BPEL process -- Well explained.

This below blog contains all the essential to differentiate or understand the differences between the Sync and Asyn BPEL process.

Difference between Sync and Async BPEL process - anindyabhattacharjee

Well explained Anindya. Hats off.....

Just for quick reference and to find the differences: if you look in to the source code of the .BPEL file you will find the following respective to the to different BPEL process:

Async BPEL process will contain:  Receive and Invoke for the call back.

 <sequence name="main">
        <!-- Receive input from requestor. (Note: This maps to operation defined in BPELProcess1_Async.wsdl) -->
        <receive name="receiveInput" partnerLink="bpelprocess1_async_client" portType="client:BPELProcess1_Async" operation="process" variable="inputVariable" createInstance="yes"/>
        <!--
          Asynchronous callback to the requester. (Note: the callback location and correlation id is transparently handled using WS-addressing.)
        -->
        <invoke name="callbackClient" partnerLink="bpelprocess1_async_client" portType="client:BPELProcess1_AsyncCallback" operation="processResponse" inputVariable="outputVariable"/>
    </sequence>

Sync BPEL process will contain: Receive and a Reply.

  <sequence name="main">
    <!-- Receive input from requestor. (Note: This maps to operation defined in Sync_realSync.wsdl) -->
    <receive name="receiveInput" partnerLink="sync_realsync_client" portType="client:Sync_realSync" operation="process" variable="inputVariable" createInstance="yes"/>
    <!-- Generate reply to synchronous request -->
    <reply name="replyOutput" partnerLink="sync_realsync_client" portType="client:Sync_realSync" operation="process" variable="outputVariable"/>
  </sequence> 

How To Configure a Read Only or Read & Deployment Only or Restricted User For Oracle SOA 11g Enterprise Manager Console


If you  would like to create or configure a user, Who only has read and deploy composites permissions (Restricted Access) in EM console please do the following:

Access to the Enterprise Manager console is determined by the role assigned to the user. See Appendix C.1 Roles and Privileges in:
Document Reference: Oracle® Fusion Middleware Administrator's Guide for Oracle SOA Suite and Oracle Business Process Management Suite 11g Release 1 (11.1.1.4.0) - Part Number E10226-06

Section: C.1.1 Overall Role Functionality Matrix
For a description of the roles defined and the access granted to each role.

Steps to configure the roles described in the document document: (In this case we assign the Monitor role to the user created)

  1.  Log in to the Weblogic console.
  2. Click on Security Realms -> the name of the realm (myRealm is the default) -> Users and Groups.
  3. Click on New to create a new user.
  4. Click on the name of the user just created, then Groups and move Monitors from the list on the left to the right. Click Save.
  5. Now log in to the Enterprise Manager console with admin privileges, open the SOA folder and right-click on soa-infra and select Security -> Application Roles.
  6. Leave the search text empty and click on search button. This will give you a list of all Application Roles.
  7. Click on SOAMonitor role to edit it.
  8. Scroll down and click on add user. Click on the search button, and a list of available users will be populated. You should see the user just created on the Weblogic console. Move the user to the right and click OK and OK again.
  9. Log out, then log in with the user just created.


Additional Info: If you are keen in learning about the roles and their restrictions on weblogic server console please refer:


Document: Oracle® Fusion Middleware Securing Resources Using Roles and Policies for Oracle WebLogic Server 11g Release 1 (10.3.4) - Part Number E13747-04
Section: 6 Users, Groups, And Security Roles



Tuesday 15 March 2011

Oracle SOA JMS Adapter Tuning - Number of Inbound Threads


To improve performance, the adapter.jms.receive.threads property can be tuned for an adapter service. The default value is 1, but multiple inbound threads can be used to improve performance. When specified, the value of adapter.jms.receive.threads is used to spawn multiple inbound poller threads.


For example:

<service name="dequeue" ui:wsdlLocation="dequeue.wsdl">
<interface.wsdl interface="http://xmlns.oracle.com/pcbpel/adapter/jms/textmessageusingqueues/textmessageusingqueues/dequeue%2F#wsdl.interface(Consume_Message_ptt)"/>
<binding.jca config="dequeue_jms.jca">
<property name="adapter.jms.receive.threads" type="xs:string" many="false">10</property>
</binding.jca">
</service>


These setting need to be done in 10g - BPEL.xml or 11g Composite.xml


In this case  there will be 10 concurrently processing threads.

How can I throttle (Frequency) inbound message flow 10g and 11g- For Adapters Like JMS, File, AQ.

There is an activation agent (bpel.xml) property (since 10.1.3.1), which can be used to control the speed at which the adapter posts messages to BPEL

 ...
    <activationAgents>
         <activationAgent partnerLink="JmsDequeuePL" ... >
           <property name="minimumDelayBetweenMessages">1000</property>
       </activationAgent>
    </activationAgents>
  </BPELProcess>
</BPELSuitcase>
The same setting in 11G would be configured as a binding property in the composite.xml the corresponding (inbound) <service>, e.g.
<service name="Inbound">
  <interface.wsdl interface="http://xmlns.oracle.com/pcbpel/demo1#wsdl.interface(SampleInbound_PortType)"/>
  <binding.jca config="Dequeue_jms.jca">
    <property name="minimumDelayBetweenMessages">1000</property>
  </binding.jca>
</service
 
 This setting ensures that there at least will be 1000 milli seconds delay between two consecutive messages being posted to the BPEL process.

Note: This setting pertains only to BPEL, and only to one adapter polling thread. If multiple adapter polling threads (e.g. multiple JMS dequeuer threads) have been configured, this setting will control the speed of each thread, not the combined speed.

Thursday 10 March 2011

Siteminder sso cookie does not clear once the App is logged out.



The issue:

If you have setup siteminder sso with oracle fusion middleware.
The fusion middleware application comes with Oracle B2B and Worklist application.Once a user login though sso in these application,the logout button dosent work or complets the loop.
We need a way to clear the siteminder sso cookie once the logout button is clicked.
Please suggest a way to make this customization in the apps.


The solution:

The solution seems to be configuring in SiteMinder: configure the logout URL in the app as a SiteMinder logout URL

Steps are as:

1) Find the URL of the logout action in the app (from the docs, by hovering over it, or by tracing the HTTP traffic)
2) Open the SiteMinder Web Agent configuration (either in the SiteMinder console or in the local WebAgent config file) and add a LogOffUri setting to reflect the above URI. Note: this is a URI not a URL. So remove the http://hostname portion.

if you are not the siteminder administrator, You can pass this info to the SiteMinder administrator and they should know exactly what it means.

Oracle 11g DB vs Microsoft SQL 2008

Once when I visited one of my friends, My friend and I had a (so called healthy) Debate between Oracle 11g DB vs Microsoft SQL 2008.

I was towards oracle's performance and high cost and my friend was towards MS DB and its benifits of being low cost and may be better performance...

After a while... this kind of continued in a email... My friend sent me this PDF document

Twelve ways to reduce costs with SQL Server 2008 - White paper1.pdf

For my review and reading....

As a counter response or you can say to continue the healthier side of the debate... I sent the below response...

Hi Friend,

Had some time in hand to read the PDF that you sent me... thanks for this... now as this is in front of the table...looks like I was right 100%...

Now the Twelve ways to reduce costs with SQL Server 2008 - White paper1.pdf that you attached talks only about cost and cost reduction... and I believe I agreed that Oracle is very very very expensive compared to MS 2008 and I believe I also stated only Enterprise Architecture budget can only offered Oracle... this document does not tell any thing about performance and benchmark comparison with matching cost ....

Now I believe this PDF that you have provided is a sales pitched document.... now I would like to provide my side of refference:

Comparative Management Costs Stud - By Edison group    ---> this is not an oracle document.... (Thanks to google in helping me find one) ... 

A third party comparative Study, this is cost with performance and DBA Management.... Read the conclusion of both, your reference and my reference, and you will know what I was really about and how they compare.... But do read the report in detail for knowledge sake...

The fact speaks out in terms of comparative  study....

Hope this helps you get some insight in comparison. I believe this was a healthy debate.

Cheers,
Arun.