package com.apobates.forum.core.impl;

import com.apobates.forum.core.impl.event.*;
import com.apobates.forum.core.impl.event.listener.*;
import com.github.davidmarquis.redisq.RedisMessageQueue;
import com.github.davidmarquis.redisq.consumer.MessageConsumer;
import com.github.davidmarquis.redisq.producer.DefaultMessageProducer;
import com.github.davidmarquis.redisq.producer.MessageProducer;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedisCoreEventConfig {
    // loop queue
    @Bean("boardCreateQueue")
    public RedisMessageQueue boardCreateQueue(){
        RedisMessageQueue mq =  new com.github.davidmarquis.redisq.RedisMessageQueue();
        mq.setQueueName("core:BoardCreateEvent");
        return mq;
    }
    @Bean("moderatorBornQueue")
    public RedisMessageQueue moderatorBornQueue(){
        RedisMessageQueue mq =  new com.github.davidmarquis.redisq.RedisMessageQueue();
        mq.setQueueName("core:ModeratorBornEvent");
        return mq;
    }
    @Bean("moderatorRecallQueue")
    public RedisMessageQueue moderatorRecallQueue(){
        RedisMessageQueue mq =  new com.github.davidmarquis.redisq.RedisMessageQueue();
        mq.setQueueName("core:ModeratorRecallEvent");
        return mq;
    }

    @Bean("topicPublishQueue")
    public RedisMessageQueue topicPublishQueue(){
        RedisMessageQueue mq =  new com.github.davidmarquis.redisq.RedisMessageQueue();
        mq.setQueueName("core:TopicPublishEvent");
        return mq;
    }
    @Bean("topicMoveQueue")
    public RedisMessageQueue topicMoveQueue(){
        RedisMessageQueue mq =  new com.github.davidmarquis.redisq.RedisMessageQueue();
        mq.setQueueName("core:TopicMoveEvent");
        return mq;
    }

    @Bean("postsPublishQueue")
    public RedisMessageQueue postsPublishQueue(){
        RedisMessageQueue mq =  new com.github.davidmarquis.redisq.RedisMessageQueue();
        mq.setQueueName("core:PostsPublishEvent");
        return mq;
    }
    @Bean("postsMoodQueue")
    public RedisMessageQueue postsMoodQueue(){
        RedisMessageQueue mq =  new com.github.davidmarquis.redisq.RedisMessageQueue();
        mq.setQueueName("core:PostsMoodEvent");
        return mq;
    }

    @Bean("plugTopicPublishQueue")
    public RedisMessageQueue plugTopicPublishQueue(){
        RedisMessageQueue mq =  new com.github.davidmarquis.redisq.RedisMessageQueue();
        mq.setQueueName("core:PlugTopicPublishEvent");
        return mq;
    }
    // loop Producer
    @Bean("boardCreateProducer")
    public MessageProducer<BoardCreateEvent> boardCreateProducer(@Qualifier("boardCreateQueue") RedisMessageQueue boardCreateQueue){
        DefaultMessageProducer<BoardCreateEvent> dmq = new com.github.davidmarquis.redisq.producer.DefaultMessageProducer<>();
        dmq.setQueue(boardCreateQueue);
        return dmq;
    }
    @Bean("moderatorBornProducer")
    public MessageProducer<ModeratorBornEvent> moderatorBornProducer(@Qualifier("moderatorBornQueue") RedisMessageQueue moderatorBornQueue){
        DefaultMessageProducer<ModeratorBornEvent> dmq = new com.github.davidmarquis.redisq.producer.DefaultMessageProducer<>();
        dmq.setQueue(moderatorBornQueue);
        return dmq;
    }
    @Bean("moderatorRecallProducer")
    public MessageProducer<ModeratorRecallEvent> moderatorRecallProducer(@Qualifier("moderatorRecallQueue") RedisMessageQueue moderatorRecallQueue){
        DefaultMessageProducer<ModeratorRecallEvent> dmq = new com.github.davidmarquis.redisq.producer.DefaultMessageProducer<>();
        dmq.setQueue(moderatorRecallQueue);
        return dmq;
    }

    @Bean("topicPublishProducer")
    public MessageProducer<TopicPublishEvent> topicPublishProducer(@Qualifier("topicPublishQueue") RedisMessageQueue topicPublishQueue){
        DefaultMessageProducer<TopicPublishEvent> dmq = new com.github.davidmarquis.redisq.producer.DefaultMessageProducer<>();
        dmq.setQueue(topicPublishQueue);
        return dmq;
    }
    @Bean("topicMoveProducer")
    public MessageProducer<TopicMoveEvent> topicMoveProducer(@Qualifier("topicMoveQueue") RedisMessageQueue topicMoveQueue){
        DefaultMessageProducer<TopicMoveEvent> dmq = new com.github.davidmarquis.redisq.producer.DefaultMessageProducer<>();
        dmq.setQueue(topicMoveQueue);
        return dmq;
    }

    @Bean("postsPublishProducer")
    public MessageProducer<PostsPublishEvent> postsPublishProducer(@Qualifier("postsPublishQueue") RedisMessageQueue postsPublishQueue){
        DefaultMessageProducer<PostsPublishEvent> dmq = new com.github.davidmarquis.redisq.producer.DefaultMessageProducer<>();
        dmq.setQueue(postsPublishQueue);
        return dmq;
    }
    @Bean("postsMoodProducer")
    public MessageProducer<PostsMoodEvent> postsMoodProducer(@Qualifier("postsMoodQueue") RedisMessageQueue postsMoodQueue){
        DefaultMessageProducer<PostsMoodEvent> dmq = new com.github.davidmarquis.redisq.producer.DefaultMessageProducer<>();
        dmq.setQueue(postsMoodQueue);
        return dmq;
    }

    @Bean("plugTopicPublishProducer")
    public MessageProducer<PlugTopicPublishEvent> plugTopicPublishProducer(@Qualifier("plugTopicPublishQueue") RedisMessageQueue plugTopicPublishQueue){
        DefaultMessageProducer<PlugTopicPublishEvent> dmq = new com.github.davidmarquis.redisq.producer.DefaultMessageProducer<>();
        dmq.setQueue(plugTopicPublishQueue);
        return dmq;
    }
    //loop Consumer
    @Bean
    public MessageConsumer<BoardCreateEvent> boardStatsEntryConsumer(
            @Qualifier("boardCreateQueue") RedisMessageQueue boardCreateQueue,
            @Qualifier("boardStatsEntry") BoardStatsListener boardStatsEntry){
        MessageConsumer<BoardCreateEvent> messageConsumer = new com.github.davidmarquis.redisq.consumer.MessageConsumer<>();
        messageConsumer.setQueue(boardCreateQueue);
        messageConsumer.setConsumerId("BoardCreateEvent:statsEntry");
        messageConsumer.setMessageListener(boardStatsEntry);
        return messageConsumer;
    }
    @Bean
    public MessageConsumer<BoardCreateEvent> baordConfigEntryConsumer(
            @Qualifier("boardCreateQueue") RedisMessageQueue boardCreateQueue,
            @Qualifier("boardConfigEntry") BoardConfigListener boardConfigEntry){
        MessageConsumer<BoardCreateEvent> messageConsumer = new com.github.davidmarquis.redisq.consumer.MessageConsumer<>();
        messageConsumer.setQueue(boardCreateQueue);
        messageConsumer.setConsumerId("BoardCreateEvent:configEntry");
        messageConsumer.setMessageListener(boardConfigEntry);
        return messageConsumer;
    }

    @Bean
    public MessageConsumer<TopicPublishEvent> topicConfigEntryConsumer(
            @Qualifier("topicPublishQueue") RedisMessageQueue topicPublishQueue,
            @Qualifier("topicConfigEntry") TopicConfigListener topicConfigEntry){
        MessageConsumer<TopicPublishEvent> messageConsumer = new com.github.davidmarquis.redisq.consumer.MessageConsumer<>();
        messageConsumer.setQueue(topicPublishQueue);
        messageConsumer.setConsumerId("TopicPublishEvent:configEntry");
        messageConsumer.setMessageListener(topicConfigEntry);
        return messageConsumer;
    }
    @Bean
    public MessageConsumer<TopicPublishEvent> topicStatsEntryConsumer(
            @Qualifier("topicPublishQueue") RedisMessageQueue topicPublishQueue,
            @Qualifier("topicStatsEntry") TopicStatsListener topicStatsEntry){
        MessageConsumer<TopicPublishEvent> messageConsumer = new com.github.davidmarquis.redisq.consumer.MessageConsumer<>();
        messageConsumer.setQueue(topicPublishQueue);
        messageConsumer.setConsumerId("TopicPublishEvent:statsEntry");
        messageConsumer.setMessageListener(topicStatsEntry);
        return messageConsumer;
    }
    @Bean
    public MessageConsumer<TopicPublishEvent> topicTagEntryConsumer(
            @Qualifier("topicPublishQueue") RedisMessageQueue topicPublishQueue,
            @Qualifier("topicTagEntry") TopicTagListener topicTagEntry){
        MessageConsumer<TopicPublishEvent> messageConsumer = new com.github.davidmarquis.redisq.consumer.MessageConsumer<>();
        messageConsumer.setQueue(topicPublishQueue);
        messageConsumer.setConsumerId("TopicPublishEvent:tagEntry");
        messageConsumer.setMessageListener(topicTagEntry);
        return messageConsumer;
    }

    @Bean
    public MessageConsumer<PostsPublishEvent> postsStatsEntryConsumer(
            @Qualifier("postsPublishQueue") RedisMessageQueue postsPublishQueue,
            @Qualifier("postsStatsEntry") PostsStatsListener postsStatsEntry){
        MessageConsumer<PostsPublishEvent> messageConsumer = new com.github.davidmarquis.redisq.consumer.MessageConsumer<>();
        messageConsumer.setQueue(postsPublishQueue);
        messageConsumer.setConsumerId("PostsPublishEvent:statsEntry");
        messageConsumer.setMessageListener(postsStatsEntry);
        return messageConsumer;
    }

    @Bean
    public MessageConsumer<PlugTopicPublishEvent> plugTopicConfigEntryConsumer(
            @Qualifier("plugTopicPublishQueue") RedisMessageQueue plugTopicPublishQueue,
            @Qualifier("plugTopicConfigEntry") PlugTopicConfigListener plugTopicConfigEntry){
        MessageConsumer<PlugTopicPublishEvent> messageConsumer = new com.github.davidmarquis.redisq.consumer.MessageConsumer<>();
        messageConsumer.setQueue(plugTopicPublishQueue);
        messageConsumer.setConsumerId("PlugTopicPublishEvent:configEntry");
        messageConsumer.setMessageListener(plugTopicConfigEntry);
        return messageConsumer;
    }
    @Bean
    public MessageConsumer<PlugTopicPublishEvent> plugTopicStatsEntryConsumer(
            @Qualifier("plugTopicPublishQueue") RedisMessageQueue plugTopicPublishQueue,
            @Qualifier("plugTopicStatsEntry") PlugTopicStatsListener plugTopicStatsEntry){
        MessageConsumer<PlugTopicPublishEvent> messageConsumer = new com.github.davidmarquis.redisq.consumer.MessageConsumer<>();
        messageConsumer.setQueue(plugTopicPublishQueue);
        messageConsumer.setConsumerId("PlugTopicPublishEvent:statsEntry");
        messageConsumer.setMessageListener(plugTopicStatsEntry);
        return messageConsumer;
    }
    @Bean
    public MessageConsumer<PlugTopicPublishEvent> plugTopicActionEntryConsumer(
            @Qualifier("plugTopicPublishQueue") RedisMessageQueue plugTopicPublishQueue,
            @Qualifier("plugTopicActionEntry") PlugTopicRelateActionListener plugTopicActionEntry){
        MessageConsumer<PlugTopicPublishEvent> messageConsumer = new com.github.davidmarquis.redisq.consumer.MessageConsumer<>();
        messageConsumer.setQueue(plugTopicPublishQueue);
        messageConsumer.setConsumerId("PlugTopicPublishEvent:actionEntry");
        messageConsumer.setMessageListener(plugTopicActionEntry);
        return messageConsumer;
    }
}
