Class BindingsLifecycleController

java.lang.Object
org.springframework.cloud.stream.binding.BindingsLifecycleController
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

public class BindingsLifecycleController extends Object implements org.springframework.context.ApplicationContextAware
Lifecycle controller for the bindings. It is registered as a bean and once injected could be used to control the lifecycle f the bindings.
Since:
3.x
Author:
Oleg Zhurakousky, Soby Chacko
  • Constructor Details

  • Method Details

    • defineInputBinding

      public <P> P defineInputBinding(String bindingName)
      Allows to dynamically define a new input binding returning its consumer properties for further customization.
      Type Parameters:
      P - the type of consumer properties. For example, if binding derives from Kafka, it will return KafkaConsumerProperties.
      Parameters:
      bindingName - the name of the binding.
      Returns:
      instance of the consumer properties.
    • defineOutputBinding

      public <P> P defineOutputBinding(String bindingName)
      Allows to dynamically define a new input binding returning its producer properties for further customization.
      Type Parameters:
      P - the type of producer properties. For example, if binding derives from Kafka, it will return KafkaProducerProperties.
      Parameters:
      bindingName - the name of the binding.
      Returns:
      instance of the producer properties.
    • getExtensionProperties

      public <T> T getExtensionProperties(String bindingName)
      Will return producer or consumer properties for a specified binding. For example, calling `getExtensionProperties("foo-in-0")` on Kafka binding will return an instance of KafkaConsumerProperties.
      Type Parameters:
      T - type of producer or consumer properties for a specified binding
      Parameters:
      bindingName - name of the binding
      Returns:
      producer or consumer properties
    • getObjectMapper

      public tools.jackson.databind.ObjectMapper getObjectMapper()
      Provide an accessor for the custom ObjectMapper created by this controller.
      Returns:
      ObjectMapper
      Since:
      4.1.2
    • stop

      public void stop(String bindingName)
      Convenience method to stop the binding with provided `bindingName`.
      Parameters:
      bindingName - the name of the binding.
    • start

      public void start(String bindingName)
      Convenience method to start the binding with provided `bindingName`.
      Parameters:
      bindingName - the name of the binding.
    • pause

      public void pause(String bindingName)
      Convenience method to pause the binding with provided `bindingName`.
      Parameters:
      bindingName - the name of the binding.
    • resume

      public void resume(String bindingName)
      Convenience method to resume the binding with provided `bindingName`.
      Parameters:
      bindingName - the name of the binding.
    • changeState

      public void changeState(String bindingName, BindingsLifecycleController.State state)
      General purpose method to change the state of the provided binding.
      Parameters:
      bindingName - the name of the binding.
      state - the BindingsLifecycleController.State you wish to set this binding to
    • queryStates

      public List<Map<String,Object>> queryStates()
      Queries the List of states for all available bindings. The returned list consists of Binding objects which could be further interrogated using Binding.isPaused() and Binding.isRunning().
      Returns:
      the list of Bindings
    • queryState

      public List<Binding<?>> queryState(String name)
      Queries the individual state of a binding. The returned list Binding object could be further interrogated using Binding.isPaused() and Binding.isRunning().
      Returns:
      collection of Binding objects.
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException