记得上下班打卡 | git大法好,push需谨慎

Commit 13a02d47 authored by anjiabin's avatar anjiabin

合并consumer

parent e373a1d1
package com.liquidnet.service.dragon.service; package com.liquidnet.service.dragon.service;
public interface IDragonOrdersService { public interface IDragonOrdersService {
void sendRedisQueue();
} }
package com.liquidnet.service.dragon.controller; package com.liquidnet.service.dragon.controller;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.service.IDragonOrdersService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("pay") @RequestMapping("pay")
public class PayController { public class PayController {
@Autowired
IDragonOrdersService dragonOrdersService;
@PostMapping("pre")
@ApiOperation("发送测试redis")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<String> checkCanOrder() {
dragonOrdersService.sendRedisQueue();
return ResponseDto.success();
}
} }
package com.liquidnet.service.dragon.service.impl; package com.liquidnet.service.dragon.service.impl;
import com.liquidnet.service.dragon.service.IDragonOrdersService; import com.liquidnet.service.dragon.service.IDragonOrdersService;
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 DragonOrdersServiceImpl implements IDragonOrdersService { public class DragonOrdersServiceImpl implements IDragonOrdersService {
@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();
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment