Commit f302b4a3 authored by Noel Alonso's avatar Noel Alonso
Browse files

Crea base para manejar topic de snapshots

parent 0257c9db
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -17,8 +17,13 @@ public abstract class EventSourcingStreams extends BaseStreams {

	protected StreamsBuilder builder = new StreamsBuilder();

	protected String snapshotTopicSuffix = "-snapshot";

	protected String snapshotTopic;

	public EventSourcingStreams(StreamConfig config, AlertService alertService) {
		super(config, alertService);
		snapshotTopic = topic + snapshotTopicSuffix;
	}

	@Override
@@ -28,6 +33,9 @@ public abstract class EventSourcingStreams extends BaseStreams {

		KStream<String, Event> events = builder.stream(topic);

		// Reenvia eventos snapshot al topic correspondiente
		forwardSnapshotEvents(events);

		// Realiza el enriquecimiento del item antes de crear
		processEnrichCreateSteam(events);

@@ -53,6 +61,8 @@ public abstract class EventSourcingStreams extends BaseStreams {
				StreamUtils.baseStreamsConfig(bootstrapServers, stateStoreDir, serviceId, schemaRegistry));
	}

	protected abstract void forwardSnapshotEvents(KStream<String, Event> events);

	/*
	 * Función para crear streams extra que sean necesarios y específicos de cada
	 * tipo