1

Topic: cost of calling setConnections every time

Hi, I'm trialing the software.  In order to be able to start SmartInspect Console against an already running application, I have to make my application call .setConnections before *every* single message sent.

try {
    SiAuto.si.setConnections("tcp()");
} catch (InvalidConnectionsException e) {
    System.out.println(e.toString());
}
SiAuto.main.logMessage(event);

How expensive is calling setConnections() like this?  Is there a more efficient way to do this?

2

Re: cost of calling setConnections every time

Hi Daniel,

thanks for your interest in SmartInspect. The same functionality can be achieved by specifying the 'reconnect' option for the 'tcp' protocol. This way you avoid parsing the connections string over and over again when logging a message. It looks like:

try {
    SiAuto.si.setConnections("tcp(reconnect=true)");
} catch (InvalidConnectionsException e) {
    System.out.println(e.toString());
}

SiAuto.main.logMessage(event);

It is sufficient to include this code only once in your application. Because of the reconnect option, there's no need to execute this code each time you log a message.
However, this doesn't change the fact that it is relatively expensive to initiate a TCP connection attempt for each message.

We therefore normally recommend logging to a file and use TCP only during debugging and development sessions.