Class PostgresSubscribableChannel

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.channel.AbstractSubscribableChannel
org.springframework.integration.jdbc.channel.PostgresSubscribableChannel
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.IntegrationPattern, PostgresChannelMessageTableSubscriber.Subscription, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.SubscribableChannelManagement, org.springframework.integration.support.management.TrackableComponent, org.springframework.messaging.MessageChannel, org.springframework.messaging.SubscribableChannel, org.springframework.messaging.support.InterceptableChannel

public class PostgresSubscribableChannel extends org.springframework.integration.channel.AbstractSubscribableChannel implements PostgresChannelMessageTableSubscriber.Subscription
An AbstractSubscribableChannel for receiving push notifications for messages send to a group id of a JdbcChannelMessageStore. Receiving such push notifications is only possible if using a Postgres database.

In order to function, the Postgres database that is used must define a trigger for sending notifications upon newly arrived messages. This trigger is defined in the schema-postgresql.sql file within this artifact but commented out.

Since:
6.0
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel

    org.springframework.integration.channel.AbstractMessageChannel.ChannelInterceptorList

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
  • Field Summary

    Fields inherited from class org.springframework.integration.channel.AbstractMessageChannel

    interceptors, meters

    Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport

    EXPRESSION_PARSER, logger

    Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement

    METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME

    Fields inherited from interface org.springframework.messaging.MessageChannel

    INDEFINITE_TIMEOUT
  • Constructor Summary

    Constructors
    Constructor
    Description
    PostgresSubscribableChannel(JdbcChannelMessageStore jdbcChannelMessageStore, Object groupId, PostgresChannelMessageTableSubscriber messageTableSubscriber)
    Create a subscribable channel for a Postgres database.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    doSend(org.springframework.messaging.Message<?> message, long timeout)
     
    protected org.springframework.integration.dispatcher.MessageDispatcher
     
    Return the group id for which this subscription receives notifications.
    Return the region for which this subscription receives notifications.
    void
    Indicate that a message was added to the represented region and group id.
    void
    Set the executor to use for dispatching newly received messages.
    boolean
    subscribe(org.springframework.messaging.MessageHandler handler)
     
    boolean
    unsubscribe(org.springframework.messaging.MessageHandler handle)
     

    Methods inherited from class org.springframework.integration.channel.AbstractSubscribableChannel

    getSubscriberCount

    Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel

    addInterceptor, addInterceptor, destroy, getComponentType, getFullChannelName, getIChannelInterceptorList, getIntegrationPatternType, getInterceptors, getMetricsCaptor, getOverrides, isLoggingEnabled, onInit, registerMetricsCaptor, removeInterceptor, removeInterceptor, send, send, setDatatypes, setInterceptors, setLoggingEnabled, setMessageConverter, setShouldTrack

    Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport

    afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement

    getManagedName, getManagedType, getThisAs, registerObservationRegistry, setManagedName, setManagedType

    Methods inherited from interface org.springframework.messaging.MessageChannel

    send, send

    Methods inherited from interface org.springframework.integration.support.context.NamedComponent

    getBeanName, getComponentName
  • Constructor Details

    • PostgresSubscribableChannel

      public PostgresSubscribableChannel(JdbcChannelMessageStore jdbcChannelMessageStore, Object groupId, PostgresChannelMessageTableSubscriber messageTableSubscriber)
      Create a subscribable channel for a Postgres database.
      Parameters:
      jdbcChannelMessageStore - The message store to use for the relevant region.
      groupId - The group id that is targeted by the subscription.
      messageTableSubscriber - The subscriber to use for receiving notifications.
  • Method Details

    • setDispatcherExecutor

      public void setDispatcherExecutor(Executor executor)
      Set the executor to use for dispatching newly received messages.
      Parameters:
      executor - The executor to use.
    • subscribe

      public boolean subscribe(org.springframework.messaging.MessageHandler handler)
      Specified by:
      subscribe in interface org.springframework.messaging.SubscribableChannel
      Overrides:
      subscribe in class org.springframework.integration.channel.AbstractSubscribableChannel
    • unsubscribe

      public boolean unsubscribe(org.springframework.messaging.MessageHandler handle)
      Specified by:
      unsubscribe in interface org.springframework.messaging.SubscribableChannel
      Overrides:
      unsubscribe in class org.springframework.integration.channel.AbstractSubscribableChannel
    • getDispatcher

      protected org.springframework.integration.dispatcher.MessageDispatcher getDispatcher()
      Specified by:
      getDispatcher in class org.springframework.integration.channel.AbstractSubscribableChannel
    • doSend

      protected boolean doSend(org.springframework.messaging.Message<?> message, long timeout)
      Overrides:
      doSend in class org.springframework.integration.channel.AbstractSubscribableChannel
    • notifyUpdate

      public void notifyUpdate()
      Description copied from interface: PostgresChannelMessageTableSubscriber.Subscription
      Indicate that a message was added to the represented region and group id. Note that this method might also be invoked if there are no new messages to read, for example if another subscription already read those messages or if a new messages might have arrived during a temporary connection loss.
      Specified by:
      notifyUpdate in interface PostgresChannelMessageTableSubscriber.Subscription
    • getRegion

      public String getRegion()
      Description copied from interface: PostgresChannelMessageTableSubscriber.Subscription
      Return the region for which this subscription receives notifications.
      Specified by:
      getRegion in interface PostgresChannelMessageTableSubscriber.Subscription
      Returns:
      The relevant region of the JdbcChannelMessageStore.
    • getGroupId

      public Object getGroupId()
      Description copied from interface: PostgresChannelMessageTableSubscriber.Subscription
      Return the group id for which this subscription receives notifications.
      Specified by:
      getGroupId in interface PostgresChannelMessageTableSubscriber.Subscription
      Returns:
      The group id of the PostgresSubscribableChannel.