Class KafkaListener
java.lang.Object
org.frankframework.extensions.kafka.AbstractKafkaFacade
org.frankframework.extensions.kafka.KafkaListener
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasPhysicalDestination,IConfigurable,IListener<org.apache.kafka.clients.consumer.ConsumerRecord<String,,byte[]>> IPullingListener<org.apache.kafka.clients.consumer.ConsumerRecord<String,,byte[]>> IScopeProvider,NameAware,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Category(EXPERIMENTAL)
@ConfigurationWarning("Experimental and under development. Do not use unless you wish to participate in this development.")
public class KafkaListener
extends AbstractKafkaFacade
implements IPullingListener<org.apache.kafka.clients.consumer.ConsumerRecord<String,byte[]>>
Experimental
IListener for listening to a topic in
a Kafka instance.
The Kafka integration is still under development so do not
currently use unless you wish to participate in this development.-
Field Summary
Fields inherited from class org.frankframework.extensions.kafka.AbstractKafkaFacade
properties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<org.apache.kafka.clients.consumer.ConsumerRecord<String, byte[]>> rawMessage, PipeLineSession pipeLineSession) Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.protected org.apache.kafka.clients.consumer.Consumer<String, byte[]> voidcloseThread(Map<String, Object> threadContext) Finalizes a message receiving thread.voidConfigure this component.extractMessage(RawMessageWrapper<org.apache.kafka.clients.consumer.ConsumerRecord<String, byte[]>> wrappedMessage, Map<String, Object> threadContext) Extracts data from message obtained fromIPullingListener.getRawMessage(Map)orIPushingListener.wrapRawMessage(Object, PipeLineSession).RawMessageWrapper<org.apache.kafka.clients.consumer.ConsumerRecord<String, byte[]>> getRawMessage(Map<String, Object> threadContext) Retrieves messages from queue or other channel, but does no processing on it.Prepares a thread for receiving messages.voidstart()Prepares the listener for receiving messages.voidstop()Close all resources used for listening.Methods inherited from class org.frankframework.extensions.kafka.AbstractKafkaFacade
checkConnectionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoader
-
Constructor Details
-
KafkaListener
public KafkaListener()
-
-
Method Details
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classAbstractKafkaFacade- Throws:
ConfigurationException- in case it was not able to configure the component.
-
start
public void start()Description copied from interface:IListenerPrepares the listener for receiving messages.start()is called once each time the listener is started. -
buildConsumer
-
stop
public void stop()Description copied from interface:IListenerClose all resources used for listening. Called once each time the listener is stopped. -
extractMessage
public Message extractMessage(@Nonnull RawMessageWrapper<org.apache.kafka.clients.consumer.ConsumerRecord<String, byte[]>> wrappedMessage, @Nonnull Map<String, Object> threadContext) Description copied from interface:IListenerExtracts data from message obtained fromIPullingListener.getRawMessage(Map)orIPushingListener.wrapRawMessage(Object, PipeLineSession). May also extract other parameters from the message and put those into the context.- Specified by:
extractMessagein interfaceIListener<org.apache.kafka.clients.consumer.ConsumerRecord<String,byte[]>> - Parameters:
wrappedMessage- TheRawMessageWrapperfrom which to extract theMessage.threadContext- Context to populate. Either aPipeLineSessionor aMapthreadContext depending on caller.- Returns:
- input
Messagefor adapter.
-
afterMessageProcessed
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<org.apache.kafka.clients.consumer.ConsumerRecord<String, byte[]>> rawMessage, PipeLineSession pipeLineSession) Description copied from interface:IListenerCalled to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.- Specified by:
afterMessageProcessedin interfaceIListener<org.apache.kafka.clients.consumer.ConsumerRecord<String,byte[]>>
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationNamein interfaceHasPhysicalDestination
-
openThread
Description copied from interface:IPullingListenerPrepares a thread for receiving messages. Called once for each thread that will listen for messages.- Specified by:
openThreadin interfaceIPullingListener<org.apache.kafka.clients.consumer.ConsumerRecord<String,byte[]>> - Returns:
- the threadContext for this thread. The threadContext is a Map in which
thread-specific data can be stored. May not be
null, must be a mutable map type.
-
closeThread
Description copied from interface:IPullingListenerFinalizes a message receiving thread. Called once for each thread that listens for messages, just beforeIListener.stop()is called.- Specified by:
closeThreadin interfaceIPullingListener<org.apache.kafka.clients.consumer.ConsumerRecord<String,byte[]>>
-
getRawMessage
public RawMessageWrapper<org.apache.kafka.clients.consumer.ConsumerRecord<String,byte[]>> getRawMessage(@Nonnull Map<String, Object> threadContext) Description copied from interface:IPullingListenerRetrieves messages from queue or other channel, but does no processing on it. Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, orsynchronized.Any thread-specific properties should be stored in and retrieved from the threadContext.
- Specified by:
getRawMessagein interfaceIPullingListener<org.apache.kafka.clients.consumer.ConsumerRecord<String,byte[]>>
-