You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/reference/asciidoc/jdbc.adoc
+53
Original file line number
Diff line number
Diff line change
@@ -480,6 +480,8 @@ Instead, if possible, consider using either JMS- or AMQP-backed channels instead
480
480
For further reference, see the following resource:
481
481
482
482
* https://mikehadlow.blogspot.com/2012/04/database-as-queue-anti-pattern.html[The Database As Queue Anti-Pattern].
483
+
484
+
If you are still planning to use your database as a queue, consider using PostgreSQL and its notification mechanism which is described <<postgresql-push,in a subsequent section>>.
483
485
====
484
486
485
487
===== Concurrent Polling
@@ -575,6 +577,57 @@ The message data for a persistent channel is keyed in the store on the channel n
575
577
Consequently, if the channel names are not globally unique, the channels can pick up data that is not intended for them.
576
578
To avoid this danger, you can use the message store `region` to keep data separate for different physical channels that have the same logical name.
577
579
580
+
581
+
[[postgresql-push]]
582
+
==== PostgreSQL: Receiving Push Notifications
583
+
584
+
PostgreSQL offers a listen and notification framework for receiving push notifications upon database table manipulations.
585
+
Spring Integration leverages this mechanism (starting with version 6.0) to allow for receiving push notifications when new messages are added to a `JdbcChannelMessageStore`.
586
+
When using this feature, a database trigger must be defined, which can be found as part of the comments of the `schema-postgresql.sql` file which is included in the JDBC module of Spring Integration.
587
+
588
+
Push notifications are received via the `PostgresChannelMessageTableSubscriber` class which allows its subscribers to receive a callback upon the arrival of new messages for any given `region` and `groupId`.
589
+
These notifications are received even if a message was appended on a different JVM, but to the same database.
590
+
The `PostgresSubscribableChannel` implementation uses a `PostgresChannelMessageTableSubscriber.Subscription` contract to pull messages from the store as a reaction for notification from the mentioned `PostgresChannelMessageTableSubscriber` notifications.
591
+
592
+
For example, push notifications for `some group` can be received as follows:
593
+
594
+
====
595
+
[source,java]
596
+
----
597
+
@Bean
598
+
public JdbcChannelMessageStore messageStore(DataSource dataSource) {
599
+
JdbcChannelMessageStore messageStore = new JdbcChannelMessageStore(dataSource);
return new PostgresSubscribableChannel(messageStore, "some group", subscriber);
618
+
}
619
+
----
620
+
====
621
+
622
+
[IMPORTANT]
623
+
====
624
+
Any active `PostgresChannelMessageTableSubscriber` occupies an exclusive JDBC `Connection` for the duration of its active life cycle.
625
+
It is therefore important that this connection does not originate from a pooling `DataSource`.
626
+
Such connection pools do normally expect that issued connections are closed within a predefined timeout window.
627
+
628
+
For this need of an exclusive connection, it is also recommended that a JVM only runs a single `PostgresChannelMessageTableSubscriber` which can be used to register any number of subscriptions.
Copy file name to clipboardExpand all lines: src/reference/asciidoc/whats-new.adoc
+13-2
Original file line number
Diff line number
Diff line change
@@ -17,23 +17,34 @@ In general the project has been moved to Java 17 baseline and migrated from Java
17
17
[[x6.0-new-components]]
18
18
=== New Components
19
19
20
+
[[x6.0-mqtt]]
21
+
==== MQTT ClientManager
22
+
20
23
A new MQTT `ClientManager` has been added to support a reusable MQTT connection across different channel adapters.
21
24
See <<./mqtt.adoc#mqtt-shared-client,Shared MQTT Client Support>> for more information.
22
25
23
26
[[x6.0-graphql]]
24
-
=== GraphQL Support
27
+
==== GraphQL Support
25
28
26
29
The GraphQL support has been added.
27
30
See <<./graphql.adoc#graphql,GraphQL Support>> for more information.
28
31
29
32
[[x6.0-smb]]
30
-
=== SMB Support
33
+
==== SMB Support
31
34
32
35
SMB support has been added from the Spring Integration Extensions project.
33
36
The Java DSL (see `org.springframework.integration.smb.dsl.Smb` factory) also has been added to this module.
34
37
An `SmbStreamingMessageSource` and `SmbOutboundGateway` implementation are introduced.
35
38
See <<./smb.adoc#smb,SMB Support>> for more information.
36
39
40
+
[[x6.0-jdbc]]
41
+
==== PostgreSQL Push Notification
42
+
43
+
A `PostgresSubscribableChannel` allows to receive push notifications via `PostgresChannelMessageTableSubscriber` upon new messages add to the `JdbcChannelMessageStore`.
44
+
45
+
See <<./jdbc.adoc#postgresql-push,PostgreSQL: Receiving Push Notifications>> for more information.
0 commit comments