Search in sources :

Example 1 with Incoming

use of org.eclipse.microprofile.reactive.messaging.Incoming in project smallrye-reactive-messaging by smallrye.

the class KafkaRecordBatchExample method consumeMessage.

// <code>
@Incoming("prices")
public CompletionStage<Void> consumeMessage(KafkaRecordBatch<String, Double> records) {
    for (KafkaRecord<String, Double> record : records) {
        record.getMetadata(IncomingKafkaRecordMetadata.class).ifPresent(metadata -> {
            int partition = metadata.getPartition();
            long offset = metadata.getOffset();
            Instant timestamp = metadata.getTimestamp();
        // ... process messages
        });
    }
    // ack will commit the latest offsets (per partition) of the batch.
    return records.ack();
}
Also used : IncomingKafkaRecordMetadata(io.smallrye.reactive.messaging.kafka.api.IncomingKafkaRecordMetadata) Instant(java.time.Instant) Incoming(org.eclipse.microprofile.reactive.messaging.Incoming)

Example 2 with Incoming

use of org.eclipse.microprofile.reactive.messaging.Incoming in project smallrye-reactive-messaging by smallrye.

the class FileConsumer method consume.

@Incoming("files")
public void consume(GenericFile<File> file) {
    File actualFile = file.getFile();
    list.add(actualFile.getName());
}
Also used : GenericFile(org.apache.camel.component.file.GenericFile) File(java.io.File) Incoming(org.eclipse.microprofile.reactive.messaging.Incoming)

Example 3 with Incoming

use of org.eclipse.microprofile.reactive.messaging.Incoming in project smallrye-reactive-messaging by smallrye.

the class FileMessageConsumer method consume.

@Incoming("files")
public CompletionStage<Void> consume(Message<GenericFile<File>> msg) {
    File actualFile = msg.getPayload().getFile();
    list.add(actualFile.getName());
    return msg.ack();
}
Also used : GenericFile(org.apache.camel.component.file.GenericFile) File(java.io.File) Incoming(org.eclipse.microprofile.reactive.messaging.Incoming)

Example 4 with Incoming

use of org.eclipse.microprofile.reactive.messaging.Incoming in project smallrye-reactive-messaging by smallrye.

the class BeanWithCamelSink method sink.

@Incoming("camel")
public CompletionStage<Void> sink(String value) {
    values.add(value);
    ProducerTemplate template = camel.createProducerTemplate();
    return template.asyncSendBody("file:./target?fileName=values.txt&fileExist=append", value).thenApply(x -> null);
}
Also used : ProducerTemplate(org.apache.camel.ProducerTemplate) Incoming(org.eclipse.microprofile.reactive.messaging.Incoming)

Example 5 with Incoming

use of org.eclipse.microprofile.reactive.messaging.Incoming in project smallrye-reactive-messaging by smallrye.

the class CollectedMediatorMetadata method createMediatorConfiguration.

private MediatorConfiguration createMediatorConfiguration(Method met, Bean<?> bean) {
    DefaultMediatorConfiguration configuration = new DefaultMediatorConfiguration(met, bean);
    if (strict) {
        configuration.strict();
    }
    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;
}
Also used : Incomings(io.smallrye.reactive.messaging.annotations.Incomings) Incoming(org.eclipse.microprofile.reactive.messaging.Incoming) Blocking(io.smallrye.reactive.messaging.annotations.Blocking) Outgoing(org.eclipse.microprofile.reactive.messaging.Outgoing) DefaultMediatorConfiguration(io.smallrye.reactive.messaging.providers.DefaultMediatorConfiguration)

Aggregations

Incoming (org.eclipse.microprofile.reactive.messaging.Incoming)19 Outgoing (org.eclipse.microprofile.reactive.messaging.Outgoing)7 Blocking (io.smallrye.reactive.messaging.annotations.Blocking)4 ApplicationScoped (javax.enterprise.context.ApplicationScoped)4 JsonObject (io.vertx.core.json.JsonObject)3 Instant (java.time.Instant)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 GlobalOpenTelemetry (io.opentelemetry.api.GlobalOpenTelemetry)2 Span (io.opentelemetry.api.trace.Span)2 SpanContext (io.opentelemetry.api.trace.SpanContext)2 SpanKind (io.opentelemetry.api.trace.SpanKind)2 W3CTraceContextPropagator (io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator)2 Context (io.opentelemetry.context.Context)2 ContextPropagators (io.opentelemetry.context.propagation.ContextPropagators)2 OpenTelemetrySdk (io.opentelemetry.sdk.OpenTelemetrySdk)2 InMemorySpanExporter (io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter)2 SdkTracerProvider (io.opentelemetry.sdk.trace.SdkTracerProvider)2 SpanProcessor (io.opentelemetry.sdk.trace.SpanProcessor)2 SpanData (io.opentelemetry.sdk.trace.data.SpanData)2