Exemplo n.º 1
0
        public ChannelProcessResult ProcessSubscriberMessage(MessagePackage message)
        {
            if (MessageEntryHelper.MatchEntryCriteria(_param, message, _config.EntryControl))
            {
                if (_pipeLine.Process(message))
                {
                    string  msgXml = message.GetMessageXml();
                    Message msg    = XObjectManager.CreateObject <Message>(msgXml);
                    if (msg == null)
                    {
                        return(ChannelProcessResult.ProcessingError);
                    }

                    msg.Header.ID   = Guid.NewGuid();
                    msg.Header.Type = _config.PublishMessageType;

                    if (_param.Sender.NotifyMessagePublish(msg))
                    {
                        return(ChannelProcessResult.Success);
                    }
                    else
                    {
                        return(ChannelProcessResult.SendingError);
                    }
                }
                else
                {
                    return(ChannelProcessResult.ProcessingError);
                }
            }
            else
            {
                return(ChannelProcessResult.NotMatchEntryCriteria);
            }
        }
Exemplo n.º 2
0
        public ChannelProcessResult ProcessResponserMessage(MessagePackage request, out MessagePackage response)
        {
            response = null;

            if (MessageEntryHelper.MatchEntryCriteria(_param, request, _config.EntryControl))
            {
                if (_pipeLineReq.Process(request))
                {
                    string  reqXml = request.GetMessageXml();
                    Message reqMsg = XObjectManager.CreateObject <Message>(reqXml);
                    if (reqMsg == null)
                    {
                        return(ChannelProcessResult.ProcessingError);
                    }

                    reqMsg.Header.ID   = Guid.NewGuid();
                    reqMsg.Header.Type = _config.RequestMessageTypePair.RequestMessageType;

                    Message rspMsg = null;
                    if (_param.Sender.NotifyMessageRequest(reqMsg, out rspMsg) &&
                        rspMsg != null && rspMsg.Header != null)
                    {
                        if (!_config.RequestMessageTypePair.ResponseMessageType.EqualsTo(rspMsg.Header.Type))
                        {
                            _param.Log.Write(LogType.Error,
                                             "Receiving response message is not the type of :"
                                             + _config.RequestMessageTypePair.ResponseMessageType.ToString());
                            return(ChannelProcessResult.SendingError);
                        }

                        rspMsg.Header.ID   = Guid.NewGuid();
                        rspMsg.Header.Type = _config.ResponseMessageType;

                        string rspXml = rspMsg.ToXMLString();
                        response = new MessagePackage(rspMsg, rspXml);
                        response.Accept(_param.ChannelName);

                        if (_pipeLineRsp.Process(response))
                        {
                            return(ChannelProcessResult.Success);
                        }
                        else
                        {
                            return(ChannelProcessResult.ProcessingError);
                        }
                    }
                    else
                    {
                        return(ChannelProcessResult.SendingError);
                    }
                }
                else
                {
                    return(ChannelProcessResult.ProcessingError);
                }
            }
            else
            {
                return(ChannelProcessResult.NotMatchEntryCriteria);
            }
        }