Example #1
0
        public static RpcServer GetDefault(string mqAddress, IList <string> routeKeyList, string applicationId)
        {
            DistributedMQConfig distributedMQConfig = new DistributedMQConfig
            {
                ServerAddress = mqAddress,
                Exchange      = "RPC_EXCHANGE",
                MsgSendType   = MessageSendType.Router,
                IsDurable     = false
            };
            RpcServer server = new RpcServer(distributedMQConfig, routeKeyList, applicationId);

            return(server);
        }
Example #2
0
        public static IMessageQueue Create(DistributedMQConfig distributedMQConfig, MessageQueueTypeEnum messageQueueTypeEnum = 0, IList <string> routeKeyList = null, string applicationId = null)
        {
            IMqFactory mqFactory = null;

            switch (messageQueueTypeEnum)
            {
            case MessageQueueTypeEnum.RabbitMq:
            {
                mqFactory = new RabbitMQ.Factory.RabbitMqFactory(distributedMQConfig, applicationId, routeKeyList);
            }; break;
                // return new RouterMQ(distributedMQConfig,applicationId, routeKeyList);
            }
            return(mqFactory.CreateRabbitFactory());
        }
Example #3
0
        public SimpleMQ(DistributedMQConfig mqConfig, string applicationId = null) : base(mqConfig)
        {
            this._encoding = mqConfig.DefaultEncoding;
            ConnectionFactory factory1 = new ConnectionFactory();

            factory1.AutomaticRecoveryEnabled = true;
            factory1.TopologyRecoveryEnabled  = true;
            factory1.Uri = new Uri(mqConfig.ServerAddress);
            ConnectionFactory factory = factory1;

            this._ApplicationCode = applicationId;
            this._queue           = base.MQConfig.ProducerID;
            _connection           = factory.CreateConnection(mqConfig.Name);
            this.CreateMQ(null);
        }
Example #4
0
        public RpcServer StartServer()
        {
            DistributedMQConfig distributedMQConfig = new DistributedMQConfig
            {
                ServerAddress = this.MqRpcConfig.MqAddress,
                Exchange      = this.MqRpcConfig.Exchange,
                ProducerID    = GetCurrentServerRpcName(),
                MsgSendType   = MessageSendType.Router,
                IsDurable     = false
            };
            var       routeKeyList = IocUnity.Get <DefaultRegisterService>().GetRouteKeyList();
            RpcServer server       = new RpcServer(distributedMQConfig, routeKeyList, null);

            server.ReciveMsgedEvent -= new ReciveMQMessageHandler(RpcServer_ReciveMsgedEvent);
            server.ReciveMsgedEvent += new ReciveMQMessageHandler(RpcServer_ReciveMsgedEvent);
            CurrentRpcServer         = server;
            return(server);
        }
Example #5
0
 public RpcServer(DistributedMQConfig distributedMQConfig, IList <string> routeKeyList, string applicationId) : base(distributedMQConfig)
 {
     this.MQConfig = distributedMQConfig;
     this.MsgQueue = MQFactory.Create(distributedMQConfig, MessageQueueTypeEnum.RabbitMq, routeKeyList, applicationId);
     this.MsgQueue.ReceiveMQ(delegate(MQMessage msg) {
         if ((msg != null) && (msg.Response != null))
         {
             MQMsgRequest request1 = new MQMsgRequest {
                 Exchange        = msg.Response.Exchange,
                 RequestRouteKey = msg.Response.ResponseRouteKey
             };
             msg.Request  = request1;
             msg.Response = null;
         }
         if (this.ReciveMsgedEvent != null)
         {
             this.ReciveMsgedEvent(msg);
         }
     });
 }
Example #6
0
        public RpcClient(DistributedMQConfig distributedMQConfig, MQMsgRequest mQMsgRequest = null, string applicationId = null) : base(distributedMQConfig)
        {
            this.ApplicationId = applicationId;
            this.MQConfig      = distributedMQConfig;
            this.MsgQueue      = MQFactory.Create(this.MQConfig, MessageQueueTypeEnum.RabbitMq, null, applicationId);

            if (!string.IsNullOrEmpty(this.MQConfig.ProducerID))
            {
                this.MsgQueue.DeleteMQ(this.MQConfig.ProducerID, true, true);
            }

            string str = IdentityHelper.NewSequentialGuid().ToString("N");

            if (string.IsNullOrEmpty(this.MQConfig.Exchange))
            {
                this.MQConfig.Exchange = MQDefaultSetting._Exchange;
            }
            MQMsgResponse response1 = new MQMsgResponse
            {
                Exchange         = this.MQConfig.Exchange,
                ResponseQueue    = MQDefaultSetting._prefixQueue + "-" + str,
                ResponseRouteKey = str
            };

            this._mQMsgResponse = response1;
            if (mQMsgRequest == null)
            {
                MQMsgRequest request1 = new MQMsgRequest
                {
                    Exchange        = this.MQConfig.Exchange,
                    RequestRouteKey = MQDefaultSetting._RequestRouteKey
                };
                this._mQMsgRequest = request1;
            }
            else
            {
                this._mQMsgRequest = mQMsgRequest;
            }
        }
Example #7
0
 public override IMessageQueue CreateInstance(DistributedMQConfig mqConfig) =>
 new RouterMQ(mqConfig, null);
Example #8
0
 public IMessageQueue CreateInstance(DistributedMQConfig mqConfig)
 {
     throw new NotImplementedException();
 }
Example #9
0
 public RabbitMqFactory(DistributedMQConfig mQConfig, string applicationId, IList <string> routeKeyList)
 {
     this.MqConfig      = mQConfig;
     this.ApplicationId = applicationId;
     this.RouteKeyList  = routeKeyList;
 }
Example #10
0
 public abstract IMessageQueue CreateInstance(DistributedMQConfig mqConfig);
Example #11
0
 protected MessageQueueBase(DistributedMQConfig mqConfig)
 {
     this.mQConfig = mqConfig;
 }
Example #12
0
 protected RocketMqMessageQueue(DistributedMQConfig mqConfig) : base(mqConfig)
 {
 }
Example #13
0
 public RpcBase(DistributedMQConfig distributedMQConfig)
 {
     this.MQConfig = distributedMQConfig;
 }