功能梳理

yun-zuoyi
alwaysfrin 7 years ago
parent cae7ba95de
commit 8ebe456cab

@ -1,6 +1,6 @@
package cn.estsh.i3plus.core.apiservice.controller; package cn.estsh.i3plus.core.apiservice.controller;
import cn.estsh.i3plus.core.apiservice.mq.I3CoreQueue; import cn.estsh.i3plus.core.apiservice.mq.I3CoreQueueConfig;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.impp.framework.boot.util.ResultBean; import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.i3plus.pojo.mes.MachineFactory; import cn.estsh.i3plus.pojo.mes.MachineFactory;
@ -83,13 +83,13 @@ public class DemoRestController {
String context = "hello : " + data; String context = "hello : " + data;
System.out.println("发送DEMO_STR_QUEUE数据 : " + context); System.out.println("发送DEMO_STR_QUEUE数据 : " + context);
this.rabbitTemplate.convertAndSend(I3CoreQueue.DEMO_STR_QUEUE, context); this.rabbitTemplate.convertAndSend(I3CoreQueueConfig.DEMO_STR_QUEUE, context);
System.out.println("发送DEMO_HANDLE_QUEUE数据 : " + context); System.out.println("发送DEMO_HANDLE_QUEUE数据 : " + context);
this.rabbitTemplate.convertAndSend(I3CoreQueue.DEMO_HANDLE_QUEUE, context); this.rabbitTemplate.convertAndSend(I3CoreQueueConfig.DEMO_HANDLE_QUEUE, context);
System.out.println("发送Object数据 : " + context); System.out.println("发送Object数据 : " + context);
this.rabbitTemplate.convertAndSend(I3CoreQueue.DEMO_OBJ_QUEUE, new MachineFactory("111mq","rabbit")); this.rabbitTemplate.convertAndSend(I3CoreQueueConfig.DEMO_OBJ_QUEUE, new MachineFactory("111mq","rabbit"));
return new ResultBean(true,"操作成功"); return new ResultBean(true,"操作成功");
} }
@ -97,17 +97,17 @@ public class DemoRestController {
@GetMapping(value="/get-mq-handle") @GetMapping(value="/get-mq-handle")
@ApiOperation(value="手动获取队列",notes="接收队列") @ApiOperation(value="手动获取队列",notes="接收队列")
public ResultBean getHandleMQ(){ public ResultBean getHandleMQ(){
Object data = this.rabbitTemplate.receiveAndConvert(I3CoreQueue.DEMO_HANDLE_QUEUE); Object data = this.rabbitTemplate.receiveAndConvert(I3CoreQueueConfig.DEMO_HANDLE_QUEUE);
if(data != null) { if(data != null) {
LOGGER.info("获取队列数据:" + data); LOGGER.info("获取队列数据:" + data);
} }
Object message = this.rabbitTemplate.receiveAndConvert(I3CoreQueue.DEMO_STR_QUEUE); Object message = this.rabbitTemplate.receiveAndConvert(I3CoreQueueConfig.DEMO_STR_QUEUE);
if(message != null){ if(message != null){
LOGGER.info("获取str数据" + data); LOGGER.info("获取str数据" + data);
} }
message = this.rabbitTemplate.receiveAndConvert(I3CoreQueue.DEMO_OBJ_QUEUE); message = this.rabbitTemplate.receiveAndConvert(I3CoreQueueConfig.DEMO_OBJ_QUEUE);
if(message != null){ if(message != null){
LOGGER.info("获取obj数据" + data); LOGGER.info("获取obj数据" + data);
} }
@ -143,7 +143,7 @@ public class DemoRestController {
System.out.println("i=" + i + ",s=" + s + ",s1=" + s1 + ",s2=" + s2); System.out.println("i=" + i + ",s=" + s + ",s1=" + s1 + ",s2=" + s2);
}); });
} }
String returnMsg = (String) rabbitTemplate.convertSendAndReceive(I3CoreQueue.DEMO_RETURN_QUEUE, data); String returnMsg = (String) rabbitTemplate.convertSendAndReceive(I3CoreQueueConfig.DEMO_RETURN_QUEUE, data);
System.out.println("===返回数据==="+returnMsg); System.out.println("===返回数据==="+returnMsg);
return new ResultBean(true,"操作成功"); return new ResultBean(true,"操作成功");
} }
@ -159,7 +159,7 @@ public class DemoRestController {
@ApiOperation(value="ack队列",notes="发送") @ApiOperation(value="ack队列",notes="发送")
public ResultBean sendAckMQ(String data) throws IOException, TimeoutException { public ResultBean sendAckMQ(String data) throws IOException, TimeoutException {
System.out.println("发送ack数据 : " + data); System.out.println("发送ack数据 : " + data);
this.rabbitTemplate.convertAndSend(I3CoreQueue.DEMO_ACK_QUEUE, data); this.rabbitTemplate.convertAndSend(I3CoreQueueConfig.DEMO_ACK_QUEUE, data);
return new ResultBean(true,"操作成功"); return new ResultBean(true,"操作成功");
} }
@ -169,13 +169,13 @@ public class DemoRestController {
public ResultBean getAckMQ() throws IOException, TimeoutException { public ResultBean getAckMQ() throws IOException, TimeoutException {
Channel channel = this.rabbitTemplate.getConnectionFactory().createConnection().createChannel(false); Channel channel = this.rabbitTemplate.getConnectionFactory().createConnection().createChannel(false);
System.out.println("1====" + channel); System.out.println("1====" + channel);
String str = (String) rabbitTemplate.receiveAndConvert(I3CoreQueue.DEMO_ACK_QUEUE); String str = (String) rabbitTemplate.receiveAndConvert(I3CoreQueueConfig.DEMO_ACK_QUEUE);
System.out.println("2=============="+str); System.out.println("2=============="+str);
Message message = rabbitTemplate.receive(I3CoreQueue.DEMO_ACK_QUEUE); Message message = rabbitTemplate.receive(I3CoreQueueConfig.DEMO_ACK_QUEUE);
System.out.println("3=============="+message); System.out.println("3=============="+message);
try { try {
/*String data = (String) this.rabbitTemplate.receiveAndConvert(I3CoreQueue.DEMO_ACK_QUEUE); /*String data = (String) this.rabbitTemplate.receiveAndConvert(I3CoreQueueConfig.DEMO_ACK_QUEUE);
System.out.println("【client】数据接收成功" + data); System.out.println("【client】数据接收成功" + data);
if("ack".equals(data)){ if("ack".equals(data)){
@ -183,7 +183,7 @@ public class DemoRestController {
throw new RuntimeException("【队列抛出异常】" + data); throw new RuntimeException("【队列抛出异常】" + data);
}*/ }*/
String data = (String) this.rabbitTemplate.receiveAndConvert(I3CoreQueue.DEMO_ACK_QUEUE); String data = (String) this.rabbitTemplate.receiveAndConvert(I3CoreQueueConfig.DEMO_ACK_QUEUE);
System.out.println("【client】数据接收成功" + data); System.out.println("【client】数据接收成功" + data);
if("ackack".equals(data)){ if("ackack".equals(data)){

@ -14,8 +14,8 @@ import org.springframework.context.annotation.Configuration;
* @Modify: * @Modify:
**/ **/
@Configuration @Configuration
public class I3CoreQueue { public class I3CoreQueueConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(I3CoreQueue.class); private static final Logger LOGGER = LoggerFactory.getLogger(I3CoreQueueConfig.class);
public static final String DEMO_STR_QUEUE = "demo_str_queue"; public static final String DEMO_STR_QUEUE = "demo_str_queue";

@ -17,17 +17,17 @@ import java.io.IOException;
@Component @Component
public class I3CoreQueueReceiver { public class I3CoreQueueReceiver {
/*@RabbitListener(queues = I3CoreQueue.DEMO_STR_QUEUE) /*@RabbitListener(queues = I3CoreQueueConfig.DEMO_STR_QUEUE)
public void getObjQueue(String data) { public void getObjQueue(String data) {
System.out.println("接收数据 : " + data.toString()); System.out.println("接收数据 : " + data.toString());
} }
@RabbitListener(queues = I3CoreQueue.DEMO_OBJ_QUEUE) @RabbitListener(queues = I3CoreQueueConfig.DEMO_OBJ_QUEUE)
public void getStrQueue(MachineFactory data) { public void getStrQueue(MachineFactory data) {
System.out.println("强转对象:" + data); System.out.println("强转对象:" + data);
}*/ }*/
@RabbitListener(queues = I3CoreQueue.DEMO_RETURN_QUEUE) @RabbitListener(queues = I3CoreQueueConfig.DEMO_RETURN_QUEUE)
public Message processReturn(String data, Channel channel, Message message) { public Message processReturn(String data, Channel channel, Message message) {
try { try {
System.out.println("【client】数据接收成功" + data); System.out.println("【client】数据接收成功" + data);
@ -59,7 +59,7 @@ public class I3CoreQueueReceiver {
return message; return message;
} }
@RabbitListener(queues = I3CoreQueue.DEMO_ACK_QUEUE) @RabbitListener(queues = I3CoreQueueConfig.DEMO_ACK_QUEUE)
public void processAck(String data, Channel channel, Message message) { public void processAck(String data, Channel channel, Message message) {
try { try {
System.out.println("【client】数据接收成功" + data); System.out.println("【client】数据接收成功" + data);

Loading…
Cancel
Save