Skip to content

Commit

Permalink
Channel stacking is prevented during message sending with Message Pro…
Browse files Browse the repository at this point in the history
…ducer.
  • Loading branch information
byerlikaya committed Jun 14, 2024
1 parent 8cbacf5 commit f5c8b4e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Basic.RabbitMQ/Basic.RabbitMQ.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<Title>Basic.RabbitMQ</Title>
<Authors>Barış Yerlikaya</Authors>
<Company>Barış Yerlikaya</Company>
<Copyright>Copyright (c) 2023 Barış Yerlikaya</Copyright>
<Copyright>Copyright (c) 2024 Barış Yerlikaya</Copyright>
<PackageProjectUrl>https://github.com/byerlikaya/Basic.RabbitMQ</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/byerlikaya/Basic.RabbitMQ</RepositoryUrl>
<PackageTags>RabbitMQ rabbitmq</PackageTags>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Description>.NET Core library that simplifies RabbitMQ usage and works with the Direct Exchange type.</Description>
<PackageId>Basic.RabbitMQ</PackageId>
<Version>1.1.0.1</Version>
<Version>1.1.1</Version>
<Product>Basic.RabbitMQ</Product>
<LangVersion>preview</LangVersion>
</PropertyGroup>
Expand Down
6 changes: 2 additions & 4 deletions src/Basic.RabbitMQ/MessageProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ public class MessageProducer(RabbitMQClientService rabbitMqClientService) : IMes
{
public void SendMessage(string queueName, string routingKey, string message)
{
var channel = rabbitMqClientService.Connect(queueName);

using var channel = rabbitMqClientService.Connect(queueName);
channel.QueueBind(
exchange: rabbitMqClientService.BrokerOptions.ExchangeName,
queue: queueName,
Expand All @@ -26,8 +25,7 @@ public void SendMessage(string queueName, string routingKey, string message)

public void SendMessage<T>(string queueName, string routingKey, T message)
{
var channel = rabbitMqClientService.Connect(queueName);

using var channel = rabbitMqClientService.Connect(queueName);
channel.QueueBind(
exchange: rabbitMqClientService.BrokerOptions.ExchangeName,
queue: queueName,
Expand Down
4 changes: 2 additions & 2 deletions src/Basic.RabbitMQ/Services/RabbitMQClientService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Basic.RabbitMQ.Services;

public class RabbitMQClientService(IConfiguration configuration, ConnectionFactory connectionFactory)
: IDisposable
// ReSharper disable once InconsistentNaming
public class RabbitMQClientService(IConfiguration configuration, ConnectionFactory connectionFactory) : IDisposable
{
public readonly MessageBrokerOptions BrokerOptions = configuration.GetSection(nameof(MessageBrokerOptions)).Get<MessageBrokerOptions>();

Expand Down

0 comments on commit f5c8b4e

Please sign in to comment.