java.lang.Object
dk.cloudcreate.essentials.components.queue.postgresql.QueueNameDuplicationFilter
All Implemented Interfaces:
dk.cloudcreate.essentials.components.foundation.postgresql.NotificationDuplicationFilter

public class QueueNameDuplicationFilter extends Object implements dk.cloudcreate.essentials.components.foundation.postgresql.NotificationDuplicationFilter
Custom filter to extract the "queue_name" property from the Postgresql Notification.getParameter() JSON content.
This filter is useful when dealing with multiple Notification's involving the same queue.
Example: if 100 messages are queued for the same QueueName in the same UnitOfWork, then the MultiTableChangeListener will notify the PostgresqlDurableQueues with 100 TableChangeNotification's. Using the QueueNameDuplicationFilter the PostgresqlDurableQueues will only receive a single TableChangeNotification for that specific QueueName. Filtering is only performed on Notifications returned in a single database notification poll
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface dk.cloudcreate.essentials.components.foundation.postgresql.NotificationDuplicationFilter

    dk.cloudcreate.essentials.components.foundation.postgresql.NotificationDuplicationFilter.TableNameDuplicationFilter
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    extractDuplicationKey(com.fasterxml.jackson.databind.JsonNode parameterJson)
    Extracts the "queue_name" field from the given JSON parameter, if it exists.
    Example Notification.getParameter() content:

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • QueueNameDuplicationFilter

      public QueueNameDuplicationFilter()
  • Method Details

    • extractDuplicationKey

      public Optional<String> extractDuplicationKey(com.fasterxml.jackson.databind.JsonNode parameterJson)
      Extracts the "queue_name" field from the given JSON parameter, if it exists.
      Example Notification.getParameter() content:
      
       {
         "table_name" : "durable_queues",
         "sql_operation" : "INSERT",
         "id" : "d897f4eb-ed90-4b10-9479-971bf9b26fd3",
         "queue_name" : "TestQueue",
         "added_ts" : "2024-11-26T17:09:41.279749+01:00",
         "next_delivery_ts" : "2024-11-26T17:09:41.279749+01:00",
         "delivery_ts" : null,
         "is_dead_letter_message" : false,
         "is_being_delivered" : false
       }
       
      Specified by:
      extractDuplicationKey in interface dk.cloudcreate.essentials.components.foundation.postgresql.NotificationDuplicationFilter
      Parameters:
      parameterJson - a JsonNode representing the JSON structure of the notification parameter
      Returns:
      an Optional containing the queue name if it exists, otherwise an empty Optional