A ConnectionFactory object provides a template that an application uses to create a Connection object. The application uses the Connection object to create a Session object.
For C and C++ applications a single type of ConnectionFactory has a property that enables you to select which type of protocol you want to use for a connection.
An XMS application can create multiple connections, and a multithreaded application can use a single Connection object concurrently on multiple threads. A Connection object encapsulates a communications connection between an application and a messaging server.
A connection serves several purposes:
The preferred way of assigning a connection's client identifier is to configure in a client-specific ConnectionFactory object using properties and transparently assign it to the connection it creates.
An alternative way of assigning a client identifier is to use a provider-specific value that is set on the Connection object. This value does not override the identifier that has been administratively configured. It is provided for the case where no administratively specified identifier exists. If an administratively specified identifier does exist, an attempt to override it with a provider-specific value causes an exception to be thrown. If an application explicitly sets an identifier, it must do this immediately after creating the connection and before any other action on the connection is taken; otherwise, an exception is thrown.
An XMS application typically creates a connection, one or more sessions, and a number of message producers and message consumers.
Creating a connection is relatively expensive in terms of system resources because it involves establishing a communications connection, and it might also involve authenticating the application.