nerdexam
Oracle

1Z0-895 · Question #50

You are writing an EE component that functions as a message producer. The message producer sends message to a JMS queue. The component environment defines a resource-ref of type…

The correct answer is D. @Resource (loopkup = "jms/QueueConnectionFactory"). A connection factory is the object a client uses to create a connection to a provider. A connection factory encapsulates a set of connection configuration parameters that has been defined by an administrator. Each connection factory is an instance of theConnectionFactory…

JMS and Message-Driven Beans

Question

You are writing an EE component that functions as a message producer. The message producer sends message to a JMS queue. The component environment defines a resource-ref of type javax.jms.ConnectionFactory with the same jms/ConnectionFactory. Which will correctly obtain a connection factory for a queue?

Options

  • AContext context = new initialContext();
  • BInitialContext Context = new Context () ;
  • C@Resource ("ConnectionFactory")
  • D@Resource (loopkup = "jms/QueueConnectionFactory")

How the community answered

(37 responses)
  • A
    3% (1)
  • B
    8% (3)
  • C
    5% (2)
  • D
    84% (31)

Explanation

A connection factory is the object a client uses to create a connection to a provider. A connection factory encapsulates a set of connection configuration parameters that has been defined by an administrator. Each connection factory is an instance of theConnectionFactory, QueueConnectionFactory, or TopicConnectionFactory interface At the beginning of a JMS client program, you usually inject a connection factory resource into a ConnectionFactory object. For example, the following code fragment specifies a resource whose JNDI name is jms/ConnectionFactory and assigns it to a ConnectionFactory object: @Resource(lookup = "jms/ConnectionFactory") private static ConnectionFactory connectionFactory; The Java EE 6 Tutoria, The JMS API Programming Model

Topics

#JMS connection factory#@Resource injection#JNDI lookup#resource-ref

Community Discussion

No community discussion yet for this question.

Full 1Z0-895 Practice