|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
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.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.MachineFactory;
|
|
|
|
@ -83,13 +83,13 @@ public class DemoRestController {
|
|
|
|
|
String context = "hello : " + data;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
this.rabbitTemplate.convertAndSend(I3CoreQueue.DEMO_HANDLE_QUEUE, context);
|
|
|
|
|
this.rabbitTemplate.convertAndSend(I3CoreQueueConfig.DEMO_HANDLE_QUEUE, 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,"操作成功");
|
|
|
|
|
}
|
|
|
|
@ -97,17 +97,17 @@ public class DemoRestController {
|
|
|
|
|
@GetMapping(value="/get-mq-handle")
|
|
|
|
|
@ApiOperation(value="手动获取队列",notes="接收队列")
|
|
|
|
|
public ResultBean getHandleMQ(){
|
|
|
|
|
Object data = this.rabbitTemplate.receiveAndConvert(I3CoreQueue.DEMO_HANDLE_QUEUE);
|
|
|
|
|
Object data = this.rabbitTemplate.receiveAndConvert(I3CoreQueueConfig.DEMO_HANDLE_QUEUE);
|
|
|
|
|
if(data != null) {
|
|
|
|
|
LOGGER.info("获取队列数据:" + data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Object message = this.rabbitTemplate.receiveAndConvert(I3CoreQueue.DEMO_STR_QUEUE);
|
|
|
|
|
Object message = this.rabbitTemplate.receiveAndConvert(I3CoreQueueConfig.DEMO_STR_QUEUE);
|
|
|
|
|
if(message != null){
|
|
|
|
|
LOGGER.info("获取str数据:" + data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message = this.rabbitTemplate.receiveAndConvert(I3CoreQueue.DEMO_OBJ_QUEUE);
|
|
|
|
|
message = this.rabbitTemplate.receiveAndConvert(I3CoreQueueConfig.DEMO_OBJ_QUEUE);
|
|
|
|
|
if(message != null){
|
|
|
|
|
LOGGER.info("获取obj数据:" + data);
|
|
|
|
|
}
|
|
|
|
@ -143,7 +143,7 @@ public class DemoRestController {
|
|
|
|
|
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);
|
|
|
|
|
return new ResultBean(true,"操作成功");
|
|
|
|
|
}
|
|
|
|
@ -159,7 +159,7 @@ public class DemoRestController {
|
|
|
|
|
@ApiOperation(value="ack队列",notes="发送")
|
|
|
|
|
public ResultBean sendAckMQ(String data) throws IOException, TimeoutException {
|
|
|
|
|
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,"操作成功");
|
|
|
|
|
}
|
|
|
|
@ -169,13 +169,13 @@ public class DemoRestController {
|
|
|
|
|
public ResultBean getAckMQ() throws IOException, TimeoutException {
|
|
|
|
|
Channel channel = this.rabbitTemplate.getConnectionFactory().createConnection().createChannel(false);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
Message message = rabbitTemplate.receive(I3CoreQueue.DEMO_ACK_QUEUE);
|
|
|
|
|
Message message = rabbitTemplate.receive(I3CoreQueueConfig.DEMO_ACK_QUEUE);
|
|
|
|
|
System.out.println("3=============="+message);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
if("ack".equals(data)){
|
|
|
|
@ -183,7 +183,7 @@ public class DemoRestController {
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
if("ackack".equals(data)){
|
|
|
|
|