DeliveryCount error
Hello,
I have a .net application which subscribe to a Solace queue and I’m able to get the messages and to acknowledge them. After the acknowledge (with success) I receive an error:
C#
SolaceSystems.Solclient.Messaging.OperationErrorException: Failed to get Delivery Count at SolaceSystems.Solclient.Utils.Types.Utilities.GuardAgainstNotOk(ReturnCode returnCode, String message, Boolean includeSdkError, ISolLogger logger) at SolaceSystems.Solclient.Messaging.Native.BasicMessageImpl.get_DeliveryCount() --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) at Serilog.Capturing.PropertyValueConverter.GetProperties(Object value)+MoveNext()
Does anyone how to configure the configure DeliveryCount in .net in order to avoid automatically call when step into the next message?
Answers
-
Hey @cristianpaun - looking at the dotnet Solace API reference docs I can see that an OperationErrorException is thrown when delivery count is not supported on the message.
Can you confirm how the messages are published to the queue that you are binding to from your dotnet consumer?
0 -
on my understanding this is a configuration related to the queue: Configuring Queues (solace.com). My problem is that I'm not trying to access this property on the message (DeliveryCount) it is done automatically when I subscribe to a queue and try to consume the message. Please see below my subscribe function and HandleMessage (with no get call for DeliveryCount):
public void Subscribe(string topicName, EventHandler<MessageEventArgs> handleMessage) { var sessionProps = new SessionProperties { Host = Host, VPNName = VPNName, UserName = UserName, Password = Password, ReconnectRetries = DefaultReconnectRetries, SSLValidateCertificate = false, GdWithWebTransport = true, }; try { Session = Context.CreateSession(sessionProps, null, null); var returnCode = Session.Connect(); if (returnCode == ReturnCode.SOLCLIENT_OK) { EndpointProperties endpointProps = new EndpointProperties() { Permission = EndpointProperties.EndpointPermission.Consume, AccessType = EndpointProperties.EndpointAccessType.Exclusive }; Queue = ContextFactory.Instance.CreateQueue(topicName); Flow = Session.CreateFlow(new FlowProperties { AckMode = MessageAckMode.ClientAck }, Queue, null, handleMessage, FlowEventHandler); Flow.Start(); WaitEventWaitHandle.WaitOne(); Flow = Session.CreateFlow(new FlowProperties { AckMode = MessageAckMode.ClientAck }, Queue, null, handleMessage, FlowEventHandler); Flow.Start(); WaitEventWaitHandle.WaitOne();*/ } else { throw new Exception($"Cannot connect to topic {topicName}"); } } catch (Exception e) { WaitEventWaitHandle.Set(); throw; } } private void HandleMessage(object? sender, MessageEventArgs messageEventArgs) { try { using var message = messageEventArgs.Message; _logger.LogInformation("Message received {@message}", message); _subscriberClient.AckMessage(message.ADMessageId); message.Dispose(); } catch (Exception e) { _logger.LogInformation("Error {@Err}", e.Message); } }
0 -
Hello there, @cristianpaun!
I have a couple of questions regarding the sample code you have provided:
Where is the exception being thrown? The provided stack trace does not show whether the exception is thrown from within the
HandleMessage
method or theSubscribe
method.Where is the
WaitEventtHandle
being set (besides thecatch
block)? In the standard .NET samples, thisAutoResetEvent
is set within theHandleMessage
handler.Why are there two separate flows being created on the same queue, and when are they being disposed? In a typical Solace app that reads from a Queue, the flow lives for the duration of the session and the
HandleMessage
handler will be invoked once for each message received.Otherwise, I have so far been unable to reproduce the issue you are seeing but have suspicions it may have to with re-assignment of the class property
Flow
between individual message events.0