public interface PgSubscriber
LISTEN/UNLISTEN
to Postgres channels.
The subscriber manages a single connection to Postgres.Modifier and Type | Method and Description |
---|---|
PgConnection |
actualConnection() |
PgChannel |
channel(String name)
Return a channel for the given
name . |
Future<Void> |
close()
Like
close(Handler) but with a future of the result |
void |
close(Handler<AsyncResult<Void>> handler)
Close the subscriber, the retry policy will not be invoked.
|
boolean |
closed() |
PgSubscriber |
closeHandler(Handler<Void> handler)
Set an handler called when the subscriber is closed.
|
Future<Void> |
connect()
Like
connect(Handler) but with a future of the result |
PgSubscriber |
connect(Handler<AsyncResult<Void>> handler)
Connect the subscriber to Postgres.
|
PgSubscriber |
reconnectPolicy(java.util.function.Function<Integer,Long> policy)
Set the reconnect policy that is executed when the subscriber is disconnected.
|
static PgSubscriber |
subscriber(Vertx vertx,
PgConnectOptions options)
Create a subscriber.
|
static PgSubscriber subscriber(Vertx vertx, PgConnectOptions options)
vertx
- the vertx instanceoptions
- the connect optionsPgChannel channel(String name)
name
.name
- the channel name
This will be the name of the channel exactly as held by Postgres for sending
notifications. Internally this name will be truncated to the Postgres identifier
maxiumum length of (NAMEDATALEN = 64) - 1 == 63
characters, and prepared
as a quoted identifier without unicode escape sequence support for use in
LISTEN/UNLISTEN
commands. Examples of channel names and corresponding
NOTIFY
commands:
name == "the_channel"
: NOTIFY the_channel, 'msg'
,
NOTIFY The_Channel, 'msg'
, or NOTIFY "the_channel", 'msg'
succeed in delivering a message to the created channel
name == "The_Channel"
: NOTIFY "The_Channel", 'msg'
,
succeeds in delivering a message to the created channel
Future<Void> connect()
connect(Handler)
but with a future of the resultPgSubscriber connect(Handler<AsyncResult<Void>> handler)
handler
- the handler notified of the connection success or failurePgSubscriber reconnectPolicy(java.util.function.Function<Integer,Long> policy)
policy
function is called with the actual
number of retries and returns an amountOfTime
value:
amountOfTime < 0
: the subscriber is closed and there is no retryamountOfTime == 0
: the subscriber retries to connect immediatelyamountOfTime > 0
: the subscriber retries after amountOfTime
millisecondspolicy
- the policy to setPgSubscriber closeHandler(Handler<Void> handler)
handler
- the handlerPgConnection actualConnection()
null
boolean closed()
Future<Void> close()
close(Handler)
but with a future of the resultvoid close(Handler<AsyncResult<Void>> handler)
Copyright © 2021 Eclipse. All rights reserved.