Search in sources :

Example 1 with Outgoing

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

Example 2 with Outgoing

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);
}
Also used : Timestamp(java.sql.Timestamp) Incoming(org.eclipse.microprofile.reactive.messaging.Incoming) Outgoing(org.eclipse.microprofile.reactive.messaging.Outgoing)

Example 3 with Outgoing

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);
    });
}
Also used : MsgBean(webapp.tier.bean.MsgBean) Broadcast(io.smallrye.reactive.messaging.annotations.Broadcast) Outgoing(org.eclipse.microprofile.reactive.messaging.Outgoing)

Example 4 with Outgoing

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);
    });
}
Also used : SensorMeasurementTaken(com.redhat.training.gardens.event.SensorMeasurementTaken) Broadcast(io.smallrye.reactive.messaging.annotations.Broadcast) Outgoing(org.eclipse.microprofile.reactive.messaging.Outgoing)

Example 5 with Outgoing

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);
    });
}
Also used : VehicleMoved(com.redhat.vehicles.movement.events.VehicleMoved) Outgoing(org.eclipse.microprofile.reactive.messaging.Outgoing)

Aggregations

Outgoing (org.eclipse.microprofile.reactive.messaging.Outgoing)8 Incoming (org.eclipse.microprofile.reactive.messaging.Incoming)5 Blocking (io.smallrye.reactive.messaging.annotations.Blocking)3 Broadcast (io.smallrye.reactive.messaging.annotations.Broadcast)2 JsonObject (io.vertx.core.json.JsonObject)2 SensorMeasurementTaken (com.redhat.training.gardens.event.SensorMeasurementTaken)1 VehicleMoved (com.redhat.vehicles.movement.events.VehicleMoved)1 Datasource (io.openk9.datasource.model.Datasource)1 EnrichItem (io.openk9.datasource.model.EnrichItem)1 EnrichPipeline (io.openk9.datasource.model.EnrichPipeline)1 Tenant (io.openk9.datasource.model.Tenant)1 DatasourceContext (io.openk9.datasource.processor.payload.DatasourceContext)1 IngestionDatasourcePayload (io.openk9.datasource.processor.payload.IngestionDatasourcePayload)1 IngestionPayload (io.openk9.datasource.processor.payload.IngestionPayload)1 Payload (io.openk9.entity.manager.dto.Payload)1 Panache (io.quarkus.hibernate.reactive.panache.Panache)1 Uni (io.smallrye.mutiny.Uni)1 Incomings (io.smallrye.reactive.messaging.annotations.Incomings)1 DefaultMediatorConfiguration (io.smallrye.reactive.messaging.providers.DefaultMediatorConfiguration)1 OutgoingRabbitMQMetadata (io.smallrye.reactive.messaging.rabbitmq.OutgoingRabbitMQMetadata)1