public QueueSenderService(IRabbitMQService rabbitMQService, IOptions <RabbitMqSettings> options, IHttpContextAccessor httpContextAccessor,
                           IMapper mapper) : base(mapper)
 {
     _rabbitMQService     = rabbitMQService;
     _rabbitMqSettings    = options.Value;
     _httpContextAccessor = httpContextAccessor;
 }
Exemple #2
0
 public Service(IEmailService emailService,
                IIdentityService identityService,
                IRabbitMQService rabbitMQService,
                IAzureBlobService azureBlobService,
                IAnnotationService annotationService,
                IAnswerService answerService,
                IEssayExerciseService essayExerciseService,
                ILogService logService,
                IMultipleChoicesExerciseService multipleChoicesExerciseService,
                IStudentService studentService,
                ITestService testService,
                IMultipleChoicesAnswerService multipleChoicesAnswerService,
                IEssayAnswerService essayAnswerService)
 {
     EmailService                   = emailService;
     IdentityService                = identityService;
     RabbitMQService                = rabbitMQService;
     AzureBlobService               = azureBlobService;
     AnnotationService              = annotationService;
     AnswerService                  = answerService;
     EssayExerciseService           = essayExerciseService;
     LogService                     = logService;
     MultipleChoicesExerciseService = multipleChoicesExerciseService;
     StudentService                 = studentService;
     TestService                    = testService;
     EssayAnswerService             = essayAnswerService;
     MultipleChoicesAnswerService   = multipleChoicesAnswerService;
 }
        public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            ParameterInfo            parameter = context.Parameter;
            RabbitMQTriggerAttribute attribute = parameter.GetCustomAttribute <RabbitMQTriggerAttribute>(inherit: false);

            if (attribute == null)
            {
                return(Task.FromResult <ITriggerBinding>(null));
            }

            string queueName = Resolve(attribute.QueueName);

            string hostName = Resolve(attribute.HostName);

            ushort batchNumber = attribute.BatchNumber;

            IRabbitMQService service = _provider.GetService(hostName, queueName);

            return(Task.FromResult <ITriggerBinding>(new RabbitMQTriggerBinding(service, hostName, queueName, batchNumber)));
        }
Exemple #4
0
 public RabbitMQListener(ITriggeredFunctionExecutor executor, IRabbitMQService service, string queueName, ushort batchNumber)
 {
     _executor    = executor;
     _service     = service;
     _queueName   = queueName;
     _batchNumber = batchNumber;
 }
 public RabbitMQTriggerBinding(IRabbitMQService service, string hostname, string queueName, ushort batchNumber)
 {
     _service            = service;
     _queueName          = queueName;
     _hostName           = hostname;
     _batchNumber        = batchNumber;
     BindingDataContract = CreateBindingDataContract();
 }
 public EmployeeService(IEmployeeRepository employee, IAccountRepository accountRepository, IDepartmentRepository departmentRepository, IRabbitMQService rabbitMQService, IMapper mapper)
 {
     this.employeeRepository   = employee;
     this.departmentRepository = departmentRepository;
     this.accountRepository    = accountRepository;
     this.rabbitMQService      = rabbitMQService;
     this.mapper = mapper;
 }
Exemple #7
0
 public EmailMessageHandler(
     ILogger <EmailMessageHandler> logger,
     IMailBox mailBox,
     IRabbitMQService rabbitMQService)
 {
     MailBox          = mailBox;
     _logger          = logger;
     _rabbitMQService = rabbitMQService;
 }
Exemple #8
0
 public MailService(
     IElasticSearchService <T> elasticSearchService,
     IRabbitMQService <T> rabbitMqService,
     IMailHelper <MailRequest> mailHelper)
 {
     this.elasticSearchService = elasticSearchService;
     this.rabbitMqService      = rabbitMqService;
     this.mailHelper           = mailHelper;
 }
 public TestUpdateService(
     IHtmlConverterService htmlConverterService,
     IRabbitMQService rabbitMQService,
     IMailAnalyzeService mailAnalyzeService)
 {
     _htmlConverterService = htmlConverterService;
     _rabbitMQService      = rabbitMQService;
     _mailAnalyzeService   = mailAnalyzeService;
 }
Exemple #10
0
 public RabbitMQTriggerBinding(IRabbitMQService service, string hostname, string queueName, ILogger logger, Type parameterType, ushort prefetchCount)
 {
     _service            = service;
     _queueName          = queueName;
     _hostName           = hostname;
     _logger             = logger;
     _parameterType      = parameterType;
     _prefetchCount      = prefetchCount;
     BindingDataContract = CreateBindingDataContract();
 }
Exemple #11
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="transactionContext">Контекст транзакций.</param>
        /// <param name="mapper">Экземпляр автомаппера.</param>
        /// <param name="rabbitService">Сервис брокера сообщений.</param>
        public TransactionService(TransactionContext transactionContext,
                                  IMapper mapper,
                                  IRabbitMQService rabbitService)
        {
            _transactionContext = transactionContext ?? throw new ArgumentException(nameof(transactionContext));
            _mapper             = mapper ?? throw new ArgumentException(nameof(mapper));
            _rabbitService      = rabbitService ?? throw new ArgumentException(nameof(rabbitService));

            _rabbitService.ConfigureServiceDefault();
        }
 public ConsumerManager(
     IRabbitMQService rabbitMQServices,
     IMailSender mailSender,
     IObjectConvertFormat objectConvertFormat
     )
 {
     _rabbitMQServices    = rabbitMQServices;
     _mailSender          = mailSender ?? throw new ArgumentNullException(nameof(mailSender));
     _objectConvertFormat = objectConvertFormat;
 }
Exemple #13
0
 public etlController(IDiscoverItemService iDiscoverItemService, IRepositoriesConfigService iRepositoriesConfigService, IShapesConfigService iShapeConfigService, ConfigSparql configSparql, CallOAIPMH callOAIPMH, CallConversor callConversor, ConfigUrlService configUrlService, IRabbitMQService amqpService)
 {
     _discoverItemService       = iDiscoverItemService;
     _repositoriesConfigService = iRepositoriesConfigService;
     _shapeConfigService        = iShapeConfigService;
     _configSparql     = configSparql;
     _callOAIPMH       = callOAIPMH;
     _callConversor    = callConversor;
     _configUrlService = configUrlService;
     _amqpService      = amqpService;
 }
 public DepartmentService(
     IDepartmentRepository departmentRepository,
     IEmployeeRepository employeeRepository,
     IRabbitMQService rabbitMQService,
     IMapper mapper)
 {
     this.departmentRepository = departmentRepository;
     this.employeeRepository   = employeeRepository;
     this.rabbitMQService      = rabbitMQService;
     this.mapper = mapper;
 }
Exemple #15
0
 public HomeController(
     ILogger <HomeController> logger,
     UserManager <ChatRoomUser> userManager,
     ApplicationDbContext context,
     IRabbitMQService mQService)
 {
     _logger      = logger;
     _userManager = userManager;
     _context     = context;
     _mQService   = mQService;
 }
Exemple #16
0
 public Receiver(
     IRabbitMQService rabbitMQServices,
     IRabbitMQConfiguration rabbitMQConfiguration,
     IMailSender mailSender,
     IObjectConvertFormat objectConvertFormat
     )
 {
     _rabbitMQServices      = rabbitMQServices;
     _rabbitMQConfiguration = rabbitMQConfiguration;
     _mailSender            = mailSender ?? throw new ArgumentNullException(nameof(mailSender));
     _objectConvertFormat   = objectConvertFormat;
 }
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="profileContext">контекст.</param>
        /// <param name="mapper">профиль AutoMapper.</param>
        /// <param name="rabbitService">Сервис брокера сообщений.</param>
        /// /// <param name="scopeFactory">Фабрика для создания объектов IServiceScope.</param>
        public ProfileService(ProfileContext profileContext,
                              IMapper mapper,
                              IRabbitMQService rabbitService,
                              IServiceScopeFactory scopeFactory)
        {
            _profileContext = profileContext ?? throw new ArgumentException(nameof(profileContext));
            _mapper         = mapper ?? throw new ArgumentException(nameof(mapper));
            _rabbitService  = rabbitService ?? throw new ArgumentException(nameof(rabbitService));
            _scopeFactory   = scopeFactory ?? throw new ArgumentException(nameof(scopeFactory));

            _rabbitService.ConfigureServiceDefault();
            _rabbitService.SetListener("ProfileAPI", OnIncomingMessage);
        }
Exemple #18
0
 public TodosController(
     ITodoItemService todoItemService,
     IRabbitMQService rabbitMQService,
     ISolrService solrService,
     IOptions <TodoSettings> config,
     IHostingEnvironment env,
     IHttpClientFactory clientFactory)
 {
     _todoItemService = todoItemService;
     _rabbitMQService = rabbitMQService;
     _solrService     = solrService;
     _config          = config;
     _env             = env;
     _clientFactory   = clientFactory;
 }
 public ProductService(
     IRepository <Product> productRepository,
     IRepository <ExchangeType> exchangeTypeRepository,
     IMapper mapper,
     DevnotContext devnotContext,
     IRedisCacheService redisCacheManager,
     IRabbitMQService rabbitMQService
     )
 {
     _productRepository      = productRepository;
     _exchangeTypeRepository = exchangeTypeRepository;
     _mapper            = mapper;
     _devnotContext     = devnotContext;
     _redisCacheManager = redisCacheManager;
     _rabbitMQService   = rabbitMQService;
 }
        private IModel CreateModelFromAttribute(RabbitMQAttribute attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            string resolvedConnectionString = Utility.FirstOrDefault(attribute.ConnectionStringSetting, _options.Value.ConnectionString);
            string resolvedHostName         = Utility.FirstOrDefault(attribute.HostName, _options.Value.HostName);
            string resolvedUserName         = Utility.FirstOrDefault(attribute.UserName, _options.Value.UserName);
            string resolvedPassword         = Utility.FirstOrDefault(attribute.Password, _options.Value.Password);
            int    resolvedPort             = Utility.FirstOrDefault(attribute.Port, _options.Value.Port);

            IRabbitMQService service = _configProvider.GetService(resolvedConnectionString, resolvedHostName, resolvedUserName, resolvedPassword, resolvedPort);

            return(service.Model);
        }
 public RabbitMQListener(
     ITriggeredFunctionExecutor executor,
     IRabbitMQService service,
     string queueName,
     ILogger logger,
     FunctionDescriptor functionDescriptor,
     ushort prefetchCount)
 {
     _executor               = executor;
     _service                = service;
     _queueName              = queueName;
     _logger                 = logger;
     _rabbitMQModel          = _service.RabbitMQModel;
     _functionDescriptor     = functionDescriptor ?? throw new ArgumentNullException(nameof(functionDescriptor));
     _functionId             = functionDescriptor.Id;
     _scaleMonitorDescriptor = new ScaleMonitorDescriptor($"{_functionId}-RabbitMQTrigger-{_queueName}".ToLower());
     _prefetchCount          = prefetchCount;
 }
        public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            ParameterInfo            parameter = context.Parameter;
            RabbitMQTriggerAttribute attribute = parameter.GetCustomAttribute <RabbitMQTriggerAttribute>(inherit: false);

            if (attribute == null)
            {
                return(Task.FromResult <ITriggerBinding>(null));
            }

            string connectionString = Utility.ResolveConnectionString(attribute.ConnectionStringSetting, _options.Value.ConnectionString, _configuration);

            string queueName = Resolve(attribute.QueueName) ?? throw new InvalidOperationException("RabbitMQ queue name is missing");

            string hostName = Resolve(attribute.HostName) ?? Constants.LocalHost;

            string userName = Resolve(attribute.UserNameSetting);

            string password = Resolve(attribute.PasswordSetting);

            string deadLetterExchangeName = Resolve(attribute.DeadLetterExchangeName) ?? string.Empty;

            int port = attribute.Port;

            if (string.IsNullOrEmpty(connectionString) && !Utility.ValidateUserNamePassword(userName, password, hostName))
            {
                throw new InvalidOperationException("RabbitMQ username and password required if not connecting to localhost");
            }

            // If there's no specified batch number, default to 1
            ushort batchNumber = 1;

            IRabbitMQService service = _provider.GetService(connectionString, hostName, queueName, userName, password, port, deadLetterExchangeName);

            return(Task.FromResult <ITriggerBinding>(new RabbitMQTriggerBinding(service, hostName, queueName, batchNumber, _logger)));
        }
        static void Main(string[] args)
        {
            var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();

            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <IConfiguration>(configuration)
                                  .AddSingleton <IRabbitMQService, RabbitMQService>()
                                  .AddLogging()
                                  .BuildServiceProvider();

            RabbitMQService = serviceProvider.GetService <IRabbitMQService>();

            Parallel.Invoke(() =>
            {
                Task.Run(() => ReceiveMessages());
                Task.Run(() => ProduceMessages());
            });

            Console.WriteLine("Test is finished");
            Console.ReadLine();
        }
        public void RegisterSignalRWithRabbitMQ(IRabbitMQService service)
        {
            // var factory = new ConnectionFactory() { HostName = "localhost"  };
            // using (var connection = factory.CreateConnection())
            // {
            //     using (var channel = connection.CreateModel())
            //     {
            //         channel.QueueDeclare(queue: "TestQueue",
            //         durable: false,
            //         autoDelete: false,
            //         exclusive: false,
            //         arguments: null
            //         );

            //         var consumer = new EventingBasicConsumer(channel);
            //         consumer.Received += (model, ea) =>
            //         {
            //               var body = ea.Body.ToArray();
            //               var message = Encoding.UTF8.GetString(body);
            //             // Console.WriteLine(" [x] Received {0}", message);
            //         };



            //         channel.BasicConsume(queue: "TestQueue",
            //         autoAck : true,
            //         consumer: consumer);

            //         //Console.WriteLine(" Press any key to exit ");
            //         //Console.ReadKey();

            //     }
            // }
            // Connect to RabbitMQ
            var rabbitMQService = service;

            rabbitMQService.Connect();
        }
        internal RabbitMQContext CreateContext(RabbitMQAttribute attribute)
        {
            string           hostname   = Utility.FirstOrDefault(attribute.HostName, _options.Value.HostName);
            string           queuename  = Utility.FirstOrDefault(attribute.QueueName, _options.Value.QueueName);
            string           exchange   = Utility.FirstOrDefault(attribute.Exchange, _options.Value.Exchange) ?? string.Empty;
            IBasicProperties properties = attribute.Properties;

            var resolvedAttribute = new RabbitMQAttribute
            {
                HostName   = hostname,
                QueueName  = queuename,
                Exchange   = exchange,
                Properties = properties,
            };

            IRabbitMQService service = GetService(hostname, queuename);

            return(new RabbitMQContext
            {
                ResolvedAttribute = resolvedAttribute,
                Service = service,
            });
        }
Exemple #26
0
 /// <summary>
 /// Connstrutor com Service para adicionar processo em Fila e Cache Distribuido
 /// </summary>
 /// <param name="contexto">contexto da base de dados</param>
 /// <param name="rabbitMqService">Interface RabbitMQ</param>
 /// <param name="cache">Interface Cache Distribuido</param>
 public ARepositorio(TContexto contexto, IRabbitMQService rabbitMqService, IDistributedCache cache)
 {
     _contexto        = contexto;
     _rabbitMqService = rabbitMqService;
     _cache           = cache;
 }
Exemple #27
0
 /// <summary>
 /// Connstrutor com Service para adicionar processo em Fila
 /// </summary>
 /// <param name="contexto">contexto da base de dados</param>
 /// <param name="rabbitMqService">Interface RabbitMQ</param>
 public ARepositorio(TContexto contexto, IRabbitMQService rabbitMqService)
 {
     _contexto        = contexto;
     _rabbitMqService = rabbitMqService;
 }
Exemple #28
0
 public BackgroundTask(ILogger <BackgroundTask> logger, IRabbitMQService rabbitMQService)
 {
     _logger          = logger;
     _rabbitMQService = rabbitMQService;
 }
Exemple #29
0
 public KeysController(IRabbitMQService rabbitMQService)
 {
     _rabbitMQService = rabbitMQService;
 }
Exemple #30
0
 public MessageController(IUnitOfWork <MangoDbContext> unitOfWork, IRabbitMQService rabbitMQService)
 {
     _unitOfWork      = unitOfWork;
     _rabbitMQService = rabbitMQService;
 }