Open
Description
Hi,
I was wondering whether
@Query("LISTEN request_event_notification", nativeQuery = true)
fun getNewRequestStream(): Flux<RequestModel>
is supported?
// 1
Using the PGconnection manually it is a two step process:
connection.createStatement("LISTEN request_event_notification").execute()
.flatMap(PostgresqlResult::getRowsUpdated).subscribe();
// 2
connection.getNotifications().map(Notification::getParameter);
So I was wondering whether spring data r2dbc would support it directly in Repositories, and correctly serialize the json/text from postgres into the corresponding type (RequestModel)
corresponding SQL:
CREATE OR REPLACE FUNCTION notify_event() RETURNS TRIGGER AS
$$
DECLARE
payload JSON;
BEGIN
payload = row_to_json(NEW);
PERFORM pg_notify('request_event_notification', payload::text);
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS notify_request_event ON request;
CREATE TRIGGER notify_request_event
AFTER INSERT OR UPDATE OR DELETE
ON request
FOR EACH ROW
EXECUTE PROCEDURE notify_event();