Step 1: Set Up JMS Application, Creating Non-Transacted Session Step 2: Look Up User Transaction in JNDI Step 3: Start the JTA User Transaction Step 4: Perform Desired Operations Step 5: Commit or Roll Back the JTA User Transaction
12.3.1 Step 1: Set Up JMS Application, Creating Non-Transacted Session
Set up the JMS application as described in Section 5.2, Setting Up a JMS Application, however, when creating sessions, as described in Section 5.2.3, Step 3: Create a Session Using the Connection, specify that the session is to be non-transacted by setting the transacted boolean value to false. For example, the following methods illustrate how to create a non-transacted session for the PTP and Pubsub messaging models, respectively. qsession = qcon.createQueueSession false, Session.AUTO_ACKNOWLEDGE ; tsession = tcon.createTopicSession false, Session.AUTO_ACKNOWLEDGE ; Using Transactions with WebLogic JMS 12-512.3.2 Step 2: Look Up User Transaction in JNDI
The application uses JNDI to return an object reference to the UserTransaction object for the WebLogic Server domain. You can look up the UserTransaction object by establishing a JNDI context context and executing the following code, for example: UserTransaction xact = ctx.lookupjavax.transaction.UserTransaction;12.3.3 Step 3: Start the JTA User Transaction
Start the JTA user transaction using the UserTransaction.begin method. For example: xact.begin;12.3.4 Step 4: Perform Desired Operations
Perform the desired operations associated with the current transaction.12.3.5 Step 5: Commit or Roll Back the JTA User Transaction
Once you have performed the desired operations, execute one of the following commit or rollback methods on the UserTransaction object to commit or roll back the JTA user transaction. To commit the transaction, execute the following commit method: xact.commit; The commit method causes WebLogic Server to call the Transaction Manager to complete the transaction, and commit all operations performed during the current transaction. The Transaction Manager is responsible for coordinating with the resource managers to update any databases. To roll back the transaction, execute the following rollback method: xact.rollback; The rollback method causes WebLogic Server to call the Transaction Manager to cancel the transaction, and roll back all operations performed during the current transactions. Once you call the commit or rollback method, you can optionally start another transaction by calling xact.begin.12.4 JTA User Transactions Using Message Driven Beans
Parts
» Oracle Fusion Middleware Online Documentation Library
» Document Scope and Audience Guide to this Document
» Related Documentation New and Changed JMS Features In This Release
» Major Components WebLogic JMS Architecture
» Point-to-Point Messaging PublishSubscribe Messaging
» Using the Default Connection Factories
» Connection Understanding the JMS API
» WebLogic JMS Session Guidelines Session Subclasses Non-Transacted Session
» MessageProducer and MessageConsumer Understanding the JMS API
» Message Header Fields Message
» Message Property Fields Message
» ServerSessionPoolFactory ServerSessionPool ServerSession Understanding the JMS API
» ConnectionConsumer Understanding the JMS API
» Message Compression Message Properties and Message Header Fields Message Ordering
» Topics vs. Queues Asynchronous vs. Synchronous Consumers
» Persistent vs. Non-Persistent Messages
» Deferring Acknowledges and Commits Using AUTO_ACK for Non-Durable Subscribers
» Avoid Multi-threading Using the JMSXUserID Property
» Declaring a Wrapped JMS Factory using Deployment Descriptors
» Injecting Resource Dependency into a Class Non-Injected EJB 3.0 Resource Reference Annotations
» Automatically Enlisting Transactions Container-Managed Security
» Connection Testing Java EE Compliance Pooled JMS Connection Objects
» Speeding Up JNDI Lookups by Pooling Session Objects Speeding Up Object Creation Through Caching
» Performance and Tuning Disabling Wrapping and Pooling Simplified Access to Foreign JMS Providers
» ejb-jar.xml weblogic-ejb-jar.xml
» PoolTest.java PoolTestHome.java PoolTestBean.java
» Using compenv Sending a JMS Message In a Java EE Container
» Dependency Injection EJB 3.0 Wrapper Without Injection
» Create a Queue Session Create a Topic Session
» Create QueueSenders and QueueReceivers Create TopicPublishers and TopicSubscribers
» Step 1: Look Up a Connection Factory in JNDI Step 6a: Create the Message Object Message Producers
» Step 6b: Optionally Register an Asynchronous Message Listener
» Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7
» Send a Message Using Queue Sender
» Send a Message Using TopicPublisher
» Create a Message Object Define a Message Setting Message Producer Attributes
» Asynchronous Message Pipeline Receiving Messages Asynchronously
» Use Prefetch Mode to Create a Synchronous Message Pipeline
» Importing Required Packages Acknowledging Received Messages
» Setting a Redelivery Delay Overriding the Redelivery Delay on a Destination
» Defining a Session Exception Listener Closing a Session
» Preconditions for Deleting Destinations What Happens when a Destination is Deleted
» Defining the Persistent Store Setting the Client ID Policy
» Defining the Client ID Creating a Sharable Subscription Policy
» Creating Subscribers for a Durable Subscription Best Practice: Always Close Failed JMS ClientIDs
» Deleting Durable Subscriptions Modifying Durable Subscriptions
» Setting Message Header Fields
» Setting Message Property Fields
» Browsing Header and Property Fields
» Displaying Message Selectors Indexing Topic Subscriber Message Selectors To Optimize Performance
» WebLogic XML APIs Using a String Representation Using a DOM Representation
» Releasing Object Resources Configuring JMS System Resources Using JMSModuleHelper
» Creating a JMS System Resource Deleting a JMS System Resource
» Configuring JMS Servers and Store-and-Forward Agents Best Practices when Using JMSModuleHelper
» Benefits of Using Multicasting Limitations of Using Multicasting Using WebLogic Server Unicast
» Step 2: Set Up the Message Listener Dynamically Configuring Multicasting Configuration Attributes
» Uniform Distributed Destinations Weighted Distributed Destinations
» Queue Forwarding QueueSenders QueueReceivers
» TopicPublishers TopicSubscribers Using Replicated Distributed Topics
» Maximizing Production Stuck Messages
» Message Processing According to the JMS Specification Message Processing with Unit-of-Order
» Message Delivery with Unit-of-Order
» Joe Orders a Book What Happened to Joes Order
» Unit-of-Order and Distributed Topics Unit-of-Order, Topics, and Message Driven Beans
» Basic UOW Terminology Rules For Processing UOW Messages
» Example UOW Producer Code UOW Exceptions
» Limitations of UOW Message Groups Overview of Transactions
» WebLogic Messaging High Availability Features
» Application Design Limitations When using Replicated Distributed Topics Advanced Topic Features
» What is the Subscription Key Configuring a Shared Subscription
» Managing Durable Subscriptions How Sharing a Durable Subscription Works
» Sample Producer Code Re-usable ConnectionFactory Objects
» Re-usable Destination Objects Reconnected Connection Objects
» Reconnected Session Objects Automatic Failover for JMS Producers
» Special Cases for Reconnected Consumers
» Integer int Long long Character char String
» Closing Connections Helper Functions
Show more