internal TransStream ExecRequset(IQueueMessage request) { bool responseAck = false; try { if (request.QCommand == QueueCmd.QueueHasValue) { return(MessageAckServer.DoReportValue(QueueCount(request.Host))); } Logger.Debug("QueueController ExecRequset : {0}", request.Print()); switch (request.QCommand) { case QueueCmd.Enqueue: responseAck = true; //MQueue Q = Get(request.Host); var ack = ExecSet((QueueItem)request); return(MessageAckServer.DoResponse(ack)); 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: responseAck = true; MQueue mq = null; return(MessageAckServer.DoResponse(AddQueue(new QProperties(request.BodyStream), out mq))); case QueueCmd.RemoveQueue: responseAck = true; return(MessageAckServer.DoResponse(RemoveQueue(request.Host))); 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"); case QueueCmd.ClearQueue: throw new Exception("Operation not supported"); //reports case QueueCmd.Exists: responseAck = true; return(MessageAckServer.DoResponse(Exists(request.Host))); case QueueCmd.ReportQueueList: var list = GetQueueList(); return(new TransStream(list)); case QueueCmd.QueueProperty: case QueueCmd.ReportQueueItems: return(ExecQuery(request)); case QueueCmd.ReportQueueStatistic: return(GetQueueReport(request)); //throw new Exception("Operation not supported"); case QueueCmd.PerformanceCounter: throw new Exception("Operation not supported"); case QueueCmd.QueueCount: return(MessageAckServer.DoReport(QueueCount(request.Host), QueueCmd.QueueCount, MessageState.Ok, null)); } } catch (MessageException mex) { Logger.Exception("ExecGet MessageException: ", mex, true); return(MessageAckServer.DoError(mex.MessageState, request, responseAck, mex)); } catch (ArgumentException ase) { Logger.Exception("ExecGet ArgumentException: ", ase, true, true); return(MessageAckServer.DoError(MessageState.ArgumentsError, request, responseAck, ase)); } catch (SerializationException se) { Logger.Exception("ExecGet SerializationException: ", se, true); return(MessageAckServer.DoError(MessageState.SerializeError, request, responseAck, se)); } catch (Exception ex) { Logger.Exception("ExecGet Exception: ", ex, true, true); return(MessageAckServer.DoError(MessageState.UnExpectedError, request, responseAck, ex)); } return(null); }
/* * 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); }