public void Publish(string topic, IRemoteEventData eventData) { _eventBus.Trigger(this, new RemoteEventBusPublishingEvent(eventData)); _publisher.Publish(topic, eventData); _logger.LogDebug($"Event published on topic {topic}"); _eventBus.Trigger(this, new RemoteEventBusPublishedEvent(eventData)); }
public Task PublishAsync(string topic, IRemoteEventData remoteEventData) { return(Task.Factory.StartNew(() => { Publish(topic, remoteEventData); })); }
public RemoteEventArgs(IRemoteEventData eventData, string topic, string message) { EventData = eventData; Message = message; Topic = topic; ReportedTime = DateTime.Now.ToString("yyyyMMddHHmmss"); }
public Task PublishAsync(IRemoteEventData remoteEventData) { return(Task.Factory.StartNew(() => { Publish(remoteEventData); })); }
public RemoteEventArgs(IRemoteEventData eventData, string topic, string message) { EventData = eventData; Message = message; Topic = topic; EventTime = DateTime.Now; }
public Task PublishAsync(string topic, IRemoteEventData remoteEventData) { Logger.Debug($"{_producer.Name} producing on {topic}"); var deliveryReport = _producer.ProduceAsync(topic, null, _remoteEventSerializer.Serialize(remoteEventData)); return(deliveryReport.ContinueWith(task => { Logger.Debug($"Partition: {task.Result.Partition}, Offset: {task.Result.Offset}"); })); }
public async Task PublishAsync(string topic, IRemoteEventData eventData) { await _eventBus.TriggerAsync(this, new RemoteEventBusPublishingEvent(eventData)); await _publisher.PublishAsync(topic, eventData) .ContinueWith((s) => _logger.LogDebug($"Event published on topic {topic}")); await _eventBus.TriggerAsync(this, new RemoteEventBusPublishedEvent(eventData)); await Task.FromResult(0); }
public string SelectTopic(IRemoteEventData eventData) { if (eventData is IHasTopicRemoteEventData) { return((eventData as IHasTopicRemoteEventData).Topic); } foreach (var item in _mapping) { if (item.Key.IsAssignableFrom(eventData.GetType())) { return(item.Value); } } return(TOPIC_DEFAULT); }
public void Publish(string topic, IRemoteEventData remoteEventData) { var connection = _connectionPool.Acquire(); try { var channel = connection.CreateModel(); channel.ExchangeDeclare(_exchangeTopic, "topic", true); var body = Encoding.UTF8.GetBytes(_remoteEventSerializer.Serialize(remoteEventData)); var properties = channel.CreateBasicProperties(); properties.Persistent = true; channel.BasicPublish(_exchangeTopic, topic, properties, body); } finally { _connectionPool.Return(connection); } }
public void Publish(IRemoteEventData remoteEventData) { var routingKey = remoteEventData.GetType().FullName; var connection = _connectionPool.Acquire(); try { var channel = connection.CreateModel(); channel.ExchangeDeclare(_rabbitMqEventBusOptions.ExchangeName, "direct", true); var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(remoteEventData)); var properties = channel.CreateBasicProperties(); properties.Persistent = true; channel.BasicPublish(_rabbitMqEventBusOptions.ExchangeName, routingKey, properties, body); } finally { _connectionPool.Return(connection); } }
public Task PublishAsync(string topic, IRemoteEventData remoteEventData) { return(_database.PublishAsync(topic, remoteEventData.ToJsonString())); }
public void Publish(string topic, IRemoteEventData remoteEventData) { _database.Publish(topic, _remoteEventSerializer.Serialize(remoteEventData)); }
public RemoteEventBusPublishingEvent(IRemoteEventData eventData) : base(eventData) { }
public Task PublishAsync(IRemoteEventData eventData) { return(PublishAsync(_topicSelector.SelectTopic(eventData), eventData)); }
public void Publish(IRemoteEventData eventData) { }
public RemoteEventBusPublishEvent(IRemoteEventData eventData) { RemoteEventData = eventData; }
/// <summary> /// 发布事件 /// </summary> /// <param name="eventData">事件</param> public void Publish(IRemoteEventData eventData) { Publish(_topicSelector.SelectTopic(eventData), eventData); }
public void Publish(string topic, IRemoteEventData remoteEventData) { PublishAsync(topic, remoteEventData); //_producer.Flush(TimeSpan.FromSeconds(10)); }
public async Task PublishAsync(IRemoteEventData eventData) { await _publisher.PublishAsync(eventData); await Task.FromResult(0); }
public void Publish(IRemoteEventData eventData) { _publisher.Publish(eventData); }
public void Publish(string topic, IRemoteEventData eventData) { }
public Task PublishAsync(string topic, IRemoteEventData eventData) { return(Task.FromResult(0)); }