use of org.eclipse.microprofile.reactive.messaging.Outgoing 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;
}
use of org.eclipse.microprofile.reactive.messaging.Outgoing in project quickstart by wildfly.
the class MessagingBean method sendToKafka.
@Incoming("sender")
@Outgoing("to-kafka")
public Message<TimedEntry> sendToKafka(String msg) {
TimedEntry te = new TimedEntry(new Timestamp(System.currentTimeMillis()), msg);
Message<TimedEntry> m = Message.of(te);
// Just use the hash as the Kafka key for this example
int key = te.getMessage().hashCode();
// Create Metadata containing the Kafka key
OutgoingKafkaRecordMetadata<Integer> md = OutgoingKafkaRecordMetadata.<Integer>builder().withKey(key).build();
// The returned message will have the metadata added
return KafkaMetadataUtil.writeOutgoingKafkaMetadata(m, md);
}
use of org.eclipse.microprofile.reactive.messaging.Outgoing in project k8s-3tier-webapp by yurake.
the class MessageGenerator method generate.
@Outgoing("message")
@Broadcast
public Flowable<String> generate() {
return Flowable.interval(period, TimeUnit.SECONDS).onBackpressureDrop().map(tick -> {
MsgBean msgbean = new MsgBean(CreateId.createid(), message, "Generate");
logger.info(msgbean.getFullmsg());
return MsgUtils.createBody(msgbean, splitkey);
});
}
use of org.eclipse.microprofile.reactive.messaging.Outgoing in project AD482-apps by RedHatTraining.
the class SensorMeasurementService method measure.
// TODO: Implement the Kafka producer
@Outgoing("garden-sensor-measurements-out")
@Broadcast
public Multi<Record<Integer, SensorMeasurementTaken>> measure() {
return Multi.createFrom().ticks().every(Duration.ofMillis(5000)).onOverflow().drop().map(tick -> {
SensorMeasurementTaken event = generateEvent(sensorService.getSensor());
LOGGER.info("Sensor measurement taken: " + event);
return Record.of(event.getSensorId(), event);
});
}
use of org.eclipse.microprofile.reactive.messaging.Outgoing in project AD482-apps by RedHatTraining.
the class VehicleMovementsGenerator method generate.
@Outgoing("vehicle-movements")
public Multi<Record<Integer, VehicleMoved>> generate() {
return Multi.createFrom().ticks().every(Duration.ofMillis(3000)).onOverflow().drop().map(tick -> {
VehiclePosition position = positions.get(random.nextInt(positions.size()));
position.move();
VehicleMoved event = new VehicleMoved(position.vehicleId, position.latitude, position.longitude, position.elevation);
// Event produced with the vehicle id as key
return Record.of(event.vehicleId, event);
});
}
Aggregations