package com.tzy.listener.mq;

import com.rabbitmq.client.Channel;
import com.tzy.common.constant.MqConstans;
import com.tzy.sportcard.api.service.IMemberManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;


@Slf4j
@Component
public class InitUserMemberConsumer {

	@Resource
	private IMemberManageService memberManageService;

	@RabbitHandler
	@RabbitListener(queuesToDeclare = @Queue(MqConstans.QUEUE_INIT_USER_USER_MEMBER))
	public void initUserMemberConsumer(String param, Channel channel, Message message) throws IOException {
		memberManageService.initMemberV2();
		channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
	}


}
