You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use amqpendpoint class and rabbitmq to send and consume messages, and can already send and consume messages. But there is a problem. When I send more than two messages in a loop, I can see a duplicate message in the queue of rabbitmq, that is, one of the messages has been sent many times. This does not happen when I send a message in the way of rabbirmq, but when I send a message in the way of amqpendpoint, there will be repeated messages. What is the reason?How to solve it?
Here is the code:
//Send multiple message data circularly
foreach (JObject data in toSend)
this.Kernel.Send(data);//Call the send method below
AmqpCFXEndpoint endpoint;
public void Send(string data)
{
//Sending messages using amqpendpoint class
KillEndpoint();
Uri uri = new Uri($"amqp://{this.user}:{this.password}@{this.serverIP}:{this.serverPort}");
string exchangeAddress = $"/exchange/{this.exchangeName}";
endpoint = new AmqpCFXEndpoint();
endpoint.HeartbeatFrequency = TimeSpan.FromMinutes(0);
endpoint.Open("Slus.Mode.Axies");
endpoint.AddPublishChannel(uri, exchangeAddress);
Exception ex = null;
if (!endpoint.TestPublishChannel(uri, exchangeAddress, out ex))
{
Console.WriteLine($"ERROR: Unable to connect to broker {uri} Exchange {exchangeAddress}\nERROR MESSAGE: {ex.Message}");
endpoint.Close();
return;
}
endpoint.Publish(CFXEnvelope.FromJson(data));
}
Another point is that when messages are not sent in a loop, that is, when messages are sent one by one, there will be no duplicate messages in the queue of rabbitmq.
The text was updated successfully, but these errors were encountered:
Hi,
I use amqpendpoint class and rabbitmq to send and consume messages, and can already send and consume messages. But there is a problem. When I send more than two messages in a loop, I can see a duplicate message in the queue of rabbitmq, that is, one of the messages has been sent many times. This does not happen when I send a message in the way of rabbirmq, but when I send a message in the way of amqpendpoint, there will be repeated messages. What is the reason?How to solve it?
Here is the code:
//Send multiple message data circularly
foreach (JObject data in toSend)
this.Kernel.Send(data);//Call the send method below
AmqpCFXEndpoint endpoint;
public void Send(string data)
{
//Sending messages using amqpendpoint class
KillEndpoint();
Uri uri = new Uri($"amqp://{this.user}:{this.password}@{this.serverIP}:{this.serverPort}");
string exchangeAddress = $"/exchange/{this.exchangeName}";
private void KillEndpoint()
{
if (endpoint != null)
{
endpoint.Close();
endpoint = null;
}
}
Another point is that when messages are not sent in a loop, that is, when messages are sent one by one, there will be no duplicate messages in the queue of rabbitmq.
The text was updated successfully, but these errors were encountered: