Package io.vertx.redis.client
Class EventBusHandler
- java.lang.Object
-
- io.vertx.redis.client.EventBusHandler
-
public class EventBusHandler extends Object implements Handler<Response>
A handler that can be installed on a Redis connection usingRedisConnection.handler(Handler)
in order to consume subscription messages and send them on the Vert.x event bus.The message sent to the Vert.x event bus is a
JsonObject
with the following format:{ "status": "OK", "type": "message|subscribe|unsubscribe|pmessage|psubscribe|punsubscribe", "value": { "channel": "<the channel>", // for `[p]message`, `subscribe` and `unsubscribe` "message": "<the message>", // for `[p]message` "pattern": "<the pattern>", // for `pmessage`, `psubscribe` and `punsubscribe` "current": <number of current subscriptions> // for `[p]subscribe` and `[p]unsubscribe` } }
By default, the address to which the messages are sent isio.vertx.redis.<the channel>
. This can be changed by passing a different address prefix tocreate(Vertx, String)
. For example, if the prefix iscom.example
, the address iscom.example.<the channel>
.Note that for messages of types
psubscribe
andpunsubscribe
, there is no channel name. Therefore, these messages are sent to the address of<prefix>.<the pattern>
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EventBusHandler
create(Vertx vertx)
Creates a subscription handler that forwards messages to the event bus of the givenvertx
.static EventBusHandler
create(Vertx vertx, String addressPrefix)
Creates a subscription handler that forwards messages to the event bus of the givenvertx
.void
handle(Response reply)
Something has happened, so handle it.
-
-
-
Method Detail
-
create
public static EventBusHandler create(Vertx vertx)
Creates a subscription handler that forwards messages to the event bus of the givenvertx
. The default address prefix is used.
-
create
public static EventBusHandler create(Vertx vertx, String addressPrefix)
Creates a subscription handler that forwards messages to the event bus of the givenvertx
. The given address prefix is used.
-
-