0

I'm wondering how to use stomp.py client in a pick-process-finish manner. This means: start; connect; check the queue; pick messages; process them; disconnect; finish.

The lib seems to be designed for indefinitely running clients which listen on arriving messages and process them. The main thread has to somehow remain running/connected while the listener thread processes the incoming messages.

It strikes me the examples are happily using time.sleep(X) to keep the main thread up and running. This is not really viable since there is no guarantee the listener thread finishes its work before the sleep ends. With a static sleep you can't guarantee you can process all messages before you disconnect, right? ACKs are fine and usable but still.

Is there a way to keep the main thread up until the listener finishes its work?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Yuri
  • 4,254
  • 1
  • 29
  • 46
  • This question could be closed for 2 different reasons actually. First, it is opinion based since it is asking an open-ended question about how to keep the main thread up while the listener finishes. Questions eliciting opinion-based answers are off topic. Second, it's asking for recommendations for another STOMP client. This is also off-topic. – Justin Bertram Jun 20 '22 at 18:01
  • @JustinBertram The first question is perfectly fine for Stack Overflow ("how can I do X" is our bread and butter). The second can be edited out, which I've done now. – TylerH Jun 21 '22 at 16:15
  • To be fair, the question is _not_ "how can I do X" but rather "is there a way to do X." I doubt @Yuri is looking for a simple "yes" or "no" here so the "how" is implied, but the ambiguity is problematic since it is nonetheless open for interpretation. In any case, "how can I do X" is not universally acceptable if the question is ultimately eliciting opinions (e.g. "how can I best skin a cat?"). In this case, there are a handful of ways to keep the main thread up until the listener finishes. Which way is "correct" for this use-case? There aren't enough details to know so it's opinion-based. – Justin Bertram Jun 21 '22 at 16:40

0 Answers0