This has been a long time coming (since before 1.0). The use of RequestDispatcher's
when sending messages instead of directly referencing the MessageBus is now
strongly-encouraged. In fact, new API extensions (such as the async API) will no longer
introduce APIs that use the MessageBus directly in terms of sending messages.
The current APIs remain backwards compatible. But use of request dispatchers will make
your application more scaleable, by allowing messaging to be sent truly asynchronously
from your code. As opposed to directly performing operations against the bus in the same
thread from whence you send your messages. You can simply inject a RequestDispatcher
just like you're used to injecting a MessageBus.
public class MyClass {
private RequestDispatcher dispatcher;
@Inject
public MyClass(RequestDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
public void sendAMessage() {
MessageBuilder.createMessage()
.toSubject("Foo").signalling().noErrorHandling()
.sendNowWith(dispatcher);
}
}
... and in the client, you can obtain an instance to the RequestDispatcher with:
ErraiBus.getDispatcher();
Best,
Mike.
Show replies by date