TrafficDataConsumer.java 1009 Bytes
package com.viontech.consumer;

import com.viontech.controller.websocket.WebsocketController;
import com.viontech.service.adapter.traffic.ITrafficEventService;
import com.viontech.util.JavaBean2Json;
import com.viontech.vo.EventDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

/**
 * @program: event_data_handle
 * @description: 交通类型事件消费者
 * @author: authorName
 * @create: 2019-12-26 14:23
 **/
@Component
public class TrafficDataConsumer {

    @Autowired
    ITrafficEventService iTrafficEventService;

    @JmsListener(destination = "traffic")
    public void reciveDate(String msg){
        try {
            WebsocketController.broadcast(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        iTrafficEventService.recvTrafficData(JavaBean2Json.Json2JavaBean(msg, EventDataVo.class));
    }
}