Setting an EMS client connection's timeout parameter.

Setting an EMS client connection's timeout parameter.

book

Article ID: KB0089957

calendar_today

Updated On:

Products Versions
TIBCO Enterprise Message Service -
Not Applicable -

Description

Resolution:
Description:
=========
An application is trying to connect to an EMS server. If the  EMS server is unresponsive, how to set a timeout in the client application saying the server is unable to accept connections.

Environment:
=========
All


Resolution:
========

1). Set the setConnAttemptTimeout() properties on the client side.

For Java, use the TibjmsConnectionFactory object’s setConnAttemptCount(), setConnAttemptDelay(), and setConnAttemptTimeout() methods to establish new connection failure parameters.


   factory.setConnAttemptCount(10);

   factory.setConnAttemptDelay(1000);
   factory.setConnAttemptTimeout(1000);

public void setConnAttemptTimeout(int timeout)

Set the "Connect Attempt" timeout for a given connection. This timeout is per URL and per connect_attempt. If specifying two connect attempts for a given URL, for each attempt the client will wait at most "connect attempt timeout" amount of time for the connection to be established. If no connection is established within that time, the client's connection attempt is torn down. The minimum value is 100 milliseconds. If a value less than 100 milliseconds is specified, then during the connection attempt the minimum value of 100 milliseconds is used.

Parameters:
timeout - the timeout is in milliseconds.

For Java clients you can pass the properties through the system properties:

java -Dtibco.tibjms.connect.attempt.timeout=5000 tibjmsTopicSubscriber -server tcp://hostA:7222 –topic topic.sample

2). You can set the properties at the ConnectionFactory level if you are using JNDI in the factories.conf file.

If using JNDI lookup to get the ConnectionFactory object from the EMS server and are using it to create a connection to the EMS server, the client will use the properties set in the ConnectionFactory in the file factories.conf.  Note that connection factory properties set in factories.conf override the corresponding properties set using API calls. If you use JNDI, configure FT connection factory in factories.conf. For example:

[TopicConnectionFactory]
  type                  = topic
  url                   = tcp://localhost:7222
[connect_attempt_count|connect_attempt_delay|
connect_attempt_timeout|reconnect_attempt_count|
reconnect_attempt_delay|reconnect_attempt_timeout = value]

[QueueConnectionFactory]
  type                  = queue
  url                   = tcp://localhost:7222
[connect_attempt_count|connect_attempt_delay|
connect_attempt_timeout|reconnect_attempt_count|
reconnect_attempt_delay|reconnect_attempt_timeout = value]

- connect_attempt_timeout
- When attempting to connect to the EMS server, you can set this connection timeout period to abort the connection attempt after a specified period of time (in milliseconds).

Issue/Introduction

Setting an EMS client connection's timeout parameter.