io.naraplatform.daysman.daysboy.mode.local.EventStreamLocalClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of daysman-daysboy Show documentation
Show all versions of daysman-daysboy Show documentation
A application used as an example on how to set up pushing its components to the Central Repository.
The newest version!
package io.naraplatform.daysman.daysboy.mode.local;
import io.naradrama.prologue.domain.Offset;
import io.naradrama.prologue.domain.cqrs.DomainMessage;
import io.naradrama.prologue.domain.cqrs.broker.StreamEventMessage;
import io.naradrama.prologue.domain.cqrs.command.CqrsCommand;
import io.naradrama.prologue.domain.cqrs.event.CqrsEvent;
import io.naradrama.prologue.domain.cqrs.query.CqrsQuery;
import io.naraplatform.daysman.daysboy.event.EventSubscriber;
import io.naraplatform.daysman.mediator.spec.EventHandler;
import io.naraplatform.daysman.mediator.spec.EventStreamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
@Slf4j
public class EventStreamLocalClient implements EventStreamService {
//
private BlockingQueue queue;
private DaysboyLocalServer daysboyLocalServer;
private LocalMemoryStreamEventStore eventStore;
private ApplicationEventPublisher publisher;
public EventStreamLocalClient(LocalMemoryStreamEventStore eventStore, ApplicationEventPublisher publisher, EventSubscriber eventSubscriber) {
//
this.eventStore = eventStore;
this.publisher = publisher;
this.queue = new ArrayBlockingQueue<>(100);
this.daysboyLocalServer = new DaysboyLocalServer(this.queue, eventSubscriber);
new Thread(this.daysboyLocalServer).start();
}
@Override
public void consume(EventHandler eventHandler) {
//
this.daysboyLocalServer.setEventHandler(eventHandler);
}
@Override
@Deprecated
public void produce(StreamEventMessage event) {
//
try {
publisher.publishEvent(event);
queue.put(event);
log.info("produce... {}", event);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void produce(CqrsCommand command) {
// TODO
}
@Override
public void produce(CqrsQuery query) {
// TODO
}
@Override
public void produce(CqrsEvent event) {
// TODO
}
@Override
public StreamEventMessage load(String id) {
//
return eventStore.load(id);
}
@Override
public List loadAll(Offset offset) {
//
return eventStore.loadAll(offset);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy