Connect to the EMS Server
A connection with the EMS server is defined by the Connection object obtained from a Connection Factory.
For more information, see Connection Factories.
A connection is a fairly heavyweight object, so most clients will create a connection once and keep it open until the client exits. Your application can create multiple connections, if necessary.
The following examples show how to create a Connection object.
- Java
Use the
TibjmsConnectionFactoryobject’screateConnection()method to create aConnectionobject:Connection connection = factory.createConnection(userName,password);See the
tibjmsMsgProducer.javasample client for a working example. - C
Use the
tibemsConnectionFactory_CreateConnectionfunction to create a connection of typetibemsConnection:tibemsConnection connection = NULL;status = tibemsConnectionFactory_CreateConnection(factory,&connection, userName, password);If there is no connection factory, a C client can use the
tibemsConnection_Createfunction to dynamically create atibemsConnectiontype:status = tibemsConnection_Create(&connection,serverUrl, NULL, userName, password);The
tibemsConnection_Createfunction exists for backward compatibility, but the recommended procedure is that you createtibemsConnectionobjects from factories.See the
tibemsMsgProducer.csample client for a working example. - C#
Use the
ConnectionFactory.CreateConnectionmethod to create aConnectionobject:Connection connection =factory.CreateConnection(userName, password);See the
csMsgProducer.cssample client for a working example.