Beispiel #1
0
        public override bool Initialize()
        {
            try
            {
                _host     = new RPCServiceHost(typeof(RPCPullService));
                _host.Tag = this;

                switch (Channel.ProtocolType)
                {
                case ProtocolType.RPC_NamedPipe:
                    _host.AddServiceEndpoint("HYS.IM.Messaging.Queuing.RPC.IRPCPullService",
                                             new NetNamedPipeBinding(), Channel.RPCConfig.URI);
                    break;

                case ProtocolType.RPC_TCP:
                    _host.AddServiceEndpoint("HYS.IM.Messaging.Queuing.RPC.IRPCPullService",
                                             new NetTcpBinding(), Channel.RPCConfig.URI);
                    break;

                case ProtocolType.RPC_SOAP:
                    _host.AddServiceEndpoint("HYS.IM.Messaging.Queuing.RPC.IRPCPullService",
                                             new BasicHttpBinding(), Channel.RPCConfig.URI);
                    break;
                }

                _log.Write("RPCPullReceiver initialize succeeded. " + Channel.RPCConfig.URI);
                return(true);
            }
            catch (Exception err)
            {
                _log.Write(err);
                return(false);
            }
        }
Beispiel #2
0
        public bool ProcessMessage(string request, out string response)
        {
            // these exception should be handled in programming/unit-test time,
            // therefore do not need to write to log.

            RPCServiceHost host = OperationContext.Current.Host as RPCServiceHost;

            if (host == null)
            {
                throw new ArithmeticException("Cannot find RPCServiceHost in current operation context.");
            }

            RPCPullReceiver receiver = host.Tag as RPCPullReceiver;

            if (receiver == null)
            {
                throw new ArithmeticException("Cannot find RPCPullReceiver in current operation context.");
            }

            return(receiver.ProcessMessage(request, out response));
        }