Looking up a connection factory

A connection factory allows you to create connections with the EAServer JMS provider, and specify a set of configuration properties that define the connections.

Beginning in version 6.0, EAServer provides a common connection factory that you can use to create both queue and topic connections. Queue connections allow you to send and receive messages using the point-to-point messaging model. Topic connections allow you to publish and receive messages using the publish/subscribe messaging model.

To create and configure connection factories, use the Management Console—see “Connection factories”. However, you need not preconfigure connection factories unless their properties require nondefault values.

To look up preconfigured connection factories by name, use the JMS initial context factory com.sybase.jms.client.InitialContectFactory.

To look up connection factories that have not been preconfigured:

The following example illustrates how clients can use JNDI to look up a connection factory object, where ctx is the initial naming context:

// Look up a common connection factory that has not been preconfigured. 
// You can use this connection factory to create queue and topic connections.

ConnectionFactory myConnFactry=
 (ConnectionFactory) ctx.lookup(“MyConnectionFactory”);

// Look up a preconfigured queue connection factory

QueueConnectionFactory queueCF =
 (QueueConnectionFactory) ctx.lookup(“MyTestQueueCF”);

// Look up a preconfigured topic connection factory

TopicConnectionFactory topicCF =
 (TopicConnectionFactory) ctx.lookup(“MyTestTopicCF”);

If the connection factory cannot be found, EAServer throws a javax.naming.NamingException.