I am trying to get account information (for now) on my internal webserver. I can get the information I need from the API. But unfortunately the dukascopy thread keeps running and generating errors. How can I kill the thread when stopping the strategy and disconnecting the client?
I get the account information with the following basic strategy (as found in the forum).
package forex.JfUtil;
import com.dukascopy.api.*;
import forex.model.Consts;
public class MyFirstStrategy implements IStrategy{
private IAccount myAccount = null;
private IContext myContext = null;
@Override
public void onStart(IContext context) throws JFException {
myContext = context;
myAccount = myContext.getAccount();
Consts.LOG.debug("Balance: " + myAccount.getBalance());
}
@Override
public void onStop() throws JFException {
Consts.LOG.debug("Strategy successfully stopped!");
}
}
I keep the other methods empty.
Then I launch the strategy from a servlet with the following code:
import com.dukascopy.api.system.ClientFactory;
import com.dukascopy.api.system.IClient;
import forex.JfUtil.MyFirstStrategy;
import forex.model.Consts;
import javax.servlet.*;
import java.io.IOException;
import java.net.NoRouteToHostException;
@WebServlet("/BalanceFromDuka")
public class BalanceFromDuka extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
IClient client = null;
try {
client = ClientFactory.getDefaultInstance();
Consts.LOG.info("Connecting & testing ...");
client.connect("https://www.dukascopy.com/client/demo/jclient/jforex.jnlp", "", "");
//wait for it to connect
int i = 10; //wait max ten seconds
while (i > 0 && !client.isConnected()) {
Thread.sleep(1000);
i--;
}
if (!client.isConnected()) {
Consts.LOG.error("Failed to connect Dukascopy servers");
} else {
final long strategyId = client.startStrategy(new MyFirstStrategy());
client.stopStrategy(strategyId);
}
} catch (Exception e) {
Consts.LOG.error("EXCEPTION", e);
} finally {
if (client!=null) {
client.disconnect();
Consts.LOG.debug("Disconnected from Dukascopy servers");
}
}
RequestDispatcher view = request.getRequestDispatcher("/DashServlet.do");
view.forward(request, response);
}
}
I would expect that dukascopy threads would stop after the strategy ends and the client is disconnected. My app logs are:
18:58:22 [ http-bio-7070-exec-4] - INFO - forex.web.BalanceFromDuka: 39 - Connected to Dukascopy servers
18:58:25 [ Strategy MyFirstStrategy] - DEBUG - forex.dukaTools.MyFirstStrategy: 38 - Balance: xxxxxx
18:58:25 [ Strategy MyFirstStrategy] - DEBUG - forex.dukaTools.MyFirstStrategy:113 - Strategy successfully stopped!
18:58:26 [ http-bio-7070-exec-4] - DEBUG - forex.web.BalanceFromDuka: 50 - Disconnected from Dukascopy servers
Unfortunately, I keep getting the following errors every minute in my logs:
18:59:19 [CriteriaIsolationExecutorThreadsMonitor] - ERROR - dukascopy.transport.client.CriteriaThread: 48 - Found not fired event, with wait time > 2 sec: {"userId":"...
19:00:19 [CriteriaIsolationExecutorThreadsMonitor] - ERROR - dukascopy.transport.client.CriteriaThread: 48 - Found not fired event, with wait time > 2 sec: {"userId":"...
19:01:19 [CriteriaIsolationExecutorThreadsMonitor] - ERROR - dukascopy.transport.client.CriteriaThread: 48 - Found not fired event, with wait time > 2 sec: {"userId":"...
etc....
19:40:19 [CriteriaIsolationExecutorThreadsMonitor] - ERROR - dukascopy.transport.client.CriteriaThread: 48 - Found not fired event, with wait time > 2 sec: {"userId":"...
If I launch the strategy a second time to get additional information, it will create a second thread which will also remain active and will also generate errors. Therefore the number of threads keeps increasing on the webserver

Even If I stop my webapp, these threads are still running.
I realized there are more threads still running after disconnecting iClient (although it seems only CriteriaIsolationExecutorThreadsMonitor creates problems):
SEVERE: The web application [/forex-beta] appears to have started a thread named [CriteriaIsolationExecutorThreadsMonitor] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [/forex-beta] appears to have started a thread named [ActivityLogger] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [/forex-beta] appears to have started a thread named [Mina_Thread_1] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [/forex-beta] appears to have started a thread named [OrderedThreadPoolExecutor CleanUp] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [/forex-beta] appears to have started a thread named [LiveCurrencyMarketProcessingThread 1] but has failed to stop it. This is very likely to create a memory leak.
The CriteriaIsolationExecutorThreadsMonitor thread is problematic because it keeps generating errors in the log and the number of these threads increases each time I launch the strategy to get data.
So am I doing something wrong when ending the strategy and disconnecting the client? Should I wait for other threads to end before? How can I get rid of the dukascopy.transport.client.CriteriaThread errors and stop the number of thread to increase?
I am using DDS2-jClient-JForex:2.36
Thank you in advance for any help