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

org.bdware.doip.event.NaiveBroker Maven / Gradle / Ivy

The newest version!
package org.bdware.doip.event;

import org.bdware.doip.RocksDBUtil;
import org.bdware.doip.audit.AuditDoaClient;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.endpoint.event.EventMessageParser;
import org.bdware.doip.endpoint.event.TopicHandler;

public class NaiveBroker implements TopicHandler {
    EventMessageParser messageParser;


    public NaiveBroker(String path, AuditDoaClient client, String myTopic) {
        RocksDBUtil storageManager = RocksDBUtil.loadDB(path, false);
        NaivePublisher publisher = new NaivePublisher(storageManager, client);
        NaiveSubscriber subscriber = new NaiveSubscriber() {
            @Override
            public void onReceiveData(String topicId, String publisherId, DoipMessage request) {
                //replace Topic
                publisher.publish(myTopic, request);
            }
        };
        messageParser = new EventMessageParser(publisher, subscriber);
    }

    @Override
    public DoipMessage handlePublish(DoipMessage request) {
        return messageParser.handlePublish(request);
    }

    @Override
    public DoipMessage handleSubscribe(DoipMessage request) {
        return messageParser.handleSubscribe(request);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy