Search in sources :

Example 1 with DefaultGatherDataHandler

use of com.creditease.uav.collect.server.messaging.DefaultGatherDataHandler in project uavstack by uavorg.

the class GatherDataManager method start.

@Override
public void start() {
    StandardMessagingBuilder builder = new StandardMessagingBuilder("GatherDataManagerMessageBuilder", feature);
    try {
        builder.init();
    } catch (IOException e) {
        log.err(this, "Read msgtype2topic.properties FAILs, GatherDataManager can not START", e);
        return;
    }
    String[] topics = getConfigManager().getFeatureConfiguration(feature, "topics").split(",");
    List<MessageHandler> handlers = new ArrayList<>();
    for (String topic : topics) {
        handlers.add(new DefaultGatherDataHandler(topic));
    }
    MessagingContext.putConsumerHandlers(handlers);
    // init consumers
    consumers = new ArrayList<>();
    for (String topic : topics) {
        MessageConsumer consumer = builder.buildConsumer(topic);
        if (consumer == null) {
            continue;
        }
        consumers.add(consumer);
    }
    // start all consumers
    for (MessageConsumer consumer : consumers) {
        consumer.start();
        log.info(this, "GatherData Consumer [" + consumer.getName() + "] start");
    }
    log.info(this, "GatherDataManager start");
}
Also used : StandardMessagingBuilder(org.uavstack.resources.common.messaging.StandardMessagingBuilder) MessageConsumer(com.creditease.uav.messaging.api.MessageConsumer) MessageHandler(com.creditease.uav.messaging.api.MessageHandler) ArrayList(java.util.ArrayList) IOException(java.io.IOException) DefaultGatherDataHandler(com.creditease.uav.collect.server.messaging.DefaultGatherDataHandler)

Aggregations

DefaultGatherDataHandler (com.creditease.uav.collect.server.messaging.DefaultGatherDataHandler)1 MessageConsumer (com.creditease.uav.messaging.api.MessageConsumer)1 MessageHandler (com.creditease.uav.messaging.api.MessageHandler)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 StandardMessagingBuilder (org.uavstack.resources.common.messaging.StandardMessagingBuilder)1