Class BindingsLifecycleController
java.lang.Object
org.springframework.cloud.stream.binding.BindingsLifecycleController
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
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionBindingsLifecycleController(List<InputBindingLifecycle> inputBindingLifecycles, List<OutputBindingLifecycle> outputBindingsLifecycles) -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeState(String bindingName, BindingsLifecycleController.State state) General purpose method to change the state of the provided binding.<P> PcreateInputBinding(String bindingName, String binderName, BindingProperties bindingProperties) Allows to dynamically create a new input binding returning its consumer properties for further customization.<P> PcreateOutputBinding(String bindingName, String binderName, BindingProperties bindingProperties) Allows to dynamically create a new output binding returning its producer properties for further customization.<P> PdefineInputBinding(String bindingName) Deprecated.since 5.0.2<P> PdefineOutputBinding(String bindingName) Deprecated.since 5.0.2<T> TgetExtensionProperties(String bindingName) Will return producer or consumer properties for a specified binding.tools.jackson.databind.ObjectMapperProvide an accessor for the custom ObjectMapper created by this controller.<P> PinitializeInputBinding(String bindingName) <P> PinitializeOutputBinding(String bindingName) voidConvenience method to pause the binding with provided `bindingName`.queryState(String name) Queries the individual state of a binding.Queries theListof states for all available bindings.voidConvenience method to resume the binding with provided `bindingName`.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidConvenience method to start the binding with provided `bindingName`.voidConvenience method to stop the binding with provided `bindingName`.
-
Constructor Details
-
BindingsLifecycleController
public BindingsLifecycleController(List<InputBindingLifecycle> inputBindingLifecycles, List<OutputBindingLifecycle> outputBindingsLifecycles)
-
-
Method Details
-
createInputBinding
public <P> P createInputBinding(String bindingName, String binderName, BindingProperties bindingProperties) Allows to dynamically create 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.binderName- the name of the binder.bindingProperties- instance of BindingProperties.- Returns:
- instance of the consumer properties.
-
createOutputBinding
public <P> P createOutputBinding(String bindingName, String binderName, BindingProperties bindingProperties) Allows to dynamically create a new output 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.binderName- the name of the binder.bindingProperties- instance of BindingProperties.- Returns:
- instance of the consumer properties.
-
defineInputBinding
Deprecated.since 5.0.2Allows 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.
-
initializeInputBinding
-
defineOutputBinding
Deprecated.since 5.0.2Allows 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.
-
initializeOutputBinding
-
getExtensionProperties
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
Convenience method to stop the binding with provided `bindingName`.- Parameters:
bindingName- the name of the binding.
-
start
Convenience method to start the binding with provided `bindingName`.- Parameters:
bindingName- the name of the binding.
-
pause
Convenience method to pause the binding with provided `bindingName`.- Parameters:
bindingName- the name of the binding.
-
resume
Convenience method to resume the binding with provided `bindingName`.- Parameters:
bindingName- the name of the binding.
-
changeState
General purpose method to change the state of the provided binding.- Parameters:
bindingName- the name of the binding.state- theBindingsLifecycleController.Stateyou wish to set this binding to
-
queryStates
Queries theListof states for all available bindings. The returned list consists ofBindingobjects which could be further interrogated usingBinding.isPaused()andBinding.isRunning().- Returns:
- the list of
Bindings
-
queryState
Queries the individual state of a binding. The returned listBindingobject could be further interrogated usingBinding.isPaused()andBinding.isRunning().- Returns:
- collection of
Bindingobjects.
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Throws:
org.springframework.beans.BeansException
-