-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that any event is sent only once
- Loading branch information
1 parent
b20387a
commit 1b7869e
Showing
9 changed files
with
270 additions
and
138 deletions.
There are no files selected for viewing
20 changes: 0 additions & 20 deletions
20
app/src/main/java/io/apicurio/registry/events/RegistryEventsProcessor.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlEventsProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.apicurio.registry.storage.impl.kafkasql; | ||
|
||
import io.apicurio.registry.storage.dto.OutboxEvent; | ||
import io.apicurio.registry.utils.ConcurrentUtil; | ||
import io.apicurio.registry.utils.kafka.ProducerActions; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Named; | ||
import org.apache.kafka.clients.producer.ProducerRecord; | ||
|
||
import java.util.Collections; | ||
|
||
@ApplicationScoped | ||
public class KafkaSqlEventsProcessor { | ||
|
||
@Inject | ||
KafkaSqlConfiguration configuration; | ||
|
||
@Inject | ||
@Named("KafkaSqlEventsProducer") | ||
ProducerActions<String, String> eventsProducer; | ||
|
||
public void processEvent(@Observes KafkaSqlOutboxEvent event) { | ||
OutboxEvent outboxEvent = event.getOutboxEvent(); | ||
ProducerRecord<String, String> record = new ProducerRecord<>(configuration.eventsTopic(), 0, | ||
outboxEvent.getAggregateId(), outboxEvent.getPayload().toString(), Collections.emptyList()); | ||
ConcurrentUtil.get(eventsProducer.apply(record)); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlOutboxEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.apicurio.registry.storage.impl.kafkasql; | ||
|
||
import io.apicurio.registry.storage.dto.OutboxEvent; | ||
|
||
public class KafkaSqlOutboxEvent { | ||
|
||
private final OutboxEvent outboxEvent; | ||
|
||
private KafkaSqlOutboxEvent(OutboxEvent outboxEvent) { | ||
this.outboxEvent = outboxEvent; | ||
} | ||
|
||
public static KafkaSqlOutboxEvent of(OutboxEvent outboxEvent) { | ||
return new KafkaSqlOutboxEvent(outboxEvent); | ||
} | ||
|
||
public OutboxEvent getOutboxEvent() { | ||
return outboxEvent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.