cancel
Showing results for 
Search instead for 
Did you mean: 

Java API - EventHandler threads not getting killed

Former Member
0 Kudos

Hello everybody,

I didn't know whether to post this in the PI forum or in the MDM forum. I use the following scenario:

We run an EJB session bean in the Java Proxy environment of PI 7.1. In this bean we create an MDM session, log on to a repository and then attach a RecordListener that reacts to any change of the records. When an interesting change took place, the record is distributed to PI.

The code looks like this:


EventDispatcher evDis = new EventDispatcher(servername);
RecordListener recLis = new RecordListener();
evDis.registerDataNotifications(username, password, repIdent, regions[0]);
evDis.addListener(recLis);

The problem arises when we try to undeploy or stop the application. You would assume that it would stop everything connected to the application. However, it does not. The mentioned EventDispatcher creates a thread object when invoked, and this thread is never killed. The consequence: Records keep getting distributed as if nothing had happened, although the application is gone (even undeploying doesn't help). But when we redeploy the application, a new thread is created. So after some development you get 10 or more threads firing every change to PI. The only thing that helps is a restart of the J2EE engine.

So, my question: Has anybody here made a similar experience? Is this common for MDM or is rather PI the cause of this issue?

Any comments on that are very welcome.

Best regards,

Jörg

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Joerg,

Declare evDis and recLis as class level variable and call removeListener method on evDis in life cycle method of Ejb session bean.

Please write the below code in ejbRemove method.

if(evDis != null && recList != null){

evDis.removeListener(recList);

evDis.terminate();

}

Hope this helps......

Former Member
0 Kudos

Hi Veera,

thanks a lot, that pot me on the right track! In fact, it's the @PreDestroy annotation which has to be used for some cleanup method. When we execute this and included the coding you mentioned the threads are killed properly.

Currently we're facing the issue that somehow the commit status of the bean is not set to "Committed" and from the second message on we get exceptions. If anybody came across this, help is appreciated.

Best regards,

Jörg

Answers (0)