Bookmark Topic Watch Topic
  • New Topic

Using Threads for BusinessLogic in a Distributed Servlet Container

 
Catalin Mihalache
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello,

I'm studying for SCWCD. Today I read in the Sevlet2.4 Specs about Distributed Servlets Container. There is a very interesting section (SRV.7.7.2) about persisting and migrating session objects.

In my old web-Java applications I used threads for performing some business logic (Business Logic that requested a lot of time). The idea was that at every 1 minute, the browser performed a request to check if my thread finished the job. For synchronization, I used some objects ob the session .

According with me, this model will fail when is used in a distributed servlet container - just because the session object may be persisted and migrated to another JVM. Obviously, the thread and the session object (that contains the synchronization objects) are on different JVMs.

My question for you are:
a) is this correct (the model is wrong) ?
b) how to solve this situation ? (but without using an EJB container)

Thanks and excuse my poor english.
Catalin Mihalache

--------------------

SCJP 5.0 - 95%
Ongoig: SCWCD 1.4
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Report post to moderator
Certainly keeping a reference to an object having a Thread in a session is dangerous because Thread is not serializable.

How about off-loading the time consuming business logic to another application and having your web app communicate with that application?

Possible coordination tech: Java Message Service, a SOAP based service, JavaSpaces is cool for larger scale distribution.

How complex is the data that the business logic needs to work with?

Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!