public class PgSubscriberImpl extends Object implements PgSubscriber
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_CHANNEL_NAME_LENGTH |
static int |
NAMEDATALEN |
| Constructor and Description |
|---|
PgSubscriberImpl(Vertx vertx,
PgConnectOptions options) |
| Modifier and Type | Method and Description |
|---|---|
PgConnection |
actualConnection() |
static String |
applyIdLengthLimit(String channelName) |
PgChannel |
channel(String name)
Return a channel for the given
name. |
void |
close()
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.
|
PgSubscriber |
connect(Handler<AsyncResult<Void>> handler)
Connect the subscriber to Postgres.
|
PgSubscriber |
reconnectPolicy(Function<Integer,Long> policy)
Set the reconnect policy that is executed when the subscriber is disconnected.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsubscriberpublic static final int NAMEDATALEN
public static final int MAX_CHANNEL_NAME_LENGTH
public PgSubscriberImpl(Vertx vertx, PgConnectOptions options)
public PgSubscriber closeHandler(Handler<Void> handler)
PgSubscribercloseHandler in interface PgSubscriberhandler - the handlerpublic PgSubscriber reconnectPolicy(Function<Integer,Long> policy)
PgSubscriberpolicy 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 millisecondsreconnectPolicy in interface PgSubscriberpolicy - the policy to setpublic boolean closed()
closed in interface PgSubscriberpublic PgConnection actualConnection()
actualConnection in interface PgSubscribernullpublic PgSubscriber connect(Handler<AsyncResult<Void>> handler)
PgSubscriberconnect in interface PgSubscriberhandler - the handler notified of the connection success or failurepublic void close()
PgSubscriberclose in interface PgSubscriberpublic PgChannel channel(String name)
PgSubscribername.channel in interface PgSubscribername - 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
Copyright © 2020. All rights reserved.