0

我正在为消息编写传输适配器(我从 java 本机方法接收消息并将其发送到 RabbitMQ 的队列)并且我不能丢失任何消息(例如与 RabbitMQ 的服务器的连接不可用)。当处理或发送失败时,我需要一个持久性存储我的消息。现在我使用 mapDB 库及其队列实现

public void send(byte[] message){
    queue.add(message);
    db.commit();
    //do process and send the message
    queue.poll();//message sent success, we can remove it from storage
    db.commit();
}

但是它的实现时间很长。请建议这种情况下的最佳实施。

消息的顺序必须正确。

4

0 回答 0