Hi all,
I've been searching since a week to find a right solution for using basicConsume in a more complex scenario, a sort of async RPC, where the main application (publisher) sends a bunch of data sets to worker nodes (over one "inputs" queue) for sandboxed processing and later it should collect the results from the worker(s) through a "results" queue, AND then post-process them.
I've implemted everything and it works up to the point where the main app should collect the results in a separate function, which defines a DeliverCallback, which lets's says deserializes and puts the received messages in a ResultsList and it should stop consuming after all messages are taken from that results queue and return that List.
I couldn't find a proper condition to terminate the basicConsume and move on. the messageCount doesn't change and I'll be got stuck in an infinite loop if I use this as termination condition, I've read in the docs that the messages are only marked as N/Ack and that's probably why the message count doesn't go down after receiving and acknowledging them!
I realized now that I simply don't understand how the basicConsume works in the background?! I've read most parts of the documentation, googled my issue and couldn't find any useful result, only some open short discussion about similar situation...
I've tried different tutorials (my use case is more like the Tutorial 2, but in a duplex variation, where the workers also send something back!) In the basic tutorials, the basicConsume method is at the bottom of main method (Java) and is always listening.
However I need it to be at the middle of my function and only do the receiving part and die! I don't know how to do it correctly.