-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Jerry,
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. Ok. > - 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 e. > - 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 host. > - 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 -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5EHQoACgkQHPApP6U8 pFgtyw/+NW7hivOQBhKGqdLgWjUtZkaDP1a5hkW4xMQFvBCkQTxowFDb42bAbIxF cT/nEeDOeiYhDXJEdU+SI/KvWNUc4SLXTuY4oxDTSyCn0bk9/QwRz0Z2+BVM7R6M 9lS0PLRoRZv/kvMeH/tLJa3RCBK/8N/yb++vSPsZzeNfrJIdlf27dgMHE7B9RDkg yAR5s3+zNFRn2eULGvul9HSauBG3V9+cPI2mBDk0LK2fcxe9M++8ZF3oYg0za/Js b3fm3rC0fGy+Zf9TVkstdXZN0ncwUXpjuml/7TogirEQxVK9SoxpnnAxYIG45Oz5 ERRGkwyGZcc4DdAp+xhHcJzXKR46a+tzYG+DruXXWBynAJAbyHzfx4bXtgbId7Zo qV0YsmAIqWUZMlHMwCL+T7Fx4wsOROY+SklYKvgPswKe0s/BzXLG+QBgAdvWfesD Ty64Tb61V5/XUnAI0rYDOAoRLKYDzknJiGRnElp02hqZHRNQ1yOP7rI1JtZ5rHTS nO09XyYrSxc3qCba2n3t5cwIAnJFE29QufPox2l0AM1ikCVt9y2d1B+GYy4PfvyO eJ7w9iHU1cQ3IJKZx3TkzyahJeObcPXC+QuX0eW+8+VrWzcGoXxlJ7Hvx53JFYKx P/jDOUPlSgMGy8Zdryi+E5CO9DIqJY6/kh085guUkzeBv4a8pRg= =QRJU -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org