package com.sqx.nsqChannel;

import com.sqx.nsqChannel.channels.Print2MessageHandlerAdapter;
import com.sqx.nsqChannel.channels.PrintMessageHandlerAdapter;
import com.sqx.nsqChannel.config.NSQConsumers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

//@Service
@Slf4j
public class NsqConfig {
    /**
     * 端口号
     */
    @Value("${nsq.port.consumer}")
    private int port;

    @Value("${nsq.address}")
    private String address;

//    @PostConstruct
    public void startNSQChannel() {
        new NSQConsumers(address, port, "test", "ch1", new Print2MessageHandlerAdapter());
        new NSQConsumers(address, port, "test", "ch2", new PrintMessageHandlerAdapter());
    }
}
