nerdexam
Oracle

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…

Use Java Message Service API

Question

Given the code fragment:

How are transactions managed?

Exhibit

1Z0-900 question #25 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)
  • A
    3% (2)
  • B
    2% (1)
  • C
    7% (4)
  • D
    89% (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 ConnectionFactory is a factory for creating JMSContext objects; it holds no transactional state of its own.
  • B - Consumers don't own transactions; they inherit the transactional behavior of the JMSContext that 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

#JMS Context#Transaction Management#JMS Transactions#Message Service

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice