Skip to content

Commit efc7799

Browse files
committed
add queueid log
1 parent 1d0a98b commit efc7799

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

Src/Sample/EQueueTest/log4net.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<layout type="log4net.Layout.PatternLayout">
2424
<conversionPattern value="%date %5level %logger - %message%newline" />
2525
</layout>
26+
<threshold value="ERROR" />
2627
</appender>
2728
<appender name="traceAppender" type="log4net.Appender.TraceAppender">
2829
<layout type="log4net.Layout.PatternLayout">

Src/iFramework.Plugins/IFramework.MessageQueue.EQueue/CommandConsumer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
using IFramework.Infrastructure.Unity.LifetimeManagers;
1212
using IFramework.UnitOfWork;
1313
using IFramework.SysException;
14+
using System.Collections.Concurrent;
1415

1516
namespace IFramework.MessageQueue.EQueue
1617
{
1718
public class CommandConsumer : MessageConsumer<MessageContext>
1819
{
1920
public static List<CommandConsumer> CommandConsumers = new List<CommandConsumer>();
21+
public static ConcurrentDictionary<string, string> _handledCommandDict = new ConcurrentDictionary<string, string>();
2022
public static string GetConsumersStatus()
2123
{
2224
var status = string.Empty;
@@ -79,6 +81,12 @@ protected override void ConsumeMessage(MessageContext messageContext, QueueMessa
7981
{
8082
return;
8183
}
84+
var currentName = string.Format("consumer:{0} queueID:{1}", this.Name, queueMessage.QueueId);
85+
if (!_handledCommandDict.TryAdd(messageContext.MessageID, currentName))
86+
{
87+
_Logger.ErrorFormat("Duplicated command [{0}] to be processed in QueueID:{1}.", messageContext.MessageID, currentName);
88+
}
89+
8290

8391
_Logger.DebugFormat("Start Handle command, commandID:{0} queueID:{1}", messageContext.MessageID, queueMessage.QueueId);
8492
var message = messageContext.Message;

0 commit comments

Comments
 (0)