cancel
Showing results for 
Search instead for 
Did you mean: 

Long running servlet in a single node of a cluster

Former Member
0 Kudos

Good evening,

I am developing a J2EE application that consists of a number of web services that perform background processing of relatively long-running jobs. Status of the jobs actually need to be reported back to the SAP ABAP system, which we do via JCo. All communication back to ABAP occurs in a single long-running, JMS driven servlet. This callback servlet uses both a timestamp (last time status was sent back) or a count of status events to determine when to send data to the ABAP system.

All of this works great in a single Java instance J2EE configuration. However, when we introduce clustering into the configuration, we get one instance of the callback servlet per J2EE server process. Is there an easy way to configure the servlet so that it only runs on a single J2EE server process in one instance?

TIA,

- Bill

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Bill,

I admit I am not clear what is "JMS driven servlet". Are you implying that the servlet is started by receiving a JMS message ?

I just wanted to share what I know - you could define an MDB that runs only on one node of the cluster. The section for topic-on-all-nodes on

http://help.sap.com/saphelp_nw04/helpdata/de/37/30c557fad05341a951cfd051bf0b44/content.htm

You could also tune the EJB pool to have only one instance. In that way you will achieve in fact a MDB "singleton" for the cluster.

Then you could send a JMS message from your webservice whenever you want to do your ABAP calls.

Not sure if that is what you are looking for.

Hope That Helps

Peter

Former Member
0 Kudos

Hi Peter,

Thanks for the reply. Sorry for the confusion. It's a long-running servlet that starts when the web container starts. It then subscribes to JMS events via the normal JMS topic subscription mechanism. We collect information contained in the events and then send it back to SAP via JCo. Sending the info to SAP is based on a timer, and it is important that we only send it once, which is why we want to manage it in a single servlet in a single node.

You MDB suggestion is interesting. I'm concerned with creating a Thread (which we do because the JCo call may take a while) in an EJB. I thought that this was forbidden according to the spec. That's why we're doing it in the web container instead of the EJB container.

Thanks,

- Bill

Former Member
0 Kudos

Hi Bill,

Launching manually threads even from a web container is also not recommended as good J2EE practice.

If each applications launches its own set of threads that may easily crash the server. Another drawback of such long running servlet is that you are blocking application thread from the server. One last point - it seems that you are storing the data in the servlet at some intermediate variables without any persistance. What will happen if the server crashes ? Can you afford to loose the data ?

I am not implying that you launch threads from the MDB. I am just saying that you could define that single MDB and send messages directly to it. You do the job there inside the onMessage, no new thread. You will be guaranteed that no other call will be executed. You are guaranteed nothing will be lost in case server crashes, you will not use resources even if there is no traffic.

Btw, please feel free to give me a phone call or write an email to further discuss the issue. You can take the details from your CSN I am currently processing

Best Regards

Peter