Hash: SHA256


On 2/11/20 6:55 PM, Jerry Malcolm wrote:
> On 2/11/2020 4:32 PM, Christopher Schultz wrote:
> Jerry,
> On 2/11/20 3:11 PM, Jerry Malcolm wrote:
>>>> I need some advice.  I need to maintain a set of
>>>> long-running threads. When a request comes in, I need to
>>>> determine if I have a thread started for a particular id
>>>> found in the request.  So I need to have a hashmap of threads
>>>> keyed by the ids.  That part is simple enough.  But I'm
>>>> struggling with where to keep that hashmap object so that it
>>>> is available to all incoming requests (any session). This
>>>> object should persistently remain as long as Tomcat is
>>>> active. It must be scoped to the virtual host and only needs
>>>> to be available in one webapp context within that host.
>>>> Suggestions on how to proceed will be greatly appreciated.
> Can you give more details?
> - Does this HAVE TO remain available even when no web applications
> are deployed -- particularly the one(s) which established the
> registry to begin with?
>> It only needs to be available while the particular web app is
>> running. But the web app should start when TC boots and remain
>> running until TC stops.


> - Does this HAVE TO be limited to a single web app? Or is it okay
> to have separate thread-registries in each web application where
> this will be used?
>> It needs to be one global registry for the entire virtual host.

I'm not sure I understand this: will multiple web applications be
using this? Or just the one? Your answer to my first question makes it
seem like this is really just for one webapp, but your answer to the
second question makes it sound like this is really a cross-webapp servic

> - Does this HAVE TO be shared between all the web applications 
> deployed within a VirtualHost?
>> I'm pretty sure I can keep it all contained within one web app in
>> the host.

Hmm. More evidence for a single-webapp solution, which doesn't sound
like it really needs to be shared amongst all the webapps in a virtual

> - Do you need to be able to actually touch the java.lang.Thread 
> object, or do you just need to be able to determine whether a 
> particular id has a thread running for it?
>> I'm going to need to communicate a little bit with the threads
>> during processing of requests.  But I could use a dropbox/queue
>> approach for communication if necessary.

I'm trying to understand if an out-of-process mechanism will work. For
example, you could just have an RDBMS table like this:

| request-id | thread-started |
| 1234567890 |           true |
| 9876543210 |           true |

Whenever you start a thread for a request, you pop a record into the
db. Whenever it stops, it removes the record. The value for
"thread-started" is always "true". I suppose you could remove the
thread-started column because it doesn't do anything except remind the
humans what's happening. Maybe you want a date in that field. Maybe
you want to know when it *stopped*.

You could have as many of these tables as required, for whatever
applications you need. The applications who need to share these data
will all use the same table.

You only asked about knowing whether or not a thread was running. This
will work. I'm guessing you have other requirements that make this
solution too simple.

- -chris
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/


To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to