Hi @TomF, thanks for the replies.
The purpose of SetText is just to show the information on the window form. I did not overwrite the message, because based on the sample code, it uses the following code to display the message, I just use callback to let it show on the UI.
[Sample code]
Console.WriteLine(“Message content: {0}”, Encoding.ASCII.GetString(message.BinaryAttachment));
[My code]
SetText(Encoding.ASCII.GetString(message.BinaryAttachment));
delegate void SetTextCallback(string text);
private void SetText(string text)
{
if (this.txtSubData.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object { text });
}
else
{
string time = DateTime.Now.ToString();
this.txtSubData.Text += time + " " + text + “\r\n”;
}
}
Secondly, for Flow.Ack, my understanding is, it acks to the broker with messageid (looks it is sequence number), so that the broker (solace) confirm the consumer got the data and able to delete the data from queue. The ack message as below image. SOLCLIENT_OK only used on connection checking.
Imgur: The magic of the Internet
So, after the consumber subscribed the queue with topic, it created flow and waiting for message.
// Add subscription to the topic mapped to the queue
ITopic tutorialTopic = ContextFactory.Instance.CreateTopic(“T/mapped/topic/sampleMsg”);
session.Subscribe(queue, tutorialTopic, SubscribeFlag.WaitForConfirm, null);
Flow = session.CreateFlow(new FlowProperties()
{
AckMode = MessageAckMode.ClientAck
},
queue, null, HandleMessageEvent, HandleFlowEvent);
Flow.Start();
// block the current thread until a confirmation received
CountdownEvent.Wait();
Thanks for the link of IContext Interface, so I should not directly set Thread sleep to simulate the consumer is busy, and late to ack. I may not really understand the concept of ContextFactory, need some time to survey it.