Пример #1
0
        internal IQueueItem ExecGet(QItemStream request)
        {
            if (request.Destination == null)
            {
                throw new MessageException(MessageState.InvalidMessageHost, "Invalid message.Host ");
            }
            MQueue Q = Get(request.Destination);

            if (Q == null)
            {
                throw new MessageException(MessageState.InvalidMessageHost, "message.HostName not found " + request.Destination);
            }
            switch (request.Command)
            {
            case QueueCmd.Dequeue:
                return(Q.Dequeue());

            case QueueCmd.DequeuePriority:
                return(Q.Dequeue(request.Priority));

            case QueueCmd.Peek:
                return(Q.Peek());

            case QueueCmd.PeekPriority:
                return(Q.Peek(request.Priority));
            }

            return(null);
        }
Пример #2
0
        internal MessageState ExecSet(QItemStream item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("QueueManager.ExecSet request");
            }
            if (item.Destination == null)
            {
                throw new ArgumentNullException("QueueManager.ExecSet request.Host is invalid");
            }

            MQueue Q = Get(item.Destination);

            if (Q == null)
            {
                throw new MessageException(MessageState.InvalidMessageHost, "message.HostName not found " + item.Destination);
            }
            //var item = new QItemStream(request, QueueCmd.Enqueue);
            var ptr = Q.Enqueue(item);

            return(ptr.MessageState);
        }
Пример #3
0
        /*
         * internal void Execute(QItemStream request, Stream stream)
         * {
         *  try
         *  {
         *      switch (request.Command)
         *      {
         *          case QueueCmd.Enqueue:
         *              MessageAckServer.WriteAck(stream, ExecSet(request), null);
         *              break;
         *          case QueueCmd.Dequeue:
         *          case QueueCmd.DequeuePriority:
         *          case QueueCmd.DequeueItem:
         *          case QueueCmd.Peek:
         *          case QueueCmd.PeekPriority:
         *          case QueueCmd.PeekItem:
         *              MessageAckServer.WriteResponse(stream, ExecGet(request), MessageState.Receiving);
         *              break;
         *          case QueueCmd.Commit:
         *
         *              break;
         *          case QueueCmd.Abort:
         *
         *              break;
         *
         *          //operation
         *          case QueueCmd.AddQueue:
         *              MQueue mq = null;
         *              MessageAckServer.WriteAck(stream, AddQueue(QProperties.Get(request.GetHeader()), out mq), null);
         *              break;
         *          case QueueCmd.RemoveQueue:
         *              MessageAckServer.WriteAck(stream, RemoveQueue(request.Host.HostName), null);
         *              break;
         *          case QueueCmd.HoldEnqueue:
         *              throw new Exception("Operation not supported");
         *          case QueueCmd.NoneHoldEnqueue:
         *              throw new Exception("Operation not supported");
         *          case QueueCmd.HoldDequeue:
         *              throw new Exception("Operation not supported");
         *          case QueueCmd.NoneHoldDequeue:
         *              throw new Exception("Operation not supported");
         *          case QueueCmd.EnableQueue:
         *              throw new Exception("Operation not supported");
         *          case QueueCmd.DisableQueue:
         *              throw new Exception("Operation not supported");
         *          //reports
         *          case QueueCmd.Exists:
         *              MessageAckServer.WriteAck(stream, Exists(request.Host.HostName), null);
         *              break;
         *          case QueueCmd.QueueProperty:
         *              throw new Exception("Operation not supported");
         *          case QueueCmd.ReportQueueList:
         *              GetQueueList();
         *              break;
         *          case QueueCmd.ReportQueueItems:
         *              throw new Exception("Operation not supported");
         *          case QueueCmd.ReportQueueStatistic:
         *              throw new Exception("Operation not supported");
         *          case QueueCmd.PerformanceCounter:
         *              throw new Exception("Operation not supported");
         *          case QueueCmd.QueueCount:
         *              MessageAckServer.WriteReport(stream, QueueCount(request.Host.HostName), QueueCmd.QueueCount, MessageState.Ok, null);
         *              break;
         *      }
         *  }
         *  catch (MessageException mex)
         *  {
         *      MessageAckServer.WriteError(stream, mex.MessageState, mex);
         *      Netlog.Exception("ExecGet MessageException: ", mex, true);
         *  }
         *  catch (ArgumentException ase)
         *  {
         *      MessageAckServer.WriteError(stream, MessageState.ArgumentsError, ase);
         *      Netlog.Exception("ExecGet ArgumentException: ", ase, true, true);
         *  }
         *  catch (SerializationException se)
         *  {
         *      MessageAckServer.WriteError(stream, MessageState.SerializeError, se);
         *      Netlog.Exception("ExecGet SerializationException: ", se, true);
         *  }
         *  catch (Exception ex)
         *  {
         *      MessageAckServer.WriteError(stream, MessageState.UnExpectedError, ex);
         *      Netlog.Exception("ExecGet Exception: ", ex, true, true);
         *  }
         *
         * }
         */
        internal NetStream ExecRequset(QItemStream request)
        {
            try
            {
                switch (request.Command)
                {
                case QueueCmd.Enqueue:
                    return(MessageAckServer.DoAck(ExecSet(request), null));

                case QueueCmd.Dequeue:
                case QueueCmd.DequeuePriority:
                case QueueCmd.DequeueItem:
                case QueueCmd.Peek:
                case QueueCmd.PeekPriority:
                case QueueCmd.PeekItem:
                    return(MessageAckServer.DoResponse(ExecGet(request), MessageState.Receiving));

                case QueueCmd.Commit:
                    break;

                case QueueCmd.Abort:
                    break;

                //operation
                case QueueCmd.AddQueue:
                    MQueue mq = null;
                    return(MessageAckServer.DoAck(AddQueue(new QProperties(request.GetBodyStream()), out mq), null));

                case QueueCmd.RemoveQueue:
                    return(MessageAckServer.DoAck(RemoveQueue(request.Destination), null));

                case QueueCmd.HoldEnqueue:
                    throw new Exception("Operation not supported");

                case QueueCmd.NoneHoldEnqueue:
                    throw new Exception("Operation not supported");

                case QueueCmd.HoldDequeue:
                    throw new Exception("Operation not supported");

                case QueueCmd.NoneHoldDequeue:
                    throw new Exception("Operation not supported");

                case QueueCmd.EnableQueue:
                    throw new Exception("Operation not supported");

                case QueueCmd.DisableQueue:
                    throw new Exception("Operation not supported");

                //reports
                case QueueCmd.Exists:
                    return(MessageAckServer.DoAck(Exists(request.Destination), null));

                case QueueCmd.QueueProperty:
                    throw new Exception("Operation not supported");

                case QueueCmd.ReportQueueList:
                    GetQueueList();
                    break;

                case QueueCmd.ReportQueueItems:
                    throw new Exception("Operation not supported");

                case QueueCmd.ReportQueueStatistic:
                    throw new Exception("Operation not supported");

                case QueueCmd.PerformanceCounter:
                    throw new Exception("Operation not supported");

                case QueueCmd.QueueCount:
                    return(MessageAckServer.DoReport(QueueCount(request.Destination), QueueCmd.QueueCount, MessageState.Ok, null));
                }
            }
            catch (MessageException mex)
            {
                Netlog.Exception("ExecGet MessageException: ", mex, true);
                return(MessageAckServer.DoError(mex.MessageState, mex));
            }
            catch (ArgumentException ase)
            {
                Netlog.Exception("ExecGet ArgumentException: ", ase, true, true);
                return(MessageAckServer.DoError(MessageState.ArgumentsError, ase));
            }
            catch (SerializationException se)
            {
                Netlog.Exception("ExecGet SerializationException: ", se, true);
                return(MessageAckServer.DoError(MessageState.SerializeError, se));
            }
            catch (Exception ex)
            {
                Netlog.Exception("ExecGet Exception: ", ex, true, true);
                return(MessageAckServer.DoError(MessageState.UnExpectedError, ex));
            }
            return(null);
        }