Interface ReactiveMessagePipelineBuilder<T>
- Type Parameters:
T- the message payload type
- All Known Subinterfaces:
ReactiveMessagePipelineBuilder.ConcurrentOneByOneMessagePipelineBuilder<T>,ReactiveMessagePipelineBuilder.OneByOneMessagePipelineBuilder<T>
ReactiveMessagePipeline.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceBuilder interface for a pipeline that handles messages with concurrent one-by-one messages handlers.static interfaceBuilder interface for a pipeline that handles messages one-by-one. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the pipeline instance.messageHandler(Function<org.apache.pulsar.client.api.Message<T>, org.reactivestreams.Publisher<Void>> messageHandler) Sets a handler function that processes messages one-by-one.pipelineRetrySpec(reactor.util.retry.Retry pipelineRetrySpec) Sets a retry spec that will be used in case of failures in the pipeline.streamingMessageHandler(Function<reactor.core.publisher.Flux<org.apache.pulsar.client.api.Message<T>>, org.reactivestreams.Publisher<MessageResult<Void>>> streamingMessageHandler) Sets a handler function that processes the stream of messages.transformPipeline(Function<reactor.core.publisher.Mono<Void>, org.reactivestreams.Publisher<Void>> transformer) Sets a transform function that can be used to customize the pipeline.
-
Method Details
-
messageHandler
ReactiveMessagePipelineBuilder.OneByOneMessagePipelineBuilder<T> messageHandler(Function<org.apache.pulsar.client.api.Message<T>, org.reactivestreams.Publisher<Void>> messageHandler) Sets a handler function that processes messages one-by-one. When the message handler completes successfully, the message will be acknowledged. When the message handler emits an error, the error logger will be used to log the error and the message will be negatively acknowledged. If the error logger is not set, a default error message will be logged at the error level.
NOTE: Be aware that negative acknowledgements on ordered subscription types such as Exclusive, Failover and Key_Shared typically cause failed messages to be sent to consumers out of their original order. Negative acknowledgements for Key_Shared subscriptions may also cause message delivery to be blocked on broker versions before Pulsar 4.0. To maintain ordered message processing, it is recommended to wrap the message handler with Project Reactor's native retry logic using Mono.retryWhen to retry processing of each message indefinitely with backoff.
- Parameters:
messageHandler- a function that takes a message as input and returns an empty Publisher- Returns:
- a builder for the pipeline handling messages one-by-one
-
streamingMessageHandler
ReactiveMessagePipelineBuilder<T> streamingMessageHandler(Function<reactor.core.publisher.Flux<org.apache.pulsar.client.api.Message<T>>, org.reactivestreams.Publisher<MessageResult<Void>>> streamingMessageHandler) Sets a handler function that processes the stream of messages.- Parameters:
streamingMessageHandler- a function that takes a stream of messages as input and returns aMessageResultthat contains the acknowledgement or negative acknowledgement value of the processing.- Returns:
- the pipeline builder instance
-
transformPipeline
ReactiveMessagePipelineBuilder<T> transformPipeline(Function<reactor.core.publisher.Mono<Void>, org.reactivestreams.Publisher<Void>> transformer) Sets a transform function that can be used to customize the pipeline.- Parameters:
transformer- a transform function- Returns:
- the pipeline builder instance
- See Also:
-
Mono.transform(Function)
-
pipelineRetrySpec
Sets a retry spec that will be used in case of failures in the pipeline. The default is to retry indefinitely with an exponential backoff.- Parameters:
pipelineRetrySpec- the retry spec- Returns:
- the pipeline builder instance
- See Also:
-
Mono.retryWhen(Retry)
-
build
ReactiveMessagePipeline build()Builds the pipeline instance.- Returns:
- the pipeline instance
-