package com.liquidnet.service.dragon.service.impl;

import com.liquidnet.service.dragon.service.IDragonOrderRefundsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService {

    @Autowired
    StringRedisTemplate stringRedisTemplate;

    @Override
    public void sendRedisQueue() {
        try {
            stringRedisTemplate.convertAndSend("msg2", "测试 redis 订阅信息2");

            HashMap<String ,String> map = new HashMap<>();
            map.put("message","测试 redis 订阅信息1");
            MapRecord<String, String, String> record = StreamRecords.mapBacked(map).withStreamKey("dragon");
            stringRedisTemplate.opsForStream().add(record);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
