org.eclipse.microprofile.reactive.messaging.Acknowledgment Java Examples

The following examples show how to use org.eclipse.microprofile.reactive.messaging.Acknowledgment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeanWithMessageProcessors.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(NO_ACKNOWLEDGMENT_BUILDER)
@Acknowledgment(Acknowledgment.Strategy.NONE)
@Outgoing("sink-" + NO_ACKNOWLEDGMENT_BUILDER)
public ProcessorBuilder<Message<String>, Message<String>> processorWithNoAckWithBuilder() {
    return ReactiveStreams.<Message<String>> builder()
            .flatMap(m -> ReactiveStreams.of(Message.of(m.getPayload()), Message.of(m.getPayload())))
            .peek(m -> processed(NO_ACKNOWLEDGMENT_BUILDER, m));
}
 
Example #2
Source File: BeanWithStreamTransformers.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_ACKNOWLEDGMENT)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
@Outgoing("sink-" + PRE_ACKNOWLEDGMENT)
public Publisher<Message<String>> processorWitPreAck(Publisher<Message<String>> input) {
    return ReactiveStreams.fromPublisher(input)
            .flatMap(m -> ReactiveStreams.of(Message.of(m.getPayload()), Message.of(m.getPayload())))
            .peek(m -> processed(PRE_ACKNOWLEDGMENT, m.getPayload()))
            .buildRs();
}
 
Example #3
Source File: BeanWithProcessorsManipulatingPayloads.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(NO_ACKNOWLEDGMENT_CS)
@Acknowledgment(Acknowledgment.Strategy.NONE)
@Outgoing("sink-" + NO_ACKNOWLEDGMENT_CS)
public CompletionStage<String> processorWithNoAckCS(String input) {
    return CompletableFuture.completedFuture(input)
            .thenApply(m -> {
                processed(NO_ACKNOWLEDGMENT_CS, input);
                return m + "1";
            });
}
 
Example #4
Source File: ProcessorMediator.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
private void processMethodReturningAProcessorOfMessages() {
    Processor<Message<?>, Message<?>> result = Objects.requireNonNull(invoke(),
            msg.methodReturnedNull(configuration.methodAsString()));

    this.processor = ReactiveStreams.<Message<?>> builder()
            .flatMapCompletionStage(msg -> {
                if (configuration.getAcknowledgment() == Acknowledgment.Strategy.PRE_PROCESSING) {
                    return msg.ack().thenApply((x -> msg));
                } else {
                    return CompletableFuture.completedFuture(msg);
                }
            })
            .via(result)
            .buildRs();
}
 
Example #5
Source File: BeanWithProcessorsProducingPayloadStreams.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_ACKNOWLEDGMENT)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
@Outgoing("sink-" + PRE_ACKNOWLEDGMENT)
public Publisher<String> processorWithPreAck(String input) {
    return ReactiveStreams.of(input)
            .flatMap(m -> ReactiveStreams.of(m, m))
            .peek(m -> processed(PRE_ACKNOWLEDGMENT, m))
            .buildRs();
}
 
Example #6
Source File: MediatorConfigurationSupport.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
public Acknowledgment.Strategy processSuppliedAcknowledgement(List<?> incomings,
        Supplier<Acknowledgment.Strategy> supplier) {
    Acknowledgment.Strategy result = supplier.get();
    if (!incomings.isEmpty()) {
        return result;
    } else if (result != null) {
        throw ex.definitionExceptionUnsupported("@Outgoing", methodAsString);
    }
    return null;
}
 
Example #7
Source File: MediatorConfigurationSupport.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
public ValidationOutput validate(Shape shape, Acknowledgment.Strategy acknowledgment) {
    switch (shape) {
        case SUBSCRIBER:
            return validateSubscriber();
        case PUBLISHER:
            return validatePublisher();
        case PROCESSOR:
            return validateProcessor(acknowledgment);
        case STREAM_TRANSFORMER:
            return validateStreamTransformer(acknowledgment);
        default:
            throw ex.illegalStateExceptionForValidate(shape);
    }
}
 
Example #8
Source File: BeanWithStreamTransformers.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(NO_ACKNOWLEDGMENT_BUILDER)
@Acknowledgment(Acknowledgment.Strategy.NONE)
@Outgoing("sink-" + NO_ACKNOWLEDGMENT_BUILDER)
public PublisherBuilder<Message<String>> processorWithNoAckWithBuilder(PublisherBuilder<Message<String>> input) {
    return input
            .flatMap(m -> ReactiveStreams.of(Message.of(m.getPayload()), Message.of(m.getPayload())))
            .peek(m -> processed(NO_ACKNOWLEDGMENT_BUILDER, m.getPayload()));
}
 
Example #9
Source File: DynamicTopicProducingBean.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming("dyn-data")
@Outgoing("sink")
@Acknowledgment(Acknowledgment.Strategy.MANUAL)
public MqttMessage<String> process(Message<Integer> input) {
    String topic = "T" + input.getPayload();
    topics.add(topic);
    return MqttMessage.of(topic, input.getPayload().toString(), MqttQoS.AT_LEAST_ONCE, false).withAck(input::ack);
}
 
Example #10
Source File: BeanWithProcessorsProducingPayloadStreams.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(NO_ACKNOWLEDGMENT)
@Acknowledgment(Acknowledgment.Strategy.NONE)
@Outgoing("sink-" + NO_ACKNOWLEDGMENT)
public Publisher<String> processorWithNoAck(String input) {
    return ReactiveStreams.of(input)
            .flatMap(m -> ReactiveStreams.of(m, m))
            .peek(m -> processed(NO_ACKNOWLEDGMENT, m))
            .buildRs();
}
 
Example #11
Source File: BeanWithPayloadProcessors.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(NO_ACKNOWLEDGMENT_BUILDER)
@Acknowledgment(Acknowledgment.Strategy.NONE)
@Outgoing("sink-" + NO_ACKNOWLEDGMENT_BUILDER)
public ProcessorBuilder<String, String> processorWithNoAckWithBuilder() {
    return ReactiveStreams.<String> builder()
            .flatMap(m -> ReactiveStreams.of(m, m))
            .peek(m -> processed(NO_ACKNOWLEDGMENT_BUILDER, m));
}
 
Example #12
Source File: BeanWithPayloadProcessors.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_ACKNOWLEDGMENT_BUILDER)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
@Outgoing("sink-" + PRE_ACKNOWLEDGMENT_BUILDER)
public ProcessorBuilder<String, String> processorWithPreAckBuilder() {
    return ReactiveStreams.<String> builder()
            .flatMap(m -> ReactiveStreams.of(m, m))
            .peek(m -> processed(PRE_ACKNOWLEDGMENT_BUILDER, m));
}
 
Example #13
Source File: BeanWithMessageProcessors.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_ACKNOWLEDGMENT)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
@Outgoing("sink-" + PRE_ACKNOWLEDGMENT)
public Processor<Message<String>, Message<String>> processorWithPreAck() {
    return ReactiveStreams.<Message<String>> builder()
            .flatMap(m -> ReactiveStreams.of(Message.of(m.getPayload()), Message.of(m.getPayload())))
            .peek(m -> processed(PRE_ACKNOWLEDGMENT, m))
            .buildRs();
}
 
Example #14
Source File: BeanWithProcessorsManipulatingPayloads.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(POST_ACKNOWLEDGMENT_UNI)
@Acknowledgment(Acknowledgment.Strategy.POST_PROCESSING)
@Outgoing("sink-" + POST_ACKNOWLEDGMENT_UNI)
public Uni<String> processorWithPostAckUNI(String input) {
    processed(POST_ACKNOWLEDGMENT_UNI, input);
    return Uni.createFrom().item(() -> input + "1");
}
 
Example #15
Source File: ConsumptionBeanUsingRawMessage.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming("data")
@Outgoing("sink")
@Acknowledgment(Acknowledgment.Strategy.MANUAL)
public Message<Integer> process(Message<Integer> input) {
    kafka.add(input);
    return Message.of(input.getPayload() + 1, input::ack);
}
 
Example #16
Source File: BeanWithMessageProcessors.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(MANUAL_ACKNOWLEDGMENT_BUILDER)
@Acknowledgment(Acknowledgment.Strategy.MANUAL)
@Outgoing("sink-" + MANUAL_ACKNOWLEDGMENT_BUILDER)
public ProcessorBuilder<Message<String>, Message<String>> processorWithAckWithBuilder() {
    return ReactiveStreams.<Message<String>> builder()
            .flatMapCompletionStage(m -> m.ack().thenApply(x -> m))
            .flatMap(m -> ReactiveStreams.of(Message.of(m.getPayload()), Message.of(m.getPayload())))
            .peek(m -> processed(MANUAL_ACKNOWLEDGMENT_BUILDER, m));
}
 
Example #17
Source File: BeanWithProcessorsManipulatingMessages.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_ACKNOWLEDGMENT_UNI)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
@Outgoing("sink")
public Uni<Message<String>> processorWithPreAckUni(Message<String> input) {
    processed(PRE_ACKNOWLEDGMENT_UNI, input);
    return Uni.createFrom().completionStage(() -> CompletableFuture.completedFuture(Message.of(input.getPayload() + "1")));
}
 
Example #18
Source File: BeanWithProcessorsProducingPayloadStreams.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_ACKNOWLEDGMENT_BUILDER)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
@Outgoing("sink-" + PRE_ACKNOWLEDGMENT_BUILDER)
public PublisherBuilder<String> processorWithPreAckBuilder(String input) {
    return ReactiveStreams.of(input)
            .flatMap(m -> ReactiveStreams.of(m, m))
            .peek(m -> processed(PRE_ACKNOWLEDGMENT_BUILDER, m));
}
 
Example #19
Source File: BeanWithProcessorsProducingMessageStreams.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(NO_ACKNOWLEDGMENT_BUILDER)
@Acknowledgment(Acknowledgment.Strategy.NONE)
@Outgoing("sink-" + NO_ACKNOWLEDGMENT_BUILDER)
public PublisherBuilder<Message<String>> processorWithNoAckWithBuilder(Message<String> message) {
    return ReactiveStreams.of(message)
            .flatMap(m -> ReactiveStreams.of(Message.of(m.getPayload()), Message.of(m.getPayload())))
            .peek(m -> processed(NO_ACKNOWLEDGMENT_BUILDER, message));
}
 
Example #20
Source File: BeanWithProcessorsProducingMessageStreams.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_ACKNOWLEDGMENT)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
@Outgoing("sink-" + PRE_ACKNOWLEDGMENT)
public Publisher<Message<String>> processorWithPreAck(Message<String> input) {
    return ReactiveStreams.of(input)
            .flatMap(m -> ReactiveStreams.of(Message.of(m.getPayload()), Message.of(m.getPayload())))
            .peek(m -> processed(PRE_ACKNOWLEDGMENT, m))
            .buildRs();
}
 
Example #21
Source File: BeanWithProcessorsProducingMessageStreams.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_ACKNOWLEDGMENT_BUILDER)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
@Outgoing("sink-" + PRE_ACKNOWLEDGMENT_BUILDER)
public PublisherBuilder<Message<String>> processorWithPreAckBuilder(Message<String> input) {
    return ReactiveStreams.of(input)
            .flatMap(m -> ReactiveStreams.of(Message.of(m.getPayload()), Message.of(m.getPayload())))
            .peek(m -> processed(PRE_ACKNOWLEDGMENT_BUILDER, m));
}
 
Example #22
Source File: SubscriberBeanWithMethodsReturningSubscribers.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(MANUAL_ACKNOWLEDGMENT_MESSAGE)
@Acknowledgment(Acknowledgment.Strategy.MANUAL)
public Subscriber<Message<String>> subWithAckWithMessage() {
    return ReactiveStreams.<Message<String>> builder()
            .flatMapCompletionStage(m -> m.ack().thenApply(x -> m))
            .forEach(m -> {
                processed(MANUAL_ACKNOWLEDGMENT_MESSAGE, m.getPayload());
                microNap();
            })
            .build();
}
 
Example #23
Source File: SubscriberBeanWithMethodsReturningSubscribers.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(NO_ACKNOWLEDGMENT_MESSAGE)
@Acknowledgment(Acknowledgment.Strategy.NONE)
public Subscriber<Message<String>> subWithNoAckWithMessage() {
    return ReactiveStreams.<Message<String>> builder()
            .forEach(m -> {
                processed(NO_ACKNOWLEDGMENT_MESSAGE, m.getPayload());
                microNap();
            })
            .build();
}
 
Example #24
Source File: SubscriberBeanWithMethodsReturningSubscribers.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(NO_ACKNOWLEDGMENT_PAYLOAD)
@Acknowledgment(Acknowledgment.Strategy.NONE)
public Subscriber<String> subWithNoAckWithPayload() {
    return ReactiveStreams.<String> builder()
            .forEach(m -> {
                processed(NO_ACKNOWLEDGMENT_PAYLOAD, m);
                microNap();
            })
            .build();
}
 
Example #25
Source File: SubscriberBeanWithMethodsReturningSubscribers.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_PROCESSING_ACK_MESSAGE)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
public Subscriber<String> subWithPreAckWithMessage() {
    return ReactiveStreams.<String> builder()
            .forEach(m -> {
                microNap();
                processed(PRE_PROCESSING_ACK_MESSAGE, m);
            })
            .build();
}
 
Example #26
Source File: SubscriberBeanWithMethodsReturningSubscribers.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_PROCESSING_ACK_PAYLOAD)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
public Subscriber<String> subWithPreAckWithPayload() {
    return ReactiveStreams.<String> builder()
            .forEach(m -> {
                microNap();
                processed(PRE_PROCESSING_ACK_PAYLOAD, m);
            })
            .build();
}
 
Example #27
Source File: BeanWithProcessorsManipulatingMessages.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(MANUAL_ACKNOWLEDGMENT_CS)
@Acknowledgment(Acknowledgment.Strategy.MANUAL)
@Outgoing("sink")
public CompletionStage<Message<String>> processorWithAck(Message<String> input) {
    processed(MANUAL_ACKNOWLEDGMENT_CS, input);
    return input.ack().thenApply(x -> Message.of(input.getPayload() + "1"));
}
 
Example #28
Source File: BeanWithProcessorsManipulatingMessages.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(MANUAL_ACKNOWLEDGMENT_UNI)
@Acknowledgment(Acknowledgment.Strategy.MANUAL)
@Outgoing("sink")
public Uni<Message<String>> processorWithAckUni(Message<String> input) {
    processed(MANUAL_ACKNOWLEDGMENT_UNI, input);
    return Uni.createFrom().completionStage(() -> input.ack()
            .thenApply(x -> Message.of(input.getPayload() + "1")));
}
 
Example #29
Source File: BeanWithProcessorsManipulatingMessages.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(NO_ACKNOWLEDGMENT)
@Acknowledgment(Acknowledgment.Strategy.NONE)
@Outgoing("sink")
public Message<String> processorWithNoAck(Message<String> input) {
    processed(NO_ACKNOWLEDGMENT, input);
    return Message.of(input.getPayload() + "1");
}
 
Example #30
Source File: BeanWithProcessorsManipulatingPayloads.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Incoming(PRE_ACKNOWLEDGMENT_CS)
@Acknowledgment(Acknowledgment.Strategy.PRE_PROCESSING)
@Outgoing("sink-" + PRE_ACKNOWLEDGMENT_CS)
public CompletionStage<String> processorWithPreAckCS(String input) {
    processed(PRE_ACKNOWLEDGMENT_CS, input);
    return CompletableFuture.completedFuture(input + "1");
}