Class PostgresNotificationConfiguration
java.lang.Object
io.micronaut.data.jdbc.notification.postgres.PostgresNotificationConfiguration
@Requires(classes=org.postgresql.PGConnection.class)
@ConfigurationProperties("micronaut.data.jdbc.notifications.postgres")
public final class PostgresNotificationConfiguration
extends Object
Shared schema-generation, listener dispatch, polling, connection validation, and reconnection settings for PostgreSQL notification subscriptions.
Recovery settings apply after a listening connection fails; initial startup failures are propagated to the application. Driver connection and socket timeouts are configured separately through the datasource's PostgreSQL driver properties.
- Since:
- 5.3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classSettings for reconnecting failed PostgreSQL notification connections.static enumNotification trigger modes supported by JDBC schema generation. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates configuration with default connection recovery settings.PostgresNotificationConfiguration(PostgresNotificationConfiguration.ConnectionRecoveryConfiguration connectionRecovery) -
Method Summary
Modifier and TypeMethodDescriptionReturns the timeout passed to each notification poll.intReturns the limit for waiting notifications per listener.Returns the trigger mode used by notification schema generation.Returns the interval between listening connection checks.Returns the timeout for a listening connection check.booleanWhether schema creation also installs PostgreSQL notification functions and triggers.voidsetPollTimeout(Duration pollTimeout) Sets the notification poll timeout.voidsetQueueCapacity(int queueCapacity) Sets the limit for waiting notifications per listener.voidsetSchemaGenerate(boolean schemaGenerate) Enables notification function and trigger creation alongside generated tables.voidsetSchemaGenerateMode(PostgresNotificationConfiguration.SchemaGenerationMode schemaGenerateMode) Selects row notifications or statement-level invalidations for generated triggers.voidsetValidationInterval(Duration validationInterval) Sets the interval between round trips that detect silently broken listening connections.voidsetValidationTimeout(Duration validationTimeout) Sets the timeout for a listening connection check.
-
Field Details
-
PREFIX
- See Also:
-
-
Constructor Details
-
PostgresNotificationConfiguration
public PostgresNotificationConfiguration()Creates configuration with default connection recovery settings. -
PostgresNotificationConfiguration
@Inject public PostgresNotificationConfiguration(PostgresNotificationConfiguration.ConnectionRecoveryConfiguration connectionRecovery) - Parameters:
connectionRecovery- the connection recovery settings
-
-
Method Details
-
getConnectionRecovery
- Returns:
- the connection recovery settings
-
getQueueCapacity
public int getQueueCapacity()Returns the limit for waiting notifications per listener. Defaults to 1,000. The running callback is excluded. Reaching the limit replaces waiting notifications with oneINVALIDATEevent. This limit does not reduce notifications generated by PostgreSQL.- Returns:
- the positive notification queue capacity
-
setQueueCapacity
public void setQueueCapacity(int queueCapacity) Sets the limit for waiting notifications per listener.- Parameters:
queueCapacity- the positive notification queue capacity- Throws:
IllegalArgumentException- if the limit is less than one
-
isSchemaGenerate
public boolean isSchemaGenerate()Whether schema creation also installs PostgreSQL notification functions and triggers. Defaults to false. Only datasources usingCREATEorCREATE_DROPschema generation are modified. The datasource user must have permission to create functions and triggers.- Returns:
- whether notification schema generation is enabled
-
setSchemaGenerate
public void setSchemaGenerate(boolean schemaGenerate) Enables notification function and trigger creation alongside generated tables. Has no effect forNONEorVALIDATE; migrations remain responsible for those schemas.- Parameters:
schemaGenerate- whether notification schema generation is enabled
-
getSchemaGenerateMode
Returns the trigger mode used by notification schema generation. Defaults toROW. Has no effect unless notification schema generation is enabled.- Returns:
- the notification trigger mode
-
setSchemaGenerateMode
public void setSchemaGenerateMode(PostgresNotificationConfiguration.SchemaGenerationMode schemaGenerateMode) Selects row notifications or statement-level invalidations for generated triggers. Applies to all subscribed tables included in schema generation.- Parameters:
schemaGenerateMode- the notification trigger mode
-
getPollTimeout
Returns the timeout passed to each notification poll. Defaults to one second. This setting does not limit connection establishment or SQL statement execution.Increasing this timeout can delay graceful shutdown when no notifications arrive. Stopping the subscription signals the receiver to exit but does not interrupt an active poll. The receiver checks the stop signal after the poll returns, then closes the listening connection. Graceful shutdown waits for that cleanup and any running listener callbacks to finish.
- Returns:
- the notification poll timeout
-
setPollTimeout
Sets the notification poll timeout. Durations are used at millisecond precision.- Parameters:
pollTimeout- a duration whose millisecond value is between one andInteger.MAX_VALUE- Throws:
IllegalArgumentException- if the millisecond value is outside the supported range
-
getValidationInterval
Returns the interval between listening connection checks. Defaults to thirty seconds. Checks run between notification polls, so an active poll can delay the next check.- Returns:
- the connection validation interval
-
setValidationInterval
Sets the interval between round trips that detect silently broken listening connections.- Parameters:
validationInterval- the positive interval, in milliseconds, up toInteger.MAX_VALUE- Throws:
IllegalArgumentException- if the interval is outside the supported range
-
getValidationTimeout
Returns the timeout for a listening connection check. Defaults to five seconds. The JDBC validation timeout is rounded up to whole seconds.- Returns:
- the connection validation timeout
-
setValidationTimeout
Sets the timeout for a listening connection check. Shutdown may wait for an active check.- Parameters:
validationTimeout- the positive timeout, in milliseconds, up toInteger.MAX_VALUE- Throws:
IllegalArgumentException- if the timeout is outside the supported range
-