Q:

Handling messages received by Rabbitmq Client in Android Service

I have an android Service which is running Rabbitmq client and consuming messages from a queue. The client can receive message at any time, so i am starting the service via startService ( not binding methodology ). SO the issue is what kind of communication mechanism i use to communicate from service with the different activities: binding or a notification? Binding wont be that useful as msg recieved could be related to a different activity than the one which is visible .. and Creating a model layer for handling so many different msgs recieved in the queue in  the service is becoming a challenge as well... Any ideas and pointers?

A:

Pretty standard way to work with message queue is the following: you should add some kind of metadata to your message. And then massage handler when handle the message determine with the help of such metadata which exact class should handle your message. It's very useful to use Strategy pattern in that case. Using such a technique you easily could handle your message with several handlers as well. 
Metadata could be very different: starting form some field value (like tag for example), or you could extend your message from specific class or interface, etc...  
Answering to the second part of your question. Yes, of course if you using queue it should have a consumer. Consumer should play like message manager. It's a bad idea to alocate new thread  for each message, I think you'd better using thread pool if you want to use several threads in your app. But anyway, the amount of threads shouldn't be high, because it will affect your performance badly. Talking about the way should consumer determine message handle logic or this logic could be putted inside the thread, which will be handle concrete message - there I think both variants are possible. Each have it's own pros and cons. But I think that this logic better put to consumer, because consumer manage the messages from the queue, and this task is closer to message management then to message handling itself.

