示例#1
0
 public QueueBatchConsumer(string source, ISyncQueueDispatcher disp, String readLabelReformatExpression)
     : base(String.Format("QueueBatchConsumer[{0}]", source))
 {
     srcq = new OpaqueMessageQueue(readLabelReformatExpression)
     {
         Name = source
     };
     dst = disp;
 }
示例#2
0
        public static Result Dispatch(OpaqueMessageQueue Source, ISyncQueueDispatcher Destination)
        {
            var msg = Source.Peek();

            if (msg == null)
            {
                return(Result.SourceEmpty);
            }
            if (!Destination.CanPush)
            {
                return(Result.DestinationLocked);
            }
            if (!Destination.BeginPush(msg))
            {
                return(Result.DestinationFailure);
            }
            if (Destination.WaitCompleted(msg))
            {
                Source.Pop(msg.Id, false);
                return(Result.Dispatched);
            }
            return(Result.DestinationFailure);
        }