io.smallrye.reactive.messaging.annotations.Blocking Java Examples
The following examples show how to use
io.smallrye.reactive.messaging.annotations.Blocking.
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: QuarkusWorkerPoolRegistry.java From quarkus with Apache License 2.0 | 6 votes |
public void defineWorker(String className, String method, String poolName) { Objects.requireNonNull(className, "className was empty"); Objects.requireNonNull(method, "Method was empty"); if (!poolName.equals(Blocking.DEFAULT_WORKER_POOL)) { // Validate @Blocking value is not empty, if set if (Validation.isBlank(poolName)) { throw getBlockingError(className, method, "value is blank or null"); } // Validate @Blocking worker pool has configuration to define concurrency String workerConfigKey = WORKER_CONFIG_PREFIX + "." + poolName + "." + WORKER_CONCURRENCY; Optional<Integer> concurrency = ConfigProvider.getConfig().getOptionalValue(workerConfigKey, Integer.class); if (!concurrency.isPresent()) { throw getBlockingError(className, method, workerConfigKey + " was not defined"); } workerConcurrency.put(poolName, concurrency.get()); } }
Example #2
Source File: SynchronousPayloadProcessorAckTest.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
@Incoming("data") @Outgoing("out") @Blocking @Acknowledgment(Acknowledgment.Strategy.POST_PROCESSING) public String process(Message<String> m) { String s = m.getPayload(); return CompletableFuture.supplyAsync(() -> { if (s.equalsIgnoreCase("b")) { // nacked. throw new IllegalArgumentException("b"); } if (s.equalsIgnoreCase("e")) { // acked but not forwarded return null; } return s.toUpperCase(); }).join(); }
Example #3
Source File: SynchronousPayloadProcessorAckTest.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
@Incoming("data") @Outgoing("out") @Blocking public String process(String s) { return CompletableFuture.supplyAsync(() -> { if (s.equalsIgnoreCase("b")) { // nacked. throw new IllegalArgumentException("b"); } if (s.equalsIgnoreCase("e")) { // acked but not forwarded return null; } return s.toUpperCase(); }).join(); }
Example #4
Source File: WorkerPoolRegistry.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
public void defineWorker(String className, String method, String poolName) { Objects.requireNonNull(className, msg.classNameWasEmpty()); Objects.requireNonNull(method, msg.methodWasEmpty()); if (!poolName.equals(Blocking.DEFAULT_WORKER_POOL)) { // Validate @Blocking value is not empty, if set if (Validation.isBlank(poolName)) { throw ex.illegalArgumentForAnnotationNullOrBlank("@Blocking", className + "#" + method); } // Validate @Blocking worker pool has configuration to define concurrency String workerConfigKey = WORKER_CONFIG_PREFIX + "." + poolName + "." + WORKER_CONCURRENCY; Optional<Integer> concurrency = configInstance.get().getOptionalValue(workerConfigKey, Integer.class); if (!concurrency.isPresent()) { throw ex.illegalArgumentForWorkerConfigKey("@Blocking", className + "#" + method, workerConfigKey); } workerConcurrency.put(poolName, concurrency.get()); } }
Example #5
Source File: CollectedMediatorMetadata.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
private MediatorConfiguration createMediatorConfiguration(Method met, Bean<?> bean) { DefaultMediatorConfiguration configuration = new DefaultMediatorConfiguration(met, bean); Incomings incomings = met.getAnnotation(Incomings.class); Incoming incoming = met.getAnnotation(Incoming.class); Outgoing outgoing = met.getAnnotation(Outgoing.class); Blocking blocking = met.getAnnotation(Blocking.class); if (incomings != null) { configuration.compute(incomings, outgoing, blocking); } else if (incoming != null) { configuration.compute(Collections.singletonList(incoming), outgoing, blocking); } else { configuration.compute(Collections.emptyList(), outgoing, blocking); } return configuration; }
Example #6
Source File: MessageProcessorAckTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Incoming("data") @Outgoing("out") @Blocking public Message<String> process(Message<String> m) { String s = m.getPayload(); return CompletableFuture.supplyAsync(() -> { if (s.equalsIgnoreCase("b")) { // we cannot fail, we must nack explicitly. m.nack(new IllegalArgumentException("b")).toCompletableFuture().join(); return null; } return m.withPayload(s.toUpperCase()); }).join(); }
Example #7
Source File: InvalidBlockingProcessorShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") @Outgoing("sink") public Publisher<String> process(Integer payload) { return ReactiveStreams.of(payload) .map(i -> i + 1) .flatMapRsPublisher(i -> Flowable.just(i, i)) .map(i -> Integer.toString(i)) .buildRs(); }
Example #8
Source File: InvalidBlockingProcessorShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") @Outgoing("sink") public PublisherBuilder<String> process(Integer payload) { return ReactiveStreams.of(payload) .map(i -> i + 1) .flatMapRsPublisher(i -> Flowable.just(i, i)) .map(i -> Integer.toString(i)); }
Example #9
Source File: InvalidBlockingProcessorShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") @Outgoing("sink") public PublisherBuilder<Message<String>> process(Message<Integer> message) { return ReactiveStreams.of(message) .map(Message::getPayload) .map(i -> i + 1) .flatMapRsPublisher(i -> Flowable.just(i, i)) .map(i -> Integer.toString(i)) .map(Message::of); }
Example #10
Source File: InvalidBlockingProcessorShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") @Outgoing("sink") public Multi<String> process(Integer payload) { return Multi.createFrom().publisher( ReactiveStreams.of(payload) .map(i -> i + 1) .flatMapRsPublisher(i -> Flowable.just(i, i)) .map(i -> Integer.toString(i)).buildRs()); }
Example #11
Source File: SubscriberAckTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Incoming("data") @Blocking public void consume(String s) { CompletableFuture.runAsync(() -> { if (s.equalsIgnoreCase("2") || s.equalsIgnoreCase("8")) { throw new IllegalArgumentException("boom"); } list.add(s); }).join(); }
Example #12
Source File: InvalidBlockingProcessorShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") @Outgoing("sink") public Multi<Message<String>> process(Message<Integer> message) { return Multi.createFrom().publisher( ReactiveStreams.of(message) .map(Message::getPayload) .map(i -> i + 1) .flatMapRsPublisher(i -> Flowable.just(i, i)) .map(i -> Integer.toString(i)) .map(Message::of).buildRs()); }
Example #13
Source File: BeanReturningPayloads.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Outgoing("infinite-producer") public int create() { try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } threads.add(Thread.currentThread().getName()); return count.incrementAndGet(); }
Example #14
Source File: BeanConsumingMessagesAndProducingMessages.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") @Outgoing("sink") public Message<String> process(Message<Integer> value) { try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } threads.add(Thread.currentThread().getName()); return Message.of(Integer.toString(value.getPayload() + 1)); }
Example #15
Source File: BeanReturningMessages.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Outgoing("infinite-producer") public Message<Integer> create() { try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } threads.add(Thread.currentThread().getName()); return Message.of(count.incrementAndGet()); }
Example #16
Source File: IncomingDefaultUnorderedBlockingBean.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Incoming("in") @Blocking(ordered = false) public void consume(String s) { if (s.equals("a") || s.equals("c") || s.equals("e")) { try { Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeException(e); } } threads.add(Thread.currentThread().getName()); list.add(s); }
Example #17
Source File: BeanConsumingItemsAndProducingMessages.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") @Outgoing("sink") public Message<String> process(int value) { try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } threads.add(Thread.currentThread().getName()); return Message.of(Integer.toString(value + 1)); }
Example #18
Source File: InvalidBlockingSubscriberShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") public Uni<String> consume(String payload) { return Uni.createFrom().item(() -> { list.add(payload); return "hello"; }); }
Example #19
Source File: InvalidBlockingSubscriberShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") public Uni<String> consume(Message<String> msg) { return Uni.createFrom().item(() -> { list.add(msg.getPayload()); return "hello"; }); }
Example #20
Source File: InvalidBlockingSubscriberShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") public Uni<Void> consume(String payload) { return Uni.createFrom().item(() -> { list.add(payload); return null; }); }
Example #21
Source File: IncomingCustomUnorderedBlockingBean.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Incoming("in") @Blocking(value = "my-pool", ordered = false) public void consume(String s) { if (s.equals("b") || s.equals("d") || s.equals("f")) { try { Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeException(e); } } threads.add(Thread.currentThread().getName()); list.add(s); }
Example #22
Source File: BeanConsumingItemsAndProducingItems.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") @Outgoing("sink") public String process(int value) { try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } threads.add(Thread.currentThread().getName()); return Integer.toString(value + 1); }
Example #23
Source File: BeanConsumingMessagesAndProducingItems.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") @Outgoing("sink") public String process(Message<Integer> value) { try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } threads.add(Thread.currentThread().getName()); return Integer.toString(value.getPayload() + 1); }
Example #24
Source File: InvalidBlockingSubscriberShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") public Uni<Void> consume(Message<String> message) { return Uni.createFrom().item(() -> { list.add(message.getPayload()); return null; }); }
Example #25
Source File: InvalidBlockingSubscriberShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") public CompletionStage<String> consume(String payload) { return CompletableFuture.supplyAsync(() -> { list.add(payload); return "hello"; }, executor); }
Example #26
Source File: InvalidBlockingSubscriberShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") public CompletionStage<String> consume(Message<String> msg) { return CompletableFuture.supplyAsync(() -> { list.add(msg.getPayload()); return "hello"; }, executor); }
Example #27
Source File: InvalidBlockingSubscriberShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") public CompletionStage<Void> consume(String payload) { return CompletableFuture.supplyAsync(() -> { list.add(payload); return null; }, executor); }
Example #28
Source File: InvalidBlockingSubscriberShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Incoming("count") public CompletionStage<Void> consume(Message<String> message) { return CompletableFuture.supplyAsync(() -> { list.add(message.getPayload()); return null; }, executor); }
Example #29
Source File: InvalidBlockingPublisherShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Outgoing("sink") public PublisherBuilder<Message<String>> publisher() { return ReactiveStreams.fromPublisher(Flowable.range(1, 10)) .flatMapRsPublisher(i -> Flowable.just(i, i)) .map(i -> Integer.toString(i)) .map(Message::of); }
Example #30
Source File: InvalidBlockingPublisherShapeTest.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
@Blocking @Outgoing("sink") public PublisherBuilder<String> publisher() { return ReactiveStreams.fromPublisher(Flowable.range(1, 10)) .flatMapRsPublisher(i -> Flowable.just(i, i)) .map(i -> Integer.toString(i)); }