| | |
| | | import com.moral.api.websocket.SingleDeviceServer; |
| | | import com.moral.util.UnitConvertUtils; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.kafka.clients.consumer.Consumer; |
| | | import org.apache.kafka.clients.consumer.ConsumerRecord; |
| | | import org.apache.kafka.common.TopicPartition; |
| | |
| | | * @Version TODO |
| | | **/ |
| | | @Component |
| | | @Slf4j |
| | | public class SecondDataConsumer implements ConsumerSeekAware { |
| | | |
| | | @KafkaListener(containerFactory = "secondDataListenerFactory",topics = "second_data") |
| | | public void listen(ConsumerRecord<String, String> record, Consumer consumer) throws Exception { |
| | | String messageStr = record.value(); |
| | | Map<String, Object> message = (Map<String, Object>) JSON.parse(messageStr); |
| | | log.info(message.toString()); |
| | | //long serverStartTime = System.currentTimeMillis(); |
| | | CopyOnWriteArraySet<SingleDeviceServer> sockets = SingleDeviceServer.sockets; |
| | | for (SingleDeviceServer socket : sockets) { |