本文整理汇总了C#中IMessage.Acknowledge方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.Acknowledge方法的具体用法?C# IMessage.Acknowledge怎么用?C# IMessage.Acknowledge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessage
的用法示例。
在下文中一共展示了IMessage.Acknowledge方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnMessage
public void OnMessage(IMessage message)
{
object data = CreateDataObject(message);
bool isPermKeyOk = false;
//Israel 11/20/2015 -- Added support for permission keys.
if (message.NMSType.ToUpper() == "SUMMARY")
{
SummaryData summaryData = data as SummaryData;
isPermKeyOk = (String.IsNullOrEmpty(summaryData.PermissionKey)) ||
(v_PermKeyList.IndexOf(summaryData.PermissionKey) > -1);
if (isPermKeyOk || v_IsSuperUser)
callback.Invoke(this, data);
}
//Israel 12/16/2015 -- Message publisher was escaping the : character-- this removes it.
else if (message.NMSType.ToUpper() == "CONFIRM")
{
TradeRqmtConfirm confirmData = data as TradeRqmtConfirm;
if (!String.IsNullOrEmpty(confirmData.XmitAddr))
confirmData.XmitAddr = confirmData.XmitAddr.Replace(@"\", "");
callback.Invoke(this, data);
}
else
{
callback.Invoke(this, data);
}
message.Acknowledge();
//string testMessage = DateTime.Now.ToShortDateString() + ":" + DateTime.Now.ToLongTimeString() + ": " + message.ToString();
//File.AppendAllText(@"_MessageDump.txt", testMessage + Environment.NewLine);
}
示例2: OnMessageListener
private void OnMessageListener(IMessage message)
{
counter++;
if(this.counter <= 4)
{
session.Rollback();
}
else
{
message.Acknowledge();
session.Commit();
}
}
示例3: OnMessage
public void OnMessage(IMessage message)
{
Assert.IsNotNull(message);
if(!dontAck)
{
try
{
message.Acknowledge();
}
catch(Exception)
{
}
}
}
示例4: OnMessage
/// <summary>
/// Receives all of the test messages.
/// </summary>
///
/// <param name="message">The newly arrived test message.</param>
public void OnMessage(IMessage message)
{
try
{
if (_acknowledgeMode == AcknowledgeMode.ClientAcknowledge)
{
message.Acknowledge();
}
messagesReceived++;
_log.Debug("messagesReceived = " + messagesReceived);
// Check if all of the messages in the test have been received, in which case notify the message producer that the test has
// succesfully completed.
if (messagesReceived == NUM_MESSAGES + _extraMessage)
{
lock (testComplete)
{
failedOver = true;
Monitor.Pulse(testComplete);
}
}
}
catch (QpidException e)
{
_log.Fatal("Exception received. About to stop.", e);
Stop();
}
}
示例5: OnInvalidate
protected void OnInvalidate(IMessage receivedMsg)
{
IObjectMessage m2 = receivedMsg as IObjectMessage;
Debug.WriteLine("message has the following raw content:");
// Debug.WriteLine(m2.)
try
{
object obj = m2.Body;
}
catch (Exception e)
{
Debug.WriteLine("caught exception while accessing message body: " + e.Message);
}
object obj2 = m2.ToObject();
var msg = receivedMsg as IBytesMessage;
var result = msg != null ? new UTF8Encoding().GetString(msg.Content) : "bytes message is null";
ITextMessage message = receivedMsg as ITextMessage;
if (message == null)
{
Logger.Debug(string.Format("message with id {0} is not a text message", receivedMsg.NMSMessageId));
Debug.WriteLine(string.Format("message with id {0} is not a text message", receivedMsg.NMSMessageId));
receivedMsg.Acknowledge();
return;
}
Logger.Debug(string.Format("received text message with id {0} and text {1}", message.NMSMessageId, message.Text));
Debug.WriteLine(string.Format("received text message with id {0} and text {1}", message.NMSMessageId, message.Text));
try
{
var invalidationInformation = GetInvalidationInformation(message);
foreach (string dcpUri in invalidationInformation.InvalidationDcps)
{
foreach (ICacheAgent cacheAgent in CacheAgents)
{
Logger.Debug(string.Format("telling cache agent {0} to remove DCP with uri {1}", cacheAgent.GetType().Name, dcpUri));
//cacheAgent.Remove(dcpUri)
}
}
foreach (InvalidationUrl url in invalidationInformation.InvalidationUrls)
{
foreach (ICacheAgent cacheAgent in CacheAgents)
{
Logger.Debug(string.Format("telling cache agent {0} to remove page with url {1}", cacheAgent.GetType().Name, url.TcmUri));
//cacheAgent.Remove(url.TcmUri)
}
}
//LoggerService.Debug("<<Received message: finished processing");
}
catch (Exception e)
{
Logger.Error("error in invalidation transaction: {0}", e.ToString());
}
finally
{
message.Acknowledge();
Logger.Debug(string.Format("acknowledged received message with id {0}", message.NMSMessageId));
}
}
示例6: MessageAccepted
public void MessageAccepted(IMessage message)
{
message.Acknowledge();
}
示例7: CommitIfNecessary
/// <summary>
/// Perform a commit or message acknowledgement, as appropriate
/// </summary>
/// <param name="session">The session to commit.</param>
/// <param name="message">The message to acknowledge.</param>
/// <exception cref="NMSException">In case of commit failure</exception>
protected virtual void CommitIfNecessary(ISession session, IMessage message)
{
// Commit session or acknowledge message
if (session.Transacted)
{
// Commit necessary - but avoid commit call is Session transaction is externally coordinated.
if (IsSessionLocallyTransacted(session))
{
NmsUtils.CommitIfNecessary(session);
}
}
else if (IsClientAcknowledge(session))
{
message.Acknowledge();
}
}
示例8: MessageListenerB
private void MessageListenerB(IMessage message)
{
message.Acknowledge();
ITextMessage messageB = message as ITextMessage;
string msgText = "Message #" + receivedB;
Assert.AreEqual(msgText, messageB.Text, "Message text B does not match.");
Tracer.Info("Received Listener B: " + msgText);
receivedB++;
}