ConnectionFactory object encapsulates a set of connection
configuration
parameters that has been defined by an administrator. A client uses
it to create a connection with a JMS provider.
A ConnectionFactory object is a JMS administered object and
supports concurrent use.
JMS administered objects are objects containing configuration information that are created by an administrator and later used by JMS clients. They make it practical to administer the JMS API in the enterprise.
Although the interfaces for administered objects do not explicitly depend on the Java Naming and Directory Interface (JNDI) API, the JMS API establishes the convention that JMS clients find administered objects by looking them up in a JNDI namespace.
An administrator can place an administered object anywhere in a namespace. The JMS API does not define a naming policy.
It is expected that JMS providers will provide the tools an
administrator needs to create and configure administered objects in a
JNDI namespace. JMS provider implementations of administered objects
should be both javax.jndi.Referenceable and
java.io.Serializable so that they can be stored in all
JNDI naming contexts. In addition, it is recommended that these
implementations follow the JavaBeansTM
design patterns.
This strategy provides several benefits:
An administered object should not hold on to any remote resources. Its lookup should not use remote resources other than those used by the JNDI API itself.
Clients should think of administered objects as local Java objects. Looking them up should not have any hidden side effects or use surprising amounts of local resources.
javax.jms.Connection, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory
| Modifier and Type | Method and Description |
|---|---|
| public Connection | Returns: a newly created connectionCreates a connection with the default user identity. |
| public Connection | Returns: a newly created connectionthe caller's user name userName, String the caller's password password)Creates a connection with the specified user identity. |
| public JMSContext | Returns: a newly created JMSContextCreates a JMSContext with the default user identity and an unspecified sessionMode. |
| public JMSContext | Returns: a newly created JMSContextthe caller's user name userName, String the caller's password password)Creates a JMSContext with the specified user identity and an unspecified sessionMode. |
| public JMSContext | Returns: a newly created JMSContextthe caller's user name userName, String the caller's password password, int indicates which of four possible session modes will be used.
sessionMode)
Creates a JMSContext with the specified user identity and the specified session mode. |
| public JMSContext | Returns: a newly created JMSContextindicates which of four possible session modes will be used.
sessionMode)
Creates a JMSContext with the default user identity and the specified session mode. |
| createConnection | back to summary |
|---|---|
| public Connection createConnection() throws JMSException Creates a connection with the default user identity.
The connection is created in stopped mode. No messages
will be delivered until the
| |
| createConnection | back to summary |
|---|---|
| public Connection createConnection(String userName, String password) throws JMSException Creates a connection with the specified user identity.
The connection is created in stopped mode. No messages
will be delivered until the
| |
| createContext | back to summary |
|---|---|
| public JMSContext createContext() Creates a JMSContext with the default user identity and an unspecified sessionMode. A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer is created. The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Java EE application client container, or in the Java EE web or EJB container. If this method is called in the Java EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress. In a Java SE environment or in the Java EE application client container:
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
| |
| createContext | back to summary |
|---|---|
| public JMSContext createContext(String userName, String password) Creates a JMSContext with the specified user identity and an unspecified sessionMode. A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer. The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Java EE application client container, or in the Java EE web or EJB container. If this method is called in the Java EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress. In a Java SE environment or in the Java EE application client container:
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
| |
| createContext | back to summary |
|---|---|
| public JMSContext createContext(String userName, String password, int sessionMode) Creates a JMSContext with the specified user identity and the specified session mode. A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.
The effect of setting the In a Java SE environment or in the Java EE application client container:
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
| |
| createContext | back to summary |
|---|---|
| public JMSContext createContext(int sessionMode) Creates a JMSContext with the default user identity and the specified session mode. A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.
The effect of setting the In a Java SE environment or in the Java EE application client container:
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
| |