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();
}
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());
}
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();
}
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);
}
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;
}
Aggregations