Foren

Can I receive a message just before I am being replaced in a re-deploy

thumbnail
Gerald Rubin, geändert vor 11 Jahren.

Can I receive a message just before I am being replaced in a re-deploy

Junior Member Beiträge: 59 Beitrittsdatum: 23.10.11 Neueste Beiträge
[LR 6.1.0 CE GA1] One of my beans acts as a static data cache. It is injected into a number of other beans (all in the same war). The static cache loads users' data from the database and holds it in memory for quick access.

I start a thread in this data cache that runs every 30 minutes and deletes from memory any user's data that hasn't been touched in 90 minutes (both numbers are configurable).

When I redeploy the war containing this data cache and all the portlets that inject it, a new instance of the data cache is started (with an empty HashMap of user data), but the old threads are not killed. Is there any mechanism that I can use to know that I should kill threads before I am about to be replaced?

I guess if there isn't I could kill my threads whenever there is no data in the bean's HashMap (it all having been cleaned out), assuming these old threads are still running every 30 minutes and probably accessing some HashMap. But were those threads keeping some heap memory from being deleted? Beats me.

So, to summarize: I think my data cache bean is being kept alive even after it is redeployed while its threads wake up on schedule, look at some collection and go back to sleep.

I hope this made sense to someone. As you can see, it barely does to me.

Thanks.
thumbnail
Bijan Vakili, geändert vor 11 Jahren.

RE: Can I receive a message just before I am being replaced in a re-deploy

Expert Beiträge: 375 Beitrittsdatum: 10.03.09 Neueste Beiträge
As part of the Portlet 2.0 Lifecycle, the destroy() method allows such cleanup work to be done.
See section "PLT.5.2.3 End of Service" in JSR 286 spec.