1Z0-900 · Question #25
Given the code fragment: How are transactions managed?
The correct answer is D. through a single shared transaction in the JMS Context. In JMS 2.0's simplified API, a JMSContext encapsulates both the connection and session into a single object, and its transactional state governs all producers and consumers created from it - making D correct: one shared transaction lives in the JMSContext. Why the distractors…
Question
Given the code fragment:
How are transactions managed?
Exhibit
Options
- Athrough a single shared transaction across the connection factory
- Bthrough a separate transaction per JMS Consumer
- Cthrough a single transaction for the entire JMS Topic
- Dthrough a single shared transaction in the JMS Context
How the community answered
(61 responses)- A3% (2)
- B2% (1)
- C7% (4)
- D89% (54)
Explanation
In JMS 2.0's simplified API, a JMSContext encapsulates both the connection and session into a single object, and its transactional state governs all producers and consumers created from it - making D correct: one shared transaction lives in the JMSContext.
Why the distractors are wrong:
- A - The
ConnectionFactoryis a factory for creatingJMSContextobjects; it holds no transactional state of its own. - B - Consumers don't own transactions; they inherit the transactional behavior of the
JMSContextthat created them. - C - A Topic is a destination (where messages go), not a transactional boundary; transactions are scoped to the session/context, not the destination.
Memory tip: Think of JMSContext as a "smart session" - it replaced the old Connection + Session pair in JMS 2.0, and like the old Session, it is the single owner of the transaction. If you remember "session owns the transaction," just map Session → JMSContext in the modern API and you'll always land on D.
Topics
Community Discussion
No community discussion yet for this question.
