Esempio n. 1
0
        /// <summary>
        /// Here we do initial processing of requestData.
        /// <para>Processing of requestData can be passed to another object. Both for local and global messaging. Currenlty all processing is done in Entity. 
        /// Entity uses Addresses to register in RMQ.
        /// </para>        
        /// <para> Override this function to provide other threading models and remeber that this function is executed in the RMQ driver thread- switch ASAP.</para>
        public virtual void OnPreMessage(RequestData requestData)
        {
            //now everything is dispatched in thread pool
            ThreadPool.QueueUserWorkItem((r) =>
            {
                //try release pending rpc
                if (Bus.TryHandleAsRPCResponse(this, requestData))
                    return;

                try
                {
                    OnMessage(requestData);
                }
                catch (Exception ex)
                {
                    //todo: log it
                    //make sure that ack and RPC response (if necessary) is sent back
                    requestData.RPCResponse(1, RequestData.ErrorCodeEnum.InternalError, ex.Message, null, null);
                }
                finally
                {
                    //default response
                    requestData.RPCResponse(RequestData.ErrorCodeEnum.Error, "default response");
                }
            });
        }