All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.otto.synapse.eventsource.DefaultEventSourceBuilder Maven / Gradle / Ivy

Go to download

A library used at otto.de to implement Spring Boot based event-sourcing microservices.

There is a newer version: 0.33.1
Show newest version
package de.otto.synapse.eventsource;

import de.otto.synapse.channel.selector.MessageLog;
import de.otto.synapse.channel.selector.Selector;
import de.otto.synapse.endpoint.receiver.MessageLogReceiverEndpoint;
import de.otto.synapse.messagestore.MessageStore;
import de.otto.synapse.messagestore.MessageStoreFactory;

public class DefaultEventSourceBuilder implements EventSourceBuilder {

    private final MessageStoreFactory snapshotMessageStoreFactory;
    private final Class selector;

    public DefaultEventSourceBuilder(final MessageStoreFactory snapshotMessageStoreFactory,
                                     final Class selector) {
        this.snapshotMessageStoreFactory = snapshotMessageStoreFactory;
        this.selector = selector;
    }

    @Override
    public EventSource buildEventSource(MessageLogReceiverEndpoint messageLogReceiverEndpoint) {
        final String channelName = messageLogReceiverEndpoint.getChannelName();
        final MessageStore messageStore = snapshotMessageStoreFactory.createMessageStoreFor(channelName);
        return new DefaultEventSource(messageStore, messageLogReceiverEndpoint);
    }

    @Override
    public Class selector() {
        return selector;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy