public Task Send <T>(T commandMessage, SendOptions options) { if (!started) { throw new InvalidOperationException("The bus has not been started."); } var type = typeof(T); if (!busMessages.IsSendable(type)) { throw BusMessages.CreateMessageNotFoundException(type); } return(options == null ? busTransport.Send(commandMessage, MessageTypeToNameSendingCommandMap[type]) : busTransport.Send(commandMessage, MessageTypeToNameSendingCommandMap[type], options)); }
private void Send(Email email) { var model = JsonConvert.DeserializeObject <ExpandoObject>(email.Payload, new ExpandoObjectConverter()); var message = new RazorMessage(email.TemplateName, model); var envelope = _messageEnvelopeFactory.GetEnvelope(GetSubject(email.TemplateName), email.Address, message); _messageTransport.Send(envelope); }
public Task Send <T>(T commandMessage, SendOptions options = null) { var type = typeof(T); if (!busMessages.IsSendable(type)) { throw BusMessages.CreateMessageNotFoundException(type); } return(busTransport.Send(commandMessage, MessageTypeToNameSendingCommandMap[type], options)); }
public Task Send <T>(T commandMessage) { if (!started) { throw new InvalidOperationException("The bus has not been started."); } var type = typeof(T); if (!busMessages.IsACommand(type)) { throw BusMessages.CreateMessageNotFoundException(type); } return(busTransport.Send(commandMessage, busMessages.GetMessageTypeNameByType(type))); }
void _transport_OnMessageToUnknownDestination(MessageContainer message, IMessageTransport transport) { string dest = message.To; log.Debug("Message to remote destination {0}", dest); Uri uri = new Uri(dest); string sn = string.Format("MessageTransport_{0}", uri.Scheme); IMessageTransport mt = ServiceLocator.GetInstance <IMessageTransport>(sn); if (mt == null) { throw new Exception("No message transport configured for destination " + dest); } mt.Send(message); }
void httpTransport_OnMessageArrived(MessageContainer message, IMessageTransport transport) { if (message.RetryCount > 0) { //we don't check if already received if message is sent for the first time if (ReceivedMessageRegistry.HasBeenReceived(message.UniqueId)) { log.Warn("Message {0} has already been received. Ignoring", message.UniqueId); return; } } log.Info("Forwarding incoming http message {0} (from {1}) to {2}", message, message.From, _bus.Endpoint); message.To = _bus.Endpoint; _bus.Send(message); ReceivedMessageRegistry.RegisterReceived(message.UniqueId); }
private async Task <LogResponse> LogWorker(LogglyEvent[] events) { var response = new LogResponse { Code = ResponseCode.Unknown }; try { if (LogglyConfig.Instance.IsEnabled) { if (LogglyConfig.Instance.Transport.LogTransport == LogTransport.Https) { if (!LogglyConfig.Instance.Transport.IsOmitTimestamp) { foreach (var e in events) { // syslog has this data in the header, only need to add it for Http e.Data.AddIfAbsent("timestamp", e.Timestamp); } } } IMessageTransport transporter = TransportFactory(); response = await transporter.Send(events.Select(x => new LogglyMessage { Timestamp = x.Timestamp, Syslog = x.Syslog, Type = MessageType.Json, Content = ToJson(x.Data), CustomTags = x.Options.Tags })).ConfigureAwait(false); } else { response = new LogResponse { Code = ResponseCode.SendDisabled }; } } catch (Exception e) { LogglyException.Throw(e); } return(response); }
private LogResponse LogWorker(LogglyEvent logglyEvent) { var response = new LogResponse { Code = ResponseCode.Unknown }; try { if (LogglyConfig.Instance.IsEnabled) { if (LogglyConfig.Instance.Transport.LogTransport == LogTransport.Https) { // syslog has this data in the header, only need to add it for Http logglyEvent.Data.AddIfAbsent("timestamp", logglyEvent.Timestamp); } var message = new LogglyMessage { Timestamp = logglyEvent.Timestamp , Syslog = logglyEvent.Syslog , Type = MessageType.Json , Content = ToJson(logglyEvent.Data) }; IMessageTransport transporter = TransportFactory(); response = transporter.Send(message); } else { response = new LogResponse { Code = ResponseCode.SendDisabled }; } } catch (Exception e) { LogglyException.Throw(e); } return(response); }
private async Task <LogResponse> LogWorker(LogglyEvent[] events) { var response = new LogResponse { Code = ResponseCode.Unknown }; try { if (LogglyConfig.Instance.IsEnabled) { if (LogglyConfig.Instance.Transport.LogTransport == LogTransport.Https) { if (!LogglyConfig.Instance.Transport.IsOmitTimestamp) { foreach (var e in events) { // syslog has this data in the header, only need to add it for Http e.Data.AddIfAbsent("timestamp", e.Timestamp); } } } response = await _transport.Send(events.Select(BuildMessage)).ConfigureAwait(false); } else { response = new LogResponse { Code = ResponseCode.SendDisabled }; } } catch (Exception e) { LogglyException.Throw(e); } return(response); }