Reputation: 1200
Do EventBus events work across an RMI connection?
Basic idea: I have an RMI server and any number of clients. The server holds the EventBus object and publishes it via a getEventBus()
method.
Desired outcome: When a client publishes something on the server's EventBus, other registered clients are informed.
Has anyone done something like this or knows why it wouldn't work? Are there any pitfalls if it does?
Upvotes: 1
Views: 519
Reputation: 116
I have just tried this and it works. You need to annotate the interface, and when you have instantiated it, register the proxy object.
When an event comes in, it seems that the EventBus simply calls the function on the proxy, and the remote object is called correctly over RMI.
Upvotes: 1
Reputation: 6178
Messages published by EventBus are only avaiable within your JVM. Since you use RMI I guess your server/clients will run in their own environments, so this is not possible (eventhough I heard, that ppl tried to implement a remote EventBus, but I don't know if that succeded). Normally EventBus is used for UI specific communication within the same application.
As soon as you want to communicate between different JVMs, something like Java Messaging Services (JMS) comes in handy to broadcast Events from server to interested clients. A famous implementation of JMS is ActiveMQ.
Upvotes: 2