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
Hi, I'm using QOS ExactlyOnce. Is this supported as I notice you have an issue below. Basically when I use this the code below throws an error. It is because the GetNextMessageIdentifier returns a count only unique per topic. The id is then added to publishedMessages dictionary which contains all sent messages. Therefore I send a message to topic A and then to topic B, both will be given ID 1 and the dictionary add fails as the key already exists. Am I doing something wrong?
public short Publish(string topic, MqttQos qualityOfService, object data)
where TDataConverter : IPublishDataConverter
{
short msgID = MessageIdentifierDispenser.GetNextMessageIdentifier(String.Format("Topic:{0}", topic));
IPublishDataConverter converter = GetPublishDataConverter<TDataConverter>();
MqttPublishMessage msg = new MqttPublishMessage()
.ToTopic(topic)
.WithMessageIdentifier(msgID)
.WithQos(qualityOfService)
.PublishData(converter.ConvertToBytes(data));
// QOS level 1 or 2 messages need to be saved so we can do the ack processes
if (qualityOfService == MqttQos.AtLeastOnce || qualityOfService == MqttQos.ExactlyOnce)
{
Console.WriteLine("{0}",System.Threading.Thread.CurrentThread.ManagedThreadId);
publishedMessages.Add(msgID, msg);
}
connectionHandler.SendMessage(msg);
return msgID;
}
I fixed this by adding the following unpleasant hack at the start of function MessageIdentifierDispenser.GetNextMessageIdentifier:
key = "All";
Thereby ensuring that all messages are counted consecutively regardless of topic
The text was updated successfully, but these errors were encountered:
Hi, I'm using QOS ExactlyOnce. Is this supported as I notice you have an issue below. Basically when I use this the code below throws an error. It is because the GetNextMessageIdentifier returns a count only unique per topic. The id is then added to publishedMessages dictionary which contains all sent messages. Therefore I send a message to topic A and then to topic B, both will be given ID 1 and the dictionary add fails as the key already exists. Am I doing something wrong?
public short Publish(string topic, MqttQos qualityOfService, object data)
where TDataConverter : IPublishDataConverter
{
short msgID = MessageIdentifierDispenser.GetNextMessageIdentifier(String.Format("Topic:{0}", topic));
I fixed this by adding the following unpleasant hack at the start of function MessageIdentifierDispenser.GetNextMessageIdentifier:
key = "All";
Thereby ensuring that all messages are counted consecutively regardless of topic
The text was updated successfully, but these errors were encountered: