I am following the github codes
. I send 5 messages to the queue. And consumed by following codes. But it removes all the messages after consumed at once, not one by one.
Flow = Session.CreateFlow(new FlowProperties()
{
AckMode = MessageAckMode.ClientAck,
},
Queue, null, HandleMessageEvent, HandleFlowEvent);
Flow.Start();Console.WriteLine(“Waiting for a message in the queue ‘{0}’…”, queueName);
WaitEventWaitHandle.WaitOne();
private void HandleMessageEvent(object source, MessageEventArgs args)
{
// Received a message
Console.WriteLine("Received message.");
using (IMessage message = args.Message)
{
try
{
// Expecting the message content as a binary attachment
Console.WriteLine("Message content: {0}", Encoding.ASCII.GetString(message.BinaryAttachment));
Flow.Ack(message.ADMessageId);
Console.WriteLine($"Message acknowledged with message id :{message.ADMessageId}" );
//finish the program
WaitEventWaitHandle.Set();
}
catch (Exception ex)
{
Console.WriteLine("Error acknowledging message: {0}", ex.Message);
}
}
public void HandleFlowEvent(object sender, FlowEventArgs args)
{
// Received a flow event
Console.WriteLine("Received Flow Event '{0}' Type: '{1}' Text: '{2}'",
args.Event,
args.ResponseCode.ToString(),
args.Info);
}
}