wang
2024-04-03 b0cd8e56e79637407ff32bd559eab896101d887c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.mes.service;
 
 
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
 
 
 
 
 
@Service
public class MqMessage {
    @Autowired
    private RabbitMQUtils rabbitMQUtils;
 
    public boolean Add(String message, String queueName,String messageId){
        try {
            return rabbitMQUtils.sendMessageWithId(message, queueName,messageId);
        } catch (Exception e) {
            // TODO: handle exception
            return false;//异常时错误
        }
    }
    //根据ID查找消息
    public String SelectId(String queueName,boolean isDelete,String messageId){
 
        try {
            String content=rabbitMQUtils.consumeMessageById(messageId,queueName,isDelete);
            
            return content;
        } catch (Exception e) {
            // TODO: handle exception
            return null;//异常时错误
        } 
    }
    public boolean Delete(String queueName,String messageId){
        try
        {
            rabbitMQUtils.consumeMessageById(messageId,queueName,false);
            return true;
        }catch(Exception e){
            return false;
        }
        
    }
    //无修改
    public void Update(){
        
    }
    
    
}