Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Sending Messages to the Other Side

Sending Messages to the Other Side

This month, I thought I would take a below-the-surface look at what needs to be done to achieve transactional access to the IBM MQSeries messaging product from WebLogic Server within the context of an Xa transaction managed by WebLogic's JTA subsystem. Of course, from the outset I would like to note that WebLogic Server itself boasts a very capable and reliable messaging system - which is getting more capable with every release - but it is a fact of life that MQseries for various reasons (most predating the existence of Java, never mind the JMS messaging standard) has a large installed base, so good interoperability with it is a requirement whatever your infrastructure religion.

So Tell Me the Good News
Well, Okay, I will. The first piece of good news if you are looking for programmatic integration between WebLogic Server and MQ is that there is working code to achieve just that available on BEA's dev2dev Web site at http://dev2dev.bea.com/code/codedetailcontent.jsp? productType=weblogic+server&codeType=alpha+code&filepath= components%2Fdev2dev%2Fcodelibrary%2Falphacode%2 Falphacodewlsmqseries.htm. However, there are some features of its implementation that bear closer scrutiny to get further insight into what needs to be done to interface these two environments. If you're not into intricate details, I recommend that you proceed directly to the conclusion now for an early bath - I am about to start indulging my love of the obscure...

You're still here? Good, another implementation trivia lover - I can see that we're going to get on famously. Take a deep breath; I'm sure you're going to enjoy the trip!

Enjoy the Trip!
On the face of it, part of the MQSeries product is a Java wrapper that implements the JMS programming interface and supports the XA extensions. To aid code portability, JMS provides for connection factories, queues, and topic objects to be defined prior to application runtime and stored using a JNDI provider, so using all these standards from within the WebLogic Server environment should be simplicity itself, right?

Well, almost. There are some wrinkles that come from MQSeries restrictions that derive from the implementation of MQ itself. These need to be coded around if WebLogic Server and MQ are to live together in perfect harmony. Most of the code posted on dev2dev is concerned with ironing out these wrinkles so that the two products can coexist in perfect harmony, or at least without shed loads of cacophonous discord, or as MC geek and the OLTP crew might say "so the MQ thing doesn't go in the crapper, BEA Systems have written a wrapper."

So What Is This Wrapper Up To?
Rather than a full top-down review of the whole thing, I will spend the rest of the article reviewing the purpose of a subset of it. This will hopefully provide a level of understanding both of the XA implementation of MQ, and of the WebLogic Server transaction manager.

The first part of the wrapper is a class that maps the MQ JNDI entires from an external JNDI directory into the WebLogic JNDI tree. On the way, it interposes its wrapped versions of the XQQueueConnectionFactory or XATopicConnectionFactory. The net result is that the set of connection/topic factories present in MQSeries becomes visible in the WebLogic Server environment, with a wrapper to do the rest of the integration magic.

The wrapper at the base of the remaining mystery is a wrapper for the MQSeries XA resources. As XA resources are dispensed from the MQ factories, they in turn are wrapped, and it is in this resource wrapper that the business end of things happens.

First, the constructor of the resource wrapper registers each XA resource - once per server - under a resource name that is either given or constructed from the server and domain names and the MQ resource string. The wrapper also allows the MQSeries integration to take advantage of an optimization in the WebLogic transaction manager, namely dynamic enlistment.

So, I hear you cry, what's that? The JTA specification allows only for static enlistment, which means that all resources must register their existence at startup, and from this point on the application server must assume that all resources registered with it participated in every transaction and enlist them in JTA transactions on that basis so they are sent a commit for each transaction on the off chance that they participated. With dynamic registration, resources can enlist with JTA lazily as they are invoked in a transaction - meaning that the transaction manager knows the correct set to coordinate at commit time, improving performance. The resource name associated with a resource is used by WebLogic as a branch qualifier for the transaction. It is also used in recovery so that outstanding transactions can be completed from transaction log records. This means that these resource names must be assumed to be constant across multiple server reboots to allow for transaction recovery.

Finally, an XA resource provides a method called isSameRM that allows a transaction manager to determine conclusively if two participants in a transaction are really one and the same resource. The wrapper provides its own implementation of this method with different behavior from the out-of-the-box implementation from IBM. The reasons for this are slightly obscure, but here goes... IBM's implementation of isSameRM bases the decision on the QueueManager. The wrapper is designed to base the isSameRM decision on the name associated with the XAConnectionFactory (remember the significance of the resource name in terms of the transaction branch?). This allows multiple branches to be used for a particular MQSeries QM. This is important when multiple MQ sessions are to be manipulated in a transaction. Due to the behaviors of the WL TM and the IBM JMS implementation, the direct use of multiple MQ sessions in a single transaction can result in XA errors. The IBM JMS requires that each XAResource instance, that is associated with a particular Session, be enlisted and delisted from the transaction. The WebLogic Transaction Manager implements a delayed delistment optimization, which delays calling XA.end (the XA call that performs the delistment) until absolutely necessary (transaction suspended, commit called, etc.). This optimization helps avoid multiple start/end calls when the same resource is accessed multiple times within a transaction. However, because each JMS session has a unique XAResource object, and their isSameRM methods will return true for each other, WebLogic's Transaction Manager will treat them as if they were the same. The first session accessed will receive an XA.start call.to enlist it in the current transaction. When the JMS operation returns, the optimization will delay the XA.end call to delist the resource. When an operation is invoked on the second session, XA.start will not be called because the Transaction Manager thinks that it is the same resource and it knows it has already called XA.start on it. Following that, when the JMS call is made the IBM driver will respond with a 2072 "Syncpoint not available" error because MQSeries didn't get the XA.start it was expecting - since as far as it is concerned this is a different resource - so it decides that the call is being made outside of a global transaction.

Come Up for Some Air, Here's The Really Good News
Phew, you can come up for air now.... This transaction stuff sure provides some late night entertainment. Or perhaps a cure for insomnia. It depends on your viewpoint I suppose.

The good news is that WebLogic Server versions greater than 6.1sp3 provide an out-of-the-box transactional MQ Series bridge that allows you to map WebLogic JMS queues and topics to MQ ones without writing a single line of code - just configure the source and destination queues to be bridged and away it goes. Even better news is that the next release preview bird has told me that a transparent JMS wrapper is in the works. This will allow you to configure foreign queues into the WebLogic environment where the server will transparently take care of all this wrapping.

Yet another reason why both above and below the J2EE standards surface WebLogic Server will remain ahead of the pack in terms of ease of use - bringing faster time to market to all who use it as a platform for their applications.

That's it from me for now - I'll delist until next month. Happy transacting.

More Stories By Peter Holditch

Peter Holditch is a senior presales engineer in the UK for Azul Systems. Prior to joining Azul he spent nine years at BEA systems, going from being one of their first Professional Services consultants in Europe and finishing up as a principal presales engineer. He has an R&D background (originally having worked on BEA's Tuxedo product) and his technical interests are in high-throughput transaction systems. "Of the pitch" Peter likes to brew beer, build furniture, and undertake other ludicrously ambitious projects - but (generally) not all at the same time!

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
The challenges of aggregating data from consumer-oriented devices, such as wearable technologies and smart thermostats, are fairly well-understood. However, there are a new set of challenges for IoT devices that generate megabytes or gigabytes of data per second. Certainly, the infrastructure will have to change, as those volumes of data will likely overwhelm the available bandwidth for aggregating the data into a central repository. Ochandarena discusses a whole new way to think about your next...
DXWorldEXPO LLC announced today that Big Data Federation to Exhibit at the 22nd International CloudEXPO, colocated with DevOpsSUMMIT and DXWorldEXPO, November 12-13, 2018 in New York City. Big Data Federation, Inc. develops and applies artificial intelligence to predict financial and economic events that matter. The company uncovers patterns and precise drivers of performance and outcomes with the aid of machine-learning algorithms, big data, and fundamental analysis. Their products are deployed...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
All in Mobile is a place where we continually maximize their impact by fostering understanding, empathy, insights, creativity and joy. They believe that a truly useful and desirable mobile app doesn't need the brightest idea or the most advanced technology. A great product begins with understanding people. It's easy to think that customers will love your app, but can you justify it? They make sure your final app is something that users truly want and need. The only way to do this is by ...
CloudEXPO | DevOpsSUMMIT | DXWorldEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
Digital Transformation and Disruption, Amazon Style - What You Can Learn. Chris Kocher is a co-founder of Grey Heron, a management and strategic marketing consulting firm. He has 25+ years in both strategic and hands-on operating experience helping executives and investors build revenues and shareholder value. He has consulted with over 130 companies on innovating with new business models, product strategies and monetization. Chris has held management positions at HP and Symantec in addition to ...
Cell networks have the advantage of long-range communications, reaching an estimated 90% of the world. But cell networks such as 2G, 3G and LTE consume lots of power and were designed for connecting people. They are not optimized for low- or battery-powered devices or for IoT applications with infrequently transmitted data. Cell IoT modules that support narrow-band IoT and 4G cell networks will enable cell connectivity, device management, and app enablement for low-power wide-area network IoT. B...
The hierarchical architecture that distributes "compute" within the network specially at the edge can enable new services by harnessing emerging technologies. But Edge-Compute comes at increased cost that needs to be managed and potentially augmented by creative architecture solutions as there will always a catching-up with the capacity demands. Processing power in smartphones has enhanced YoY and there is increasingly spare compute capacity that can be potentially pooled. Uber has successfully ...
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...