package com.ssm.common;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import redis.clients.jedis.JedisCluster;

import com.dgtis.sso.redis.RedisPool;
import com.dgtis.sso.utils.Config;

public class InitListener implements ApplicationContextAware{

	private static ApplicationContext context = null;
	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		context= applicationContext;
		new Thread(new Runnable() {
			@Override
			public void run() {
				SmsMessageDelegateListener listener = context.getBean(SmsMessageDelegateListener.class);
				//监听的队列
				JedisCluster jedisCluster = RedisPool.getJedisCluster();
				jedisCluster.subscribe(listener,Config.SMS_QUEUE_SIGN_IN);
			}
		}).start();
	}
}
