Setting headers on messages
Messages sent over the event bus can also contain headers.
This can be specified by providing a headers
object
inside the DeliveryOptions
object when sending or publishing:
var options = {
headers: {
"some-header" : "some-value"
}
}
vertx.eventBus().send("news.uk.sport", "Yay! Someone kicked a ball", options);
On the other side, the consumer can retrieve the message header as follows:
vertx.eventBus().consumer("news.uk.sport", function(e) {
console.log(e.headers().get("some-header"));
});