public FileServiceInternal(IMessageProducer _mqp, IMessageQueueClient _mqc, IEbServerEventClient _sec) : base(_mqp, _mqc, _sec) { MqResponse = new EbMqResponse() { ReqType = this.GetType().ToString() }; }
public BaseService(IEbConnectionFactory _dbf, IMessageProducer _msp, IMessageQueueClient _mqc, IEbServerEventClient _sec) { this.EbConnectionFactory = _dbf as EbConnectionFactory; this.MessageProducer3 = _msp as RabbitMqProducer; this.MessageQueueClient = _mqc as RabbitMqQueueClient; this.ServerEventClient = _sec as EbServerEventClient; }
public int ProcessQueue(IMessageQueueClient mqClient, string queueName, Func <bool> doNext = null) { var msgsProcessed = 0; try { byte[] messageBytes; while ((messageBytes = mqClient.GetAsync(queueName)) != null) { var message = messageBytes.ToMessage <T>(); ProcessMessage(mqClient, message); this.TotalNormalMessagesReceived++; msgsProcessed++; if (doNext != null && !doNext()) { return(msgsProcessed); } } } catch (Exception ex) { var lastEx = ex; Log.Error("Error serializing message from mq server: " + lastEx.Message, ex); } return(msgsProcessed); }
protected MessageSender(IMessageQueueClient messageQueueClient, string defaultTopic = null) { MessageQueueClient = messageQueueClient; DefaultTopic = defaultTopic; MessageStateQueue = new BlockingCollection <MessageState>(); Logger = ObjectProviderFactory.GetService <ILoggerFactory>().CreateLogger(GetType()); }
public ServiceBusMqWorker(ServiceBusMqMessageFactory mqMessageFactory, IMessageQueueClient mqClient, string queueName, QueueClient sbClient) { this.mqMessageFactory = mqMessageFactory; this.queueName = queueName; this.mqClient = mqClient; this.sbClient = sbClient; }
public EbBaseService(IEbConnectionFactory _dbf, IMessageProducer _mqp, IMessageQueueClient _mqc, IEbMqClient _mq) { this.EbConnectionFactory = _dbf as EbConnectionFactory; this.MessageProducer3 = _mqp as RabbitMqProducer; this.MessageQueueClient = _mqc as RabbitMqQueueClient; this.MQClient = _mq as EbMqClient; }
public override void HandleThisMessage(IMessage mqMessage, IMessageQueueClient client) { if (!(mqMessage.Body is StartRentalCommand m)) { return; } var film = InfraHelper.GetFilm(m.FilmId); if (!film.IsAvailable) { return; } client.Publish(new CalculatePriceCommand { UserId = m.UserId, FilmId = m.FilmId, Type = film.Type, UseBonuses = m.UseBonuses, ActiveTo = m.ActiveTo, ActiveFrom = m.ActiveFrom, OrderId = m.OrderId }); client.Publish(new SetFilmUnavailableCommand { FilmId = m.FilmId }); }
public HealthStatusController(IMailClient mailClient, IMessageQueueClient messageQueueClient, IElasticsearchRepository repository) : this() { MailClient = mailClient; MessageQueueClient = messageQueueClient; Repository = repository; }
public int ProcessQueue(IMessageQueueClient mqClient, string queueName, Func <bool> doNext = null) { var msgsProcessed = 0; try { IMessage <T> message; while ((message = mqClient.GetAsync <T>(queueName)) != null) { ProcessMessage(mqClient, message); msgsProcessed++; if (doNext != null && !doNext()) { return(msgsProcessed); } } } catch (Exception ex) { Log.Error("Error serializing message from mq server: " + ex.Message, ex); } return(msgsProcessed); }
public MessageSender(IMessageQueueClient messageQueueClient, string defaultTopic = null) { _messageQueueClient = messageQueueClient; _defaultTopic = defaultTopic; _messageQueue = new BlockingCollection<IMessageContext>(); _logger = IoCFactory.Resolve<ILoggerFactory>().Create(this.GetType()); }
public HealthStatusController(IMailClient mailClient, IMessageQueueClient messageQueueClient, IElasticsearchRepository repository) : this() { MailClient = mailClient; MessageQueueClient = messageQueueClient; Repository = repository; }
private static void Publish_4_Rot13_messages(IMessageQueueClient mqClient) { mqClient.Publish(new Rot13 { Value = "Hello" }); mqClient.Publish(new Rot13 { Value = "World" }); mqClient.Publish(new Rot13 { Value = "ServiceStack" }); mqClient.Publish(new Rot13 { Value = "Redis" }); }
public void Process(IMessageQueueClient mqClient) { foreach (var processQueueName in ProcessQueueNames) { ProcessQueue(mqClient, processQueueName); } }
private static void Publish_4_messages(IMessageQueueClient mqClient) { mqClient.Publish(new Reverse { Value = "Hello" }); mqClient.Publish(new Reverse { Value = "World" }); mqClient.Publish(new Reverse { Value = "NServiceKit" }); mqClient.Publish(new Reverse { Value = "Redis" }); }
public void Process(IMessageQueueClient mqClient) { try { bool hadReceivedMessages; do { hadReceivedMessages = false; byte[] messageBytes; while ((messageBytes = mqClient.GetAsync(QueueNames <T> .Priority)) != null) { this.TotalPriorityMessagesReceived++; hadReceivedMessages = true; var message = messageBytes.ToMessage <T>(); ProcessMessage(mqClient, message); } while ((messageBytes = mqClient.GetAsync(QueueNames <T> .In)) != null) { this.TotalNormalMessagesReceived++; hadReceivedMessages = true; var message = messageBytes.ToMessage <T>(); ProcessMessage(mqClient, message); } } while (hadReceivedMessages); } catch (Exception ex) { var lastEx = ex; Log.Error("Error serializing message from mq server: " + lastEx.Message, ex); } }
public EventSubscriber(IMessageQueueClient messageQueueClient, IHandlerProvider handlerProvider, ICommandBus commandBus, IMessagePublisher messagePublisher, string subscriptionName, TopicSubscription[] topicSubscriptions, string consumerId, ConsumerConfig consumerConfig = null) { ConsumerConfig = consumerConfig ?? ConsumerConfig.DefaultConfig; MessageQueueClient = messageQueueClient; HandlerProvider = handlerProvider; _topicSubscriptions = topicSubscriptions ?? new TopicSubscription[0]; _topicSubscriptions.Where(ts => ts.TagFilter != null) .ForEach(ts => { TagFilters.Add(ts.Topic, ts.TagFilter); }); ConsumerId = consumerId; SubscriptionName = subscriptionName; MessagePublisher = messagePublisher; CommandBus = commandBus; var loggerFactory = ObjectProviderFactory.GetService <ILoggerFactory>(); MessageProcessor = new MailboxProcessor(new DefaultProcessingMessageScheduler(), new OptionsWrapper <MailboxOption>(new MailboxOption { BatchCount = ConsumerConfig.MailboxProcessBatchCount }), loggerFactory.CreateLogger <MailboxProcessor>()); Logger = loggerFactory.CreateLogger(GetType().Name); }
public EbBaseNewController(IServiceClient _ssclient, IRedisClient _redis, IMessageQueueClient _mqFactory, IMessageProducer _mqProducer) { this.ServiceClient = _ssclient as JsonServiceClient; this.Redis = _redis as RedisClient; this.RedisMessageQueueClient = _mqFactory as RedisMessageQueueClient; this.RedisMessageProducer = _mqProducer as RedisMessageProducer; }
public override void HandleThisMessage(IMessage mqMessage, IMessageQueueClient client) { if (!(mqMessage.Body is CreateInvoiceCommand m)) { return; } var state = State.GetState(rProxy, m.OrderId); if (!state.HasRentals || state.HasInvoiceAlready) { return; } var userId = state.UserRentals.First().UserId; var user = rProxy.Get <User>(userId); var invoice = FileHelper.CreateInvoice(user, state.UserRentals); rProxy.Set <Invoice>(new Invoice { Id = Guid.NewGuid(), CreatedOn = DateTime.Now, OrderId = m.OrderId, FileBytes = invoice, UserId = userId }); }
private static void Publish_4_Rot13_messages(IMessageQueueClient mqClient) { mqClient.Publish(new Rot13 { Value = "Hello" }); mqClient.Publish(new Rot13 { Value = "World" }); mqClient.Publish(new Rot13 { Value = "ServiceStack" }); mqClient.Publish(new Rot13 { Value = "Redis" }); }
public MessageSender(IMessageQueueClient messageQueueClient, string defaultTopic = null) { _messageQueueClient = messageQueueClient; _defaultTopic = defaultTopic; _messageQueue = new BlockingCollection <IMessageContext>(); _logger = IoCFactory.Resolve <ILoggerFactory>().Create(this.GetType()); }
public ConsumerHostServices(IConfiguration configuration, ISaveData saveData, IHostApplicationLifetime appLifetime, ILogger <ConsumerHostServices> logger) { _logger = logger; _appLifetime = appLifetime; IFactoryClient factory = new FactoryClient(configuration, saveData, _logger); _client = factory.CreateMessageQueue(configuration["MessageQueue:Type"]); }
public MessagePublisher(IMessageQueueClient messageQueueClient, string defaultTopic) : base(messageQueueClient, defaultTopic) { if (string.IsNullOrEmpty(defaultTopic)) { throw new Exception("message sender must have a default topic."); } }
public MessagePublisher(IMessageQueueClient messageQueueClient, string defaultTopic) : base(messageQueueClient, defaultTopic) { if (string.IsNullOrEmpty(defaultTopic)) { throw new Exception("message sender must have a default topic."); } }
public AppUnitOfWork(IEventBus eventBus, ILoggerFactory loggerFactory, IMessagePublisher eventPublisher, IMessageQueueClient messageQueueClient, IMessageStore messageStore) : base(eventBus, loggerFactory, eventPublisher, messageQueueClient, messageStore) { }
public MessageSender(IMessageQueueClient messageQueueClient, string defaultTopic = null) { _messageQueueClient = messageQueueClient; _defaultTopic = defaultTopic; _needMessageStore = Configuration.Instance.NeedMessageStore; _messageStateQueue = new BlockingCollection <MessageState>(); _logger = IoCFactory.IsInit() ? IoCFactory.Resolve <ILoggerFactory>().Create(GetType().Name) : null; }
public override void HandleThisMessage(IMessage mqMessage, IMessageQueueClient client) { if (!(mqMessage.Body is AddFilmCommand m)) { return; } InfraHelper.AddFilm(m.Film); }
private void DisposeMqClient() { //Disposing mqClient causes an EndOfStreamException to be thrown in StartSubscription if (mqClient == null) { return; } mqClient.Dispose(); mqClient = null; }
public void OnRegistered_EventHandler(object Sender, RegMsgQueueData evntData) { Owner = evntData.MsgQueueOwner; if (Owner.Engine == null) { throw new Exception("Engine объекта IMessageQueueClient - еще не зарегистрирован.."); } _serverEngine = Owner.Engine; }
public ResponsiveChannelFriendlyRedisMqClient(RedisMqHost host) { if (host == null) { throw new ArgumentNullException("host"); } _host = host; _innerClient = _host.CreateMessageQueueClient(); }
public RabbitMqPublishtest() { var configMock = new Mock <IOptions <QueuesConfig> >(); configMock.Setup(m => m.Value) .Returns(new QueuesConfig()); _client = new RabbitMqClient(configMock.Object, Mock.Of <IMsgDispatcher>(), Mock.Of <ILogger <IMessageQueueClient> >(), Mock.Of <IMessageSerializer>()); }
public CommandConsumer(IHandlerProvider handlerProvider, IMessagePublisher messagePublisher, string commandQueueName) { _commandQueueName = commandQueueName; _handlerProvider = handlerProvider; _messagePublisher = messagePublisher; _messageQueueClient = IoCFactory.Resolve <IMessageQueueClient>(); _logger = IoCFactory.Resolve <ILoggerFactory>().Create(this.GetType()); }
public CommandConsumer(IHandlerProvider handlerProvider, IMessagePublisher messagePublisher, string commandQueueName) { _commandQueueName = commandQueueName; _handlerProvider = handlerProvider; _messagePublisher = messagePublisher; _messageQueueClient = IoCFactory.Resolve<IMessageQueueClient>(); _logger = IoCFactory.Resolve<ILoggerFactory>().Create(this.GetType()); }
public override void HandleThisMessage(IMessage mqMessage, IMessageQueueClient client) { if (!(mqMessage.Body is SetFilmAvailableCommand m)) { return; } var film = InfraHelper.GetFilm(m.FilmId); film.IsAvailable = true; InfraHelper.UpdateFilm(film); }
public CommandBus(IMessageQueueClient messageQueueClient, ILinearCommandManager linearCommandManager, string[] commandQueueNames, string replyTopicName, string replySubscriptionName) : base(messageQueueClient) { _commandStateQueues = new ConcurrentDictionary <string, MessageState>(); _linearCommandManager = linearCommandManager; _replyTopicName = replyTopicName; _replySubscriptionName = replySubscriptionName; _commandQueueNames = commandQueueNames; }
public AppUnitOfWork(IEventBus eventBus, ILoggerFactory loggerFactory, IMessagePublisher eventPublisher, IMessageQueueClient messageQueueClient, IMessageStore messageStore) : base(eventBus, loggerFactory) { _messageStore = messageStore; _messagePublisher = eventPublisher; _messageQueueClient = messageQueueClient; _eventMessageStates = new List <MessageState>(); _anywayPublishEventMessageStates = new List <MessageState>(); }
public async Task SendMessageAsync <T>(T messageInfo) { try { IFactoryClient factory = new FactoryClient(_configuration); IMessageQueueClient message = factory.CreateMessageQueue(_configuration["MessageQueue:Type"]); await message.SendMessageAsync(messageInfo); } catch (Exception ex) { throw ex; } }
public EventSubscriber(IMessageQueueClient messageQueueClient, IHandlerProvider handlerProvider, ICommandBus commandBus, IMessagePublisher messagePublisher, string subscriptionName, params string[] topics) { _MessageQueueClient = messageQueueClient; _handlerProvider = handlerProvider; _topics = topics; _subscriptionName = subscriptionName; _messagePublisher = messagePublisher; _commandBus = commandBus; _logger = IoCFactory.Resolve<ILoggerFactory>().Create(this.GetType()); }
private void Publish_4_messages(IMessageQueueClient mqClient) { mqClient.Publish(new Reverse { Value = "Hello" }); mqClient.Publish(new Reverse { Value = "World" }); mqClient.Publish(new Reverse { Value = "ServiceStack" }); mqClient.Publish(new Reverse { Value = "Redis" }); }
private void DisposeMqClient() { //Disposing mqClient causes an EndOfStreamException to be thrown in StartSubscription if (mqClient == null) return; mqClient.Dispose(); mqClient = null; }