public QueueSendEndpointContextFactory(IMessagingFactoryContextSupervisor messagingFactoryContextSupervisor, INamespaceContextSupervisor namespaceContextSupervisor, IPipe <MessagingFactoryContext> messagingFactoryPipe, IPipe <NamespaceContext> namespacePipe, SendSettings settings) : base(namespaceContextSupervisor, namespacePipe, messagingFactoryContextSupervisor, messagingFactoryPipe) { _settings = settings; }
static IEnumerable <string> GetQueryStringOptions(SendSettings settings) { if (!settings.Durable) { yield return("durable=false"); } if (settings.AutoDelete) { yield return("autodelete=true"); } if (settings.BindToQueue) { yield return("bind=true"); } if (!string.IsNullOrWhiteSpace(settings.QueueName)) { yield return("queue=" + WebUtility.UrlEncode(settings.QueueName)); } if (settings.ExchangeType != ExchangeType.Fanout) { yield return("type=" + settings.ExchangeType); } if (settings.ExchangeArguments != null && settings.ExchangeArguments.ContainsKey("x-delayed-type")) { yield return("delayedType=" + settings.ExchangeArguments["x-delayed-type"]); } foreach (var binding in settings.ExchangeBindings) { yield return($"bindexchange={binding.Exchange.ExchangeName}"); } }
public RabbitMqSendTransport(IModelCache modelCache, SendSettings sendSettings, params ExchangeBindingSettings[] exchangeBindings) { _observers = new SendObservable(); _sendSettings = sendSettings; _modelCache = modelCache; _filter = new PrepareSendExchangeFilter(_sendSettings, exchangeBindings); }
public static ExchangeBindingSettings GetExchangeBinding(this SendSettings settings, string exchangeName) { var exchange = new Exchange(exchangeName, settings.Durable, settings.AutoDelete); var binding = new ExchangeBinding(exchange); return(binding); }
public static ExchangeBindingSettings GetErrorExchangeBinding(this SendSettings settings) { var exchange = new Exchange(settings.ExchangeName, true, false); var binding = new ExchangeBinding(exchange); return(binding); }
ISendEndpointContextSupervisor CreateSendEndpointContextSupervisor(SendSettings settings) { var topologyPipe = new ConfigureTopologyFilter <SendSettings>(settings, settings.GetBrokerTopology(), false, Stopping); var contextFactory = new SendEndpointContextFactory(ConnectionContextSupervisor, topologyPipe.ToPipe <SendEndpointContext>(), settings); return(new SendEndpointContextSupervisor(contextFactory)); }
public RabbitMqSendContextImpl(IBasicProperties basicProperties, T message, SendSettings sendSettings, CancellationToken cancellationToken, string routingKey = "") : base(message, cancellationToken) { BasicProperties = basicProperties; Exchange = sendSettings.ExchangeName; RoutingKey = routingKey; }
IPipe <NamespaceContext> CreateConfigureTopologyPipe(SendSettings settings) { var configureTopologyFilter = new ConfigureTopologyFilter <SendSettings>(settings, settings.GetBrokerTopology(), false, _host.Stopping); IPipe <NamespaceContext> namespacePipe = configureTopologyFilter.ToPipe(); return(namespacePipe); }
ISendEndpointContextSupervisor CreateTopicSendEndpointContextSupervisor(SendSettings settings) { IPipe <NamespaceContext> namespacePipe = CreateConfigureTopologyPipe(settings); var contextFactory = new TopicSendEndpointContextFactory(MessagingFactoryContextSupervisor, NamespaceContextSupervisor, Pipe.Empty <MessagingFactoryContext>(), namespacePipe, settings); return(new SendEndpointContextSupervisor(contextFactory)); }
ISendTransport CreateSendTransport(Uri address, SendSettings settings) { TransportLogMessages.CreateSendTransport(address); var endpointContextSupervisor = CreateSendEndpointContextSupervisor(settings); var transportContext = new SendTransportContext(_hostConfiguration, address, endpointContextSupervisor); return(new ServiceBusSendTransport(transportContext)); }
public UserSettings() { SendSettings = new SendSettings(); StagedSendSettings = new SendSettings(); SendReversalSettings = new SendReversalSettings(); ReceiveSettings = new ReceiveSettings(); StagedReceiveSettings = new ReceiveSettings(); BillPaySettings = new BillPaySettings(); StagedBillPaySettings = new BillPaySettings(); EnvironmentAgents = new Dictionary <string, List <EnvironmentAgent> >(); }
ISendTransport CreateSendTransport(Uri address, SendSettings settings) { var endpointContextSupervisor = CreateSendEndpointContextSupervisor(settings); var transportContext = new HostServiceBusSendTransportContext(address, endpointContextSupervisor, SendLogContext); var transport = new ServiceBusSendTransport(transportContext); Add(transport); return(transport); }
public ISendEndpointContextSupervisor CreateSendEndpointContextSupervisor(SendSettings settings) { var configureTopology = new ConfigureTopologyFilter <SendSettings>(settings, settings.GetBrokerTopology(), false, Stopping); var contextFactory = new SendEndpointContextFactory(this, configureTopology.ToPipe <SendEndpointContext>(), settings); var contextSupervisor = new SendEndpointContextSupervisor(contextFactory); Add(contextSupervisor); return(contextSupervisor); }
ISendTransport CreateSendTransport(Uri address, SendSettings settings) { LogContext.SetCurrentIfNull(_hostConfiguration.LogContext); TransportLogMessages.CreateSendTransport(address); var endpointContextSupervisor = CreateSendEndpointContextSupervisor(settings); var transportContext = new SendTransportContext(address, endpointContextSupervisor, _hostConfiguration.SendLogContext); return(new ServiceBusSendTransport(transportContext)); }
public ISendEndpointContextSupervisor CreateSendEndpointContextSupervisor(SendSettings settings) { LogContext.SetCurrentIfNull(_hostConfiguration.LogContext); var configureTopology = new ConfigureTopologyFilter <SendSettings>(settings, settings.GetBrokerTopology(), false, Stopping); var contextFactory = new SendEndpointContextFactory(this, configureTopology.ToPipe <SendEndpointContext>(), settings); var contextSupervisor = new SendEndpointContextSupervisor(contextFactory); AddSendAgent(contextSupervisor); return(contextSupervisor); }
public static Uri GetSendAddress(this RabbitMqHostSettings hostSettings, SendSettings sendSettings) { var builder = new UriBuilder { Scheme = "rabbitmq", Host = hostSettings.Host, Port = hostSettings.Port, Path = hostSettings.VirtualHost != "/" ? string.Join("/", hostSettings.VirtualHost, sendSettings.ExchangeName) : sendSettings.ExchangeName }; builder.Query += string.Join("&", GetQueryStringOptions(sendSettings)); return(builder.Uri); }
Task <ISendEndpoint> CreateSendEndpoint(Type messageType) { SendSettings sendSettings = _host.GetSendSettings(messageType); ExchangeBindingSettings[] bindings = TypeMetadataCache.GetMessageTypes(messageType) .SelectMany(type => type.GetExchangeBindings(_host.MessageNameFormatter)) .Where(binding => !sendSettings.ExchangeName.Equals(binding.Exchange.ExchangeName)) .ToArray(); Uri destinationAddress = _host.Settings.GetSendAddress(sendSettings); var modelCache = new RabbitMqModelCache(_host.ConnectionCache); var sendTransport = new RabbitMqSendTransport(modelCache, sendSettings, bindings); return(Task.FromResult <ISendEndpoint>(new SendEndpoint(sendTransport, _serializer, destinationAddress, _sourceAddress, SendPipe.Empty))); }
public Task <ISendTransport> GetSendTransport(Uri address) { SendSettings sendSettings = address.GetSendSettings(); RabbitMqHostSettings hostSettings = address.GetHostSettings(); IRabbitMqHost host = _hosts.FirstOrDefault(x => RabbitMqHostEqualityComparer.Default.Equals(hostSettings, x.Settings)); if (host == null) { throw new EndpointNotFoundException("The endpoint address specified an unknown host: " + address); } var modelCache = new RabbitMqModelCache(host.ConnectionCache); return(Task.FromResult <ISendTransport>(new RabbitMqSendTransport(modelCache, sendSettings))); }
public RabbitMqSendContextImpl(IBasicProperties basicProperties, T message, SendSettings sendSettings, CancellationToken cancellationToken, string routingKey = "") { CancellationToken = cancellationToken; _payloadCache = new PayloadCache(); // provide access to the extended settings for RabbitMQ developers _payloadCache.GetOrAddPayload <RabbitMqSendContext <T> >(() => this); _payloadCache.GetOrAddPayload <RabbitMqSendContext>(() => this); Headers = new RabbitMqSendHeaders(basicProperties); BasicProperties = basicProperties; Message = message; Exchange = sendSettings.ExchangeName; RoutingKey = routingKey; MessageId = NewId.NextGuid(); Durable = true; }
private void SetDefaults(UserSettings settings) { SendSettings settingsSource = _transactionName == StaticTransactionNames.Send ? settings.SendSettings : settings.StagedSendSettings; SelectedCountry = CountryList?.FirstOrDefault(country => country.CountryCode == settingsSource.CountryCode) ?? CountryList?.FirstOrDefault(); SelectedCountrySubdivision = CountrySubdivisionList.FirstOrDefault( countrySubdivision => countrySubdivision.CountrySubdivisionCode == settingsSource.CountrySubdivisionCode) ?? CountrySubdivisionList.First(); SelectedCurrency = CurrencyList?.FirstOrDefault(curr => curr.CurrencyCode == settingsSource.CurrencyCode) ?? CurrencyList?.FirstOrDefault(); SelectedAmountRange = AmountRangeList?.FirstOrDefault(ar => ar.Code == settingsSource.AmountRange) ?? AmountRangeList?.FirstOrDefault(); CustomAmount = settingsSource.CustomAmount; SelectedItemChoice = ItemChoiceList?.FirstOrDefault(ic => ic.Code == settingsSource.ItemChoice) ?? ItemChoiceList?.FirstOrDefault(); SelectedServiceOption = ServiceOptionList?.FirstOrDefault(so => so.Key == settingsSource.ServiceOption) ?? ServiceOptionList?.FirstOrDefault(); SelectedThirdPartyType = ThirdPartyTypeList?.FirstOrDefault(tp => tp == settingsSource.ThirdPartyType) ?? ThirdPartyTypeList?.FirstOrDefault(); }
ISendEndpointContextSupervisor CreateTopicSendEndpointContextSupervisor(SendSettings settings) { var contextFactory = new TopicSendEndpointContextFactory(ConnectionContextSupervisor, CreateSendTopologyPipe(settings), settings); return(CreateContextSupervisor(contextFactory)); }
static IEnumerable<string> GetQueryStringOptions(SendSettings settings) { if (!settings.Durable) yield return "durable=false"; if (settings.AutoDelete) yield return "autodelete=true"; if (settings.BindToQueue) yield return "bind=true"; if (!string.IsNullOrWhiteSpace(settings.QueueName)) yield return "queue=" + WebUtility.UrlEncode(settings.QueueName); if (settings.ExchangeType != ExchangeType.Fanout) yield return "type=" + settings.ExchangeType; if (settings.ExchangeArguments != null && settings.ExchangeArguments.ContainsKey("x-delayed-type")) yield return "delayedType=" + settings.ExchangeArguments["x-delayed-type"]; foreach (var binding in settings.ExchangeBindings) { yield return $"bindexchange={binding.Exchange.ExchangeName}"; } }
public static Uri GetSendAddress(this RabbitMqHostSettings hostSettings, SendSettings sendSettings) { var builder = new UriBuilder { Scheme = "rabbitmq", Host = hostSettings.Host, Port = hostSettings.Port, Path = hostSettings.VirtualHost != "/" ? string.Join("/", hostSettings.VirtualHost, sendSettings.ExchangeName) : sendSettings.ExchangeName }; builder.Query += string.Join("&", GetQueryStringOptions(sendSettings)); return builder.Uri; }
public SendEndpointContextFactory(IConnectionContextSupervisor supervisor, IPipe <SendEndpointContext> pipe, SendSettings settings) { _supervisor = supervisor; _pipe = pipe; _settings = settings; }
public BrokeredMessageErrorTransport(IConnectionContextSupervisor supervisor, SendSettings settings) : base(supervisor, settings) { }
protected override IPipeContextFactory <SendEndpointContext> CreateSendEndpointContextFactory(IServiceBusHost host, SendSettings settings, IPipe <NamespaceContext> namespacePipe) { return(new QueueSendEndpointContextFactory(host.MessagingFactoryCache, host.NamespaceCache, Pipe.Empty <MessagingFactoryContext>(), namespacePipe, settings)); }
public PreparedExchangeContextImpl(SendSettings settings) { _settings = settings; _ready = new TaskCompletionSource <SendSettings>(); }
public PrepareSendExchangeFilter(SendSettings settings, params ExchangeBindingSettings[] exchangeBindings) { _settings = settings; _exchangeBindings = exchangeBindings.Concat(settings.ExchangeBindings).ToArray(); }
static void Main(string[] args) { // Check if log file exists, if not create it. If there is an issue in this and it could not create and returns false, then send an email if (!Logger.CheckForLogFile()) { SmtpClient exchmail = new SmtpClient(); exchmail.Host = "exchmail.delta.edu"; exchmail.Port = 25; MailMessage OutGoing = new MailMessage(); OutGoing.Sender = new MailAddress("[email protected] "); OutGoing.To.Add(new MailAddress("*****@*****.**")); //OutGoing.To.Add(new MailAddress("*****@*****.**")); OutGoing.Subject = "Error with LDOA Notification"; OutGoing.From = new MailAddress("[email protected] "); OutGoing.Body = "<p>No log file exists for LDOANotificationEmail. Create LDOANotificationEmail.log file in Logs folder and run the process again manually.</p>"; OutGoing.IsBodyHtml = true; exchmail.Send(OutGoing); } else { try { string term = DataAccess.GetCurrentTerm(); // string term = "16/FA"; // Skip emailing faculty and division chairs if there is no current term if (term != "") { // Initialize list of recipients for log List <string> recipientData = new List <string>(); var usersToProcess = DataAccess.GetOutstandingLDOA(term); if (usersToProcess.Count == 0) { // No users to process to write this to log Logger.LogError("There were zero outstanding notifications to process."); SmtpClient exchmail = new SmtpClient(); exchmail.Host = "exchmail.delta.edu"; exchmail.Port = 25; MailMessage OutGoing = new MailMessage(); OutGoing.Sender = new MailAddress("[email protected] "); OutGoing.To.Add(new MailAddress("*****@*****.**")); //OutGoing.To.Add(new MailAddress("*****@*****.**")); OutGoing.Subject = "LDOA Notification - Verify Zero Outstanding"; OutGoing.From = new MailAddress("[email protected] "); OutGoing.Body = "<p>There were zero outstanding notifications to process. Verify if this is true in the database.</p>"; OutGoing.IsBodyHtml = true; exchmail.Send(OutGoing); } else { // Log the LDOA dataset for tracking and validation //string dataHeader = "StudentName, StudentEmail, StudentNumber, StudentGrade, InstructorName, InstructorEmail, CourseSection, Term, DateDropped"; //Logger.LogLDOAHeader(dataHeader); // Get each row of data from GetUnifinishedLDOA stored procedure and log it //foreach (ERPDataSet.GetUnfinishedLDOARow thisItem in usersToProcess) //{ // string dataRow = thisItem.StudentName + ", " + thisItem.StudentEmail + ", " + thisItem.StudentNumber + ", " + thisItem.StudentGrade + ", " + // thisItem.InstructorName + ", " + thisItem.InstructorEmail + ", " + thisItem.CourseSection + ", " + thisItem.Term + ", " + // thisItem.DateDropped; // Logger.LogLDOADataSet(dataRow); //} // Goes with dataset logging in line above //Logger.LogLWriteLine(System.DateTime.Now + " - CHECK FOR ERROR BELOW, IF NEW DATA SET, WE GOOD"); Logger.LogWriteLine(System.DateTime.Now + " - Email Recipient Info For This Run:"); // Figure out the email recipient and setup email if date since drop matches # from xml file and execute send then logging int droppedStudentCount = 0; foreach (ERPDataSet.GetUnfinishedLDOARow thisItem in usersToProcess) { // Determine how long it has been since this has been run int daysSinceDrop = DateTime.Now.Subtract(thisItem.DateDropped).Days; DateTime lastDate = thisItem.DateDropped.AddDays(14); // Determine which notification to send SendEmail.NoticeType noticeToSend = SendSettings.GetNoticeType(daysSinceDrop); List <string> emailRecipients = new List <string>(); // Add faculty email recipient if (SendSettings.SendFacultyEmailOnDay(daysSinceDrop)) { droppedStudentCount++; //First we need to get the instructors email and build info for log list emailRecipients.Add(thisItem.InstructorEmail); //emailRecipients.Add("*****@*****.**"); recipientData.Add(droppedStudentCount + " Instructor - " + thisItem.InstructorEmail + ", Student - " + thisItem.StudentName + ", Course = " + thisItem.CourseSection); } // If necessary, also add division chair as email recipient if (SendSettings.SendDivisionChairEmailOnday(daysSinceDrop)) { //Next we need to get the division chairs information and add info for log list string divisionChairEmail = GetDivisionChairInfo.GetDivisionChairEmail(thisItem.CourseSection); if (divisionChairEmail != "") { emailRecipients.Add(divisionChairEmail); //emailRecipients.Add("*****@*****.**"); recipientData.Add(droppedStudentCount + " Division Chair - " + divisionChairEmail + ", Student - " + thisItem.StudentName + ", Course = " + thisItem.CourseSection); } } // If we have faculty and division chair recipients in list, send emails if (emailRecipients.Any()) { SendEmail.SendNotice(noticeToSend, emailRecipients, thisItem.InstructorName, thisItem.StudentName, thisItem.StudentNumber.ToString(), thisItem.CourseSection, thisItem.DateDropped.ToString("MM/dd/yyyy"), lastDate.ToString("MM/dd/yyyy")); } } // Log how many emails were sent and the info for who they went to and for what student and course Logger.LogWriteLine("Number of emails sent: " + recipientData.Count); foreach (var line in recipientData) { Logger.LogWriteLine(line); } } } } catch (Exception ex) { // We hit an error, so send an email to notify helpdesk about this for us to look into // Construct error message string errorMessage; // Uncomment code below if there is an inner exception to have it print when debugging // Check for inner exception, SQL errors usually reside here //if (ex.InnerException.ToString() == "") //{ errorMessage = Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + "Stack Trace:" + Environment.NewLine + ex.StackTrace; //} //else //{ // errorMessage = Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + // "Inner Exception:" + Environment.NewLine + ex.InnerException + // Environment.NewLine + Environment.NewLine + "Stack Trace:" + // Environment.NewLine + ex.StackTrace; //} // Log error message Logger.LogError(errorMessage); // Send error message in email SmtpClient exchmail = new SmtpClient(); exchmail.Host = "exchmail.delta.edu"; exchmail.Port = 25; MailMessage OutGoing = new MailMessage(); OutGoing.Sender = new MailAddress("[email protected] "); OutGoing.To.Add(new MailAddress("*****@*****.**")); //OutGoing.To.Add(new MailAddress("*****@*****.**")); OutGoing.Subject = "Error with LDOA Notification"; OutGoing.From = new MailAddress("[email protected] "); OutGoing.Body = "<p>" + errorMessage + "</p>"; OutGoing.IsBodyHtml = true; exchmail.Send(OutGoing); } } }
public PrepareSendExchangeFilter(SendSettings settings, params ExchangeBindingSettings[] exchangeBindings) { _settings = settings; _exchangeBindings = exchangeBindings; }
public TopicSendEndpointContextFactory(IMessagingFactoryCache messagingFactoryCache, INamespaceCache namespaceCache, IPipe <MessagingFactoryContext> messagingFactoryPipe, IPipe <NamespaceContext> namespacePipe, SendSettings settings) : base(namespaceCache, namespacePipe, messagingFactoryCache, messagingFactoryPipe) { _settings = settings; }
IPipe <SendEndpointContext> CreateSendTopologyPipe(SendSettings settings) { return(new ConfigureTopologyFilter <SendSettings>(settings, settings.GetBrokerTopology(), false, Stopping).ToPipe <SendEndpointContext>()); }