♻️ Replace normal streams with JetStream

🐛 Fix pass order didn't handled successfully
This commit is contained in:
2025-09-14 19:25:53 +08:00
parent 19bf17200d
commit 4ee387ab76
17 changed files with 213 additions and 100 deletions

View File

@@ -1,6 +1,8 @@
using System.Text.Json;
using DysonNetwork.Shared.Proto;
using NATS.Client.Core;
using NATS.Client.JetStream;
using NATS.Net;
namespace DysonNetwork.Pusher.Services;
@@ -20,7 +22,8 @@ public class QueueService(INatsConnection nats)
})
};
var rawMessage = GrpcTypeHelper.ConvertObjectToByteString(message).ToByteArray();
await nats.PublishAsync(QueueBackgroundService.QueueName, rawMessage);
var js = nats.CreateJetStreamContext();
await js.PublishAsync(QueueBackgroundService.QueueName, rawMessage);
}
public async Task EnqueuePushNotification(Notification.Notification notification, Guid userId, bool isSavable = false)
@@ -35,7 +38,8 @@ public class QueueService(INatsConnection nats)
Data = JsonSerializer.Serialize(notification)
};
var rawMessage = GrpcTypeHelper.ConvertObjectToByteString(message).ToByteArray();
await nats.PublishAsync(QueueBackgroundService.QueueName, rawMessage);
var js = nats.CreateJetStreamContext();
await js.PublishAsync(QueueBackgroundService.QueueName, rawMessage);
}
}