> Connecting to the EMS Server
> A connection with the EMS server is defined by the Connection object obtained from a Connection Factory, as described in 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 TibjmsConnectionFactory object’s createConnection() method to create a Connection object:
> Connection connection = factory.createConnection(userName,password);
> See the tibjmsMsgProducer.java sample client for a working example.
> C
> Use the tibemsConnectionFactory_CreateConnection function to create a connection of type tibemsConnection:
> tibemsConnection connection = NULL;
> status = tibemsConnectionFactory_CreateConnection(factory,
> &connection, userName, password);
> If there is no connection factory, a C client can use the tibemsConnection_Create function to dynamically create a tibemsConnection type:
> status = tibemsConnection_Create(&connection,
> serverUrl,NULL,userName,password);
> The tibemsConnection_Create function exists for backward compatibility, but the recommended procedure is that you create tibemsConnection objects from factories.
> See the tibemsMsgProducer.c sample client for a working example.
> C#
> Use the ConnectionFactory.CreateConnection method to create a Connection object:
> Connection connection =
> factory.CreateConnection(userName, password);
> See the csMsgProducer.cs sample client for a working example.
> Starting, Stopping and Closing a Connection
> Before consuming messages, the Message Consumer client must "start" the connection. See Creating a Message Consumer for more details about Message Consumers.
> If you wish to temporarily suspend message delivery, you can "stop" the connection.
> When a client application exits, all open connections must be "closed." Unused open connections are eventually closed, but they do consume resources that could be used for other applications. Closing a connection also closes any sessions created by the connection.
> See the "start," "stop" and "close" methods for the Java Connection object, the C tibemsConnection type, and the C# Connection object.

Copyright © TIBCO Software Inc. All Rights Reserved.