package com.bizzan.bitrade.consumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.bizzan.bitrade.entity.Announcement;
import com.bizzan.bitrade.handler.AnnouncementHandler;

@Component
public class AnnouncementConsumer {

    @Autowired
    private AnnouncementHandler announcementHandler;
    
    @KafkaListener(topics = {"announcement-send"})
    public void sendAnnouncement(String content) {
    	Announcement announcement = JSON.parseObject(content, Announcement.class);
    	announcementHandler.handleAnnouncement(announcement);
    }
}
