I'm investigating using ActiveMQ as an embedded in-process message queue in my application, but I'm a bit stuck on how I go about starting such an application up. I envision it like so (pseudocode, of course):
configureBroker ()
broker.start ()
createProducer (broker)
producer.start ()
for each desired consumer
createConsumer (broker)
consumer.start ()
waitForSignal ()
signalProducerShutdown ()
waitForEmptyQueues ()
signalConsumerShutdown ()
broker.stop ()
I've tried to assemble a simple version of this, but I'm stuck on how to write the producers and consumers in such a way as to have them work forever, or until told to quit. What is the best way to do this? I'm speaking specifically about the threading aspect; what do I need/want to spawn off in its own thread, etc...
I'm completely new to message queue based applications, so please be verbose with your examples.