Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

Cost of calling setConnections every time


#1

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

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:

[code]try {
SiAuto.si.setConnections(“tcp(reconnect=true)”);
} catch (InvalidConnectionsException e) {
System.out.println(e.toString());
}

SiAuto.main.logMessage(event);
[/code]

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.