コード例 #1
0
 internal RabbitMqMiddleWare(RabbitMissionConfig config)
 {
     _serializer = SerializerFactory.Create(config.SerializerType);
     _config     = config;
     _factory    = new ConnectionFactory {
         Uri = new Uri(config.Uri)
     };
 }
コード例 #2
0
        /// <summary>
        /// 使用rabbitmq,针对同一服务,只允许调用一次
        /// </summary>
        /// <param name="server"></param>
        /// <param name="config">rabbitmq配置</param>
        /// <param name="logger"></param>
        /// <returns></returns>
        public static IMissionServer UseRabbit(this IMissionServer server, RabbitMissionConfig config, ILogger logger = null)
        {
            var middleWare = new RabbitMqMiddleWare(config);
            var serializer = SerializerFactory.Create(config.SerializerType);

            server.UseMiddleWare(middleWare, serializer, logger);
            return(server);
        }
コード例 #3
0
        /// <summary>
        /// 使用rabbitmq,针对同一客户端,只允许调用一次
        /// </summary>
        /// <param name="client"></param>
        /// <param name="config">rabbitmq配置</param>
        /// <param name="logger"></param>
        /// <returns></returns>
        public static IMissionClient UseRabbit(this IMissionClient client, RabbitMissionConfig config, ILogger logger = null)
        {
            var middleWare = new RabbitMqMiddleWare(config);
            var serializer = SerializerFactory.Create(config.SerializerType);

            client.UseMiddleWare(middleWare, serializer, logger);
            client.UseHttpClient(config.ServerHost);
            client.StartSubscribe();
            return(client);
        }