mirror of
https://github.com/spacebarchat/server.git
synced 2026-03-30 05:19:52 +00:00
21 lines
594 B
C#
21 lines
594 B
C#
using RabbitMQ.Client;
|
|
|
|
namespace Spacebar.RabbitMqUtilities;
|
|
|
|
public interface IRabbitMQService {
|
|
Task<IConnection> CreateChannel();
|
|
}
|
|
|
|
public class RabbitMQService(RabbitMQConfiguration config) : IRabbitMQService {
|
|
public async Task<IConnection> CreateChannel() {
|
|
var connection = new ConnectionFactory {
|
|
UserName = config.Username,
|
|
Password = config.Password,
|
|
HostName = config.Host,
|
|
// DispatchConsumersAsync = true
|
|
};
|
|
|
|
var channel = await connection.CreateConnectionAsync();
|
|
return channel;
|
|
}
|
|
} |