Comments
Matt McLarty wrote: For more info... Follow me on Twitter See our website
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Handling Aborted Transactions in Jaguar
Handling Aborted Transactions in Jaguar

In this article we'll examine how to handle a Jaguar CORBA_TRANSACTION_ROLLEDBACK exception that is thrown when a Jaguar transaction is aborted. We'll use the BTFBank sample application developed in an article I wrote for PBDJ in October 1999 (Vol. 6, issue10). This example is written in PowerBuilder, but the technique covered here is relevant for any Jaguar client (Java, Web, etc.) or Jaguar component that's involved in a transaction.

When developing a Jaguar component that uses Jaguar transactions, a CORBA_TRANSACTION_ROLLEDBACK exception is generated each time a transaction managed by the Jaguar server is aborted and rolled back. A transaction is marked as requiring a ROLLBACK by a PowerBuilder component's invoking the SetAbort function on the TransactionServer object.

This exception is thrown when the method that's called on a Jaguar component causes the transaction to be rolled back. In a PowerBuilder client this exception is captured by the connection object error event. If the exception isn't handled, the client application will terminate. As a result of throwing the exception, the method return value and any arguments passed by reference (output parameters) are unusable, making it difficult to handle such situations gracefully.

This situation is best illustrated with an example. In our BTFBank example we were able to deposit, withdraw and transfer money from a bank account. In this example a withdrawal of money was canceled if the account didn't have enough funds or wasn't found, or if the SQL to update the database failed. In all cases the SetAbort function was invoked to terminate the transaction. However, in the last article we didn't return a very useful message that would indicate to the client that called the withdrawal why it had failed. The code in Listing 1 modifies the function to accept by reference a string argument in which a message can be returned to be displayed to the user.

On the BTFBank client window we can make the following changes to the call to the withdraw method on the account component so the message returned by the method call is displayed with a MessageBox.

// Withdraw command button
int li_rc
int li_acct, li_tellerid
decimal ld_amount
string ls_msg

li_tellerid = Integer(sle_tellerid.text)
li_acct = Integer(sle_withdraw_account.text)
ld_amount = Real(sle_withdraw_amount.text)

li_rc=in_account.withdraw(li_acct, ld_amount, ls_msg)
IF li_rc <> 1 THEN
MessageBox("BTFBank",ls_msg)
END IF

After making these changes we can run the example. However, you'll notice that after attempting to withdraw too much money from an account, you don't get your error message. Instead, you get the CORBA_TRANSACTION_ROLLEDBACK exception as shown in Figure 1.
Figure 1: CORBA_TRANSACTION_ROLLEDBACK exception

Handling the Aborted Transaction
As a result of throwing the exception, the withdraw method return value and any arguments passed by reference (output parameters) aren't available, since the values aren't sent to the client. In order to allow return parameters to be marshaled and accessible by the client, we need to set a component property on the Jaguar server. The property, com.sybase.jaguar.component.tx_outcome, needs to be added to the account component through the Component Properties dialog on the All Properties tab, as shown in Figure 2.

The tx_outcome property isn't listed in the All Properties list, but is available to the component and set to "always" by default, which tells the Jaguar server to throw a CORBA TRANSACTION_ROLLEDBACK exception when a transaction is rolled back. In order to add the property click on the Add button, which will open the dialog shown in Figure 3, type com.sybase.jaguar.component.tx_ outcome into the Property Name field and type failed into the Property Value field.

A value of "failed" tells the Jaguar server not to throw a CORBA TRANSACTION_ROLLEDBACK exception when the component issues a SetAbort. This allows the component to raise a different exception or pass back values to the client.

Once the information is added, click the OK button. The tx_outcome property will be visible in the Component Properties dialog on the All Properties tab. Once the property is added, refresh the package or server through the Jaguar Manager and retest the application. When a withdrawal of too much money is attempted, the transaction is aborted and the error message is displayed on the client, as shown in Figure 4.

Conclusion
A method that results in an aborted transaction will throw the CORBA_ TRANSACTION_ROLLEDBACK exception. To avoid throwing the exception and to access the return value or output parameters on a method that's part of an aborted transaction, the Jaguar Component property com.sybase.jaguar.component.tx_outcome must be set to failed for each component on the Jaguar server using the Jaguar Manager. After setting the property, be sure to refresh the component. The BTFBank sample code used in this article is available on my Web site at www.erols.com/m.barlotta under Code Samples.

About Mike Barlotta
Background Information: Michael Barlotta is the Director of Technology at AEGIS.net Inc (www.AEGIS.net). Mike is a Sun Certified Java Programmer and is recognized as an expert on the Sybase application server EAServer (Jaguar CTS), mentoring clients and speaking at conferences on the topic. He is the author of several books including Taming Jaguar and Jaguar Development with PowerBuilder 7 (both by Manning Publications). Be sure to check out Mike’s Web site www.TamingJaguar.com.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Enterprise Open Source Magazine Latest Stories . . .
New tools and services for swift software-as-a-service integration in the cloud lowers the barrier to SaaS adoption for SaaS providers and developers. MuleSoft this week launched Mule iON SaaS Edition, providing a broad set of new tools and services for swift software-as-a-Service (Sa...
All the buzz surrounding OpenStack over the past few months may beg the question of whether Openstack can repeat for Cloud what Linux has done for server operating systems over the past several years. With an enthusiastic following and a compelling, if not industry-leading set of funct...
Virtual Desktop Infrastructure (VDI) has been a hot topic in the IT community for years but delivery models have limited its use. Today there are real options for using the technology to truly replace the existing desktop infrastructure to realize tangible benefits. Today’s cloud-sourc...
VMware hypervisors of the ESX family (3.x, 4.x and 5.0) are fully, out-of-the box supported by the latest versions of OpenNebula(3.0+). If you have a server farm based on any of the ESX versions, then you can make use of OpenNebula to better manage your physical (and virtual) resources...
Data centers today are stretched to the limits with fast-paced business demands. On top of that, integrating and managing IT infrastructures can pose major challenges. Organizations need a new solution that consolidates servers and workloads without breaking the bank—and Linux, togethe...
Atlantis Computing, a provider of Virtual Desktop Infrastructure (VDI) storage and performance optimization solutions,has announced the release of Atlantis ILIO Diskless VDI 3.2, a solution that enables VMware View customers to deploy virtual desktops with no storage. Atlantis ILIO Dis...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE