Imagine I'm using otto to send events over a bus. Is it possible to set up another service that runs on a separate process that can listen to the same bus events?
I think since it's another JVM that the bus events will not be delivered to the other process. the problem is in otto I'm not sure if square is using intents which can go over several processes or broadcast receiver etc. can someone confirm?
Basically lets say i have process 1 which pushes an event onto the bus and lets say i have some method/class in process 2 which subscribes to that event. Will process 2 be able to receive the event?
Unfortunately I think the answer is no. Given it's a Guava fork and it feels like designed with simplicity of use, my guess is that it won't have anything to do with IPC.
From Guava page https://code.google.com/p/guava-libraries/wiki/EventBusExplained: "EventBus (...) is designed exclusively to replace traditional Java in-process event distribution using explicit registration. It is not a general-purpose publish-subscribe system, nor is it intended for interprocess communication."
I also have a project where Otto is being used to send a message from IntentService to an Activity. If I change the IntentService so it has a dedicated process things magically stop working. I can see the difference when I add:
<service android:name=".service.image.DownloadIntentService"
android:process=":myServiceProcess"
/>
Also if I understand its architecture correctly, it doesn't even try to dispatch events to a different threads. It puts the burden on the sender to sit on the correct thread before posting.
If you really had to stick to that design I'd suggest you could have a proxy service sitting in the same process as your target destination, and send events from "remote" service to your proxy through the usual IPC mechanisms? It may be overkill for something simple, but that's how I'd go
I don't intend to have definitive answers, since I'm still going up in the learning curve. I'd love to have my wallpaper service sitting in a dedicated process sending and receiving messages to my Activities/Services by using Otto.