public MiramarPublisher(IMessageQueueFactory messageFactory) { this.messageFactory = messageFactory; miramarIdentifier = ConfigurationManager.AppSettings["MiramarIdentifier"]; monitorExchange = ConfigurationManager.AppSettings["RabbitMqMonitorExchange"]; }
public CheckScannerController(IConfigurationWrapper configuration, ICheckScannerService checkScannerService, IAuthenticationRepository authenticationService, ICommunicationRepository communicationService, ICryptoProvider cryptoProvider, IUserImpersonationService userImpersonationService, IMessageQueueFactory messageQueueFactory = null, IMessageFactory messageFactory = null) : base(userImpersonationService) { _checkScannerService = checkScannerService; _authenticationService = authenticationService; _communicationService = communicationService; _cryptoProvider = cryptoProvider; var b = configuration.GetConfigValue("CheckScannerDonationsAsynchronousProcessingMode"); _asynchronous = b != null && bool.Parse(b); if (_asynchronous) { var donationsQueueName = configuration.GetConfigValue("CheckScannerDonationsQueueName"); // ReSharper disable once PossibleNullReferenceException _donationsQueue = messageQueueFactory.CreateQueue(donationsQueueName, QueueAccessMode.Send); _messageFactory = messageFactory; } }
public ScheduleService(IMessageQueueFactory queueFactory, IMiramarTaskProvider taskProvider, IMiramarScheduleProvider scheduleProvider, IMiramarContextProvider contextProvider) { this.contextProvider = contextProvider; this.queueFactory = queueFactory; this.taskProvider = taskProvider; this.scheduleProvider = scheduleProvider; logger = InfrastructureFactory.CreateLogger("ScheduleQueue"); }
public ServeController(IServeService serveService, IConfigurationWrapper configuration, IMessageFactory messageFactory, IMessageQueueFactory messageQueueFactory) { _serveService = serveService; _messageFactory = messageFactory; var eventQueueName = configuration.GetConfigValue("SignupToServeEventQueue"); _eventQueue = messageQueueFactory.CreateQueue(eventQueueName, QueueAccessMode.Send); _messageFactory = messageFactory; }
public TripApplicationController(ITripService tripService, IConfigurationWrapper configuration, IMessageFactory messageFactory, IMessageQueueFactory messageQueueFactory) { _tripService = tripService; _messageFactory = messageFactory; var eventQueueName = configuration.GetConfigValue("TripApplicationEventQueue"); _eventQueue = messageQueueFactory.CreateQueue(eventQueueName, QueueAccessMode.Send); _messageFactory = messageFactory; }
private IHandler CreateHandlerWithChainsupportClientFactory(IMessageQueueFactory messageQueueFactory) { var chaincodeSupportClientFactoryMock = new Mock <IChaincodeSupportClientFactory>(); chaincodeSupportClientFactoryMock.Setup(m => m.Create(It.IsAny <Channel>())) .Returns(new NullChaincodeSupportClientFactory()); return(CreateHandler(messageQueueFactory, chaincodeSupportClientFactoryMock.Object)); }
public FileHandlerService(IFileHandlerFactory handlerFactory, IMessageQueueFactory msmqFactory, ISettingsProvider settingsProvider, ILogger logger) { _fileHandlerFactory = handlerFactory; _msmqFactory = msmqFactory; _settingsProvider = settingsProvider; _logger = logger; _fileHandlers = new List <IFileHandler>(); _reportingTimer = new Timer(ReportStatus); }
public TextCommunicationController(ITextCommunicationService textCommunicationService, IConfigurationWrapper configurationWrapper, IUserImpersonationService userImpersonationService, IMessageQueueFactory messageQueueFactory = null, IMessageFactory messageFactory = null, IMessageQueue messageQueue = null) : base(userImpersonationService) { _textCommunicationService = textCommunicationService; _eventQueueName = configurationWrapper.GetConfigValue("ScheduledJobsQueueName"); _streamReminderTemplateId = configurationWrapper.GetConfigIntValue("StreamReminderTemplate"); _messageQueue = messageQueue; _messageQueue.CreateQueue(_eventQueueName, QueueAccessMode.Send); _messageFactory = messageFactory; }
public MessageDistributor( ILogger <MessageDistributor> logger, IMessageQueueFactory messageQueueFactory) { _serializer = new JsonSerializer(); _serializer.MissingMemberHandling = MissingMemberHandling.Ignore; _serializer.NullValueHandling = NullValueHandling.Ignore; _logger = logger; _messageQueueFactory = messageQueueFactory; }
public QueueAdapter(IMessageQueueFactory messageFactory) { messagePublisherIsActive = false; if (!messageFactory.IsActive || !messageFactory.IsOpen) { return; } messagePublisherIsActive = true; messagePublisher = messageFactory.CreatePublisher(); }
public MainExampleQueue( IMessageQueueFactory messageQueueFactory, ICircuitBreaker circuitBreaker, ILogger logger) : base( new MainExampleQueuePath(), new XmlMessageFormatter(new[] { typeof(SerializableMessage) }), messageQueueFactory, circuitBreaker, logger) { }
public CommandSender(IMessageQueueFactory msmqFactory, ICommandParser commandParser, ISettingsProvider settingsProvider, ILogger logger) { _msmqFactory = msmqFactory; _msmqSenders = new ConcurrentBag <IMessageQueueSender>(); _commandParser = commandParser; _сommandFile = settingsProvider.GetCommandFileName(); _fileSystemWatcher = new FileSystemWatcher(); _fileSystemWatcher.IncludeSubdirectories = false; _logger = logger; }
protected Queue( IQueuePathProvider queuePathProvider, IMessageFormatter messageFormatter, IMessageQueueFactory messageQueueFactory, ICircuitBreaker circuitBreaker, ILogger logger) { _queuePathProvider = queuePathProvider; _messageFormatter = messageFormatter; _messageQueueFactory = messageQueueFactory; _circuitBreaker = circuitBreaker; _logger = logger; }
static void AddMiramarAdapter(IMessageQueueFactory queueFactory) { var queueAdapter = new QueueAdapter(queueFactory) { Name = "miramar", Layout = "${message} ${onexception:${newline}${exception:format=message,method,tostring}}" }; var logConfiguration = LogManager.Configuration; logConfiguration.AddTarget("Queue", queueAdapter); logConfiguration.LoggingRules.Add(new LoggingRule("Client-*", LogLevel.Info, queueAdapter)); LogManager.Configuration = logConfiguration; }
/// <summary> /// Ensure that the MessageQueueObject name is set and creates a /// <see cref="DefaultMessageQueueFactory"/> if no <see cref="IMessageQueueFactory"/> /// is specified. /// </summary> /// <remarks>Will attempt to create an instance of the DefaultMessageQueue to detect early /// any configuraiton errors.</remarks> /// <exception cref="System.Exception"> /// In the event of misconfiguration (such as the failure to set a /// required property) or if initialization fails. /// </exception> public virtual void AfterPropertiesSet() { if (MessageQueueObjectName == null) { throw new ArgumentException("The DefaultMessageQueueObjectName property has not been set."); } if (messageQueueFactory == null) { DefaultMessageQueueFactory mqf = new DefaultMessageQueueFactory(); mqf.ApplicationContext = applicationContext; messageQueueFactory = mqf; } //Create an instance so we can 'fail-fast' if there isn't an DefaultMessageQueue unde MessageQueue mq = MessageQueueFactory.CreateMessageQueue(messageQueueObjectName); }
static void CancelAndWait(CancellationTokenSource source, IMessageQueueFactory messageFactory, params Task[] tasks) { source.Cancel(); Task.WaitAll(tasks); InfrastructureFactory.ForceLogFlush(); InfrastructureFactory.CloseLogTargets(); if (messageFactory != null) { if (messageFactory.IsOpen) { messageFactory.Dispose(); } } }
public FileControlService( IMessageQueueFactory msmqFactory, ISettingsProvider settingsProvider, ILogger logger, ICommandSender commandSender, IMessageHandler[] messageHandlers) { _msmqFactory = msmqFactory; _settingsProvider = settingsProvider; _logger = logger; _commandSender = commandSender; _messageHandlers = messageHandlers; _messageTypes = _messageHandlers .Select(x => x.MessageType) .Union(new[] { typeof(AddSubscriberMessage) }) .ToArray(); }
/// <summary> /// Invoked by an <see cref="Spring.Objects.Factory.IObjectFactory"/> /// after it has injected all of an object's dependencies. /// </summary> /// <remarks> /// Ensure that the DefaultMessageQueueObjectName property is set, creates /// a default implementation of the <see cref="IMessageQueueFactory"/> interface /// (<see cref="DefaultMessageQueueFactory"/>) that retrieves instances on a per-thread /// basis, and registers in the Spring container a default implementation of /// <see cref="IMessageConverter"/> (<see cref="XmlMessageConverter"/>) with a /// simple System.String as its TargetType. <see cref="QueueUtils.RegisterDefaultMessageConverter"/> /// </remarks> public void AfterPropertiesSet() { if (MessageQueueFactory == null) { AssertUtils.ArgumentNotNull(applicationContext, "MessageQueueTemplate requires the ApplicationContext property to be set if the MessageQueueFactory property is not set for automatic create of the DefaultMessageQueueFactory"); DefaultMessageQueueFactory mqf = new DefaultMessageQueueFactory(); mqf.ApplicationContext = applicationContext; messageQueueFactory = mqf; } if (messageConverterObjectName == null) { messageConverterObjectName = QueueUtils.RegisterDefaultMessageConverter(applicationContext); } //If it has not been set by the user explicitly, then initialize. CreateDefaultMetadataCache(); }
private IHandler CreateHandler( IMessageQueueFactory messageQueueFactory, IChaincodeSupportClientFactory chaincodeSupportClientFactory, IChaincodeStubFactory chaincodeStubFactory = null, IChaincode chaincode = null ) { return(new global::Thinktecture.HyperledgerFabric.Chaincode.NET.Handler.Handler( chaincode ?? new Mock <IChaincode>().Object, "example.test", 9999, chaincodeStubFactory ?? new Mock <IChaincodeStubFactory>().Object, new Mock <ILogger <global::Thinktecture.HyperledgerFabric.Chaincode.NET.Handler.Handler> >().Object, messageQueueFactory, chaincodeSupportClientFactory )); }
protected override void OnStart(string[] args) { logger.Debug("Starting up service."); queueFactory = CreateMessageFactory(logger); if (!queueFactory.IsActive) { logger.InfoFormat("RabbitMQ is not active. Messaging will not be available."); } queuePublisher = new MiramarPublisher(queueFactory); var directory = AppDomain.CurrentDomain.BaseDirectory; var path = Path.Combine(directory, "miramar.config"); var contextProvider = new MiramarContextProvider(); var taskProvider = MiramarConfigurationParser.ParseConfiguration(queuePublisher, path); var scheduleProvider = MiramarSchedulingParser.ParseSchedule(queuePublisher, path); serviceTask = new Task(() => { logger.Info("Starting Miramar Controller."); var controller = new MiramarController(queuePublisher, taskProvider, scheduleProvider, contextProvider); controller.ThreadRun(serviceSource.Token); }); serviceTask.ContinueWith(x => logger.Info("Controller is shutting down.")); messageTask = new Task(() => { logger.Info("Starting Miramar Scheduler."); var scheduler = new ScheduleService(queueFactory, taskProvider, scheduleProvider, contextProvider); scheduler.ThreadRun(serviceSource.Token); }); messageTask.ContinueWith(x => logger.Info("Scheduler is shutting down.")); AddMiramarAdapter(queueFactory); serviceTask.Start(); messageTask.Start(); logger.Info("Miramar Controller is now running."); }
/// <summary> /// Invoked by an <see cref="Spring.Objects.Factory.IObjectFactory"/> /// after it has injected all of an object's dependencies. /// </summary> /// <remarks> /// <p> /// This method allows the object instance to perform the kind of /// initialization only possible when all of it's dependencies have /// been injected (set), and to throw an appropriate exception in the /// event of misconfiguration. /// </p> /// <p> /// Please do consult the class level documentation for the /// <see cref="Spring.Objects.Factory.IObjectFactory"/> interface for a /// description of exactly <i>when</i> this method is invoked. In /// particular, it is worth noting that the /// <see cref="Spring.Objects.Factory.IObjectFactoryAware"/> /// and <see cref="Spring.Context.IApplicationContextAware"/> /// callbacks will have been invoked <i>prior</i> to this method being /// called. /// </p> /// </remarks> /// <exception cref="System.Exception"> /// In the event of misconfiguration (such as the failure to set a /// required property) or if initialization fails. /// </exception> public void AfterPropertiesSet() { if (messageQueueFactory == null) { DefaultMessageQueueFactory mqf = new DefaultMessageQueueFactory(); mqf.ApplicationContext = applicationContext; messageQueueFactory = mqf; } if (messageConverterObjectName == null) { messageConverterObjectName = QueueUtils.RegisterDefaultMessageConverter(applicationContext); } if (messageQueueTemplate == null) { messageQueueTemplate = new MessageQueueTemplate(); messageQueueTemplate.ApplicationContext = ApplicationContext; messageQueueTemplate.AfterPropertiesSet(); } }
public StripeEventController(IConfigurationWrapper configuration, IStripeEventService stripeEventService = null, IMessageQueueFactory messageQueueFactory = null, IMessageFactory messageFactory = null) { var b = configuration.GetConfigValue("StripeWebhookLiveMode"); _liveMode = b != null && bool.Parse(b); b = configuration.GetConfigValue("StripeWebhookAsynchronousProcessingMode"); _asynchronous = b != null && bool.Parse(b); if (_asynchronous) { var eventQueueName = configuration.GetConfigValue("StripeWebhookEventQueueName"); _eventQueue = messageQueueFactory.CreateQueue(eventQueueName, QueueAccessMode.Send); _messageFactory = messageFactory; } else { _stripeEventService = stripeEventService; } }
public IntegrationBus(IMessageQueueFactory queueFactory, IIntegrationBusStorageFactory subscriptionStorageFactory, IIntegrationBusSecurityTokenValidator securityTokenValidator, IIntegrationBusSubscriptionValidator subscriptionValidator) { if (queueFactory == null) { throw new ArgumentNullException("queueFactory"); } if (subscriptionStorageFactory == null) { throw new ArgumentNullException("subscriptionStorageFactory"); } if (securityTokenValidator == null) { throw new ArgumentNullException("securityTokenValidator"); } if (subscriptionValidator == null) { throw new ArgumentNullException("subscriptionValidator"); } _queueManager = queueFactory.CreateMessageQueueManager(); _queueListener = queueFactory.CreateMessageQueueListener(); _queuePublisher = queueFactory.CreateMessageQueuePublisher(); _subscriptionStorage = subscriptionStorageFactory.CreateSubscriptionStorage(); _queueConsumer = new IntegrationBusConsumer(_subscriptionStorage); _securityTokenValidator = securityTokenValidator; _subscriptionValidator = subscriptionValidator; _subscribers.Add("fanout", SubscribeFanout); _subscribers.Add("direct", SubscribeDirect); _subscribers.Add("topic", SubscribeTopic); _subscribers.Add("headers", SubscribeHeaders); _unsubscribers.Add("fanout", UnsubscribeFanout); _unsubscribers.Add("direct", UnsubscribeDirect); _unsubscribers.Add("topic", UnsubscribeTopic); _unsubscribers.Add("headers", UnsubscribeHeaders); }
/// <summary> /// Initializes a new instance of the <see cref="JobQueue"/> class /// </summary> /// <param name="queueFactory">Factory for creating the queue</param> /// <param name="messageFactory">Factory for creating new messages</param> /// <param name="formatter">Formatter for formatting payloads</param> /// <param name="serializer">Serializer for serializing requests</param> /// <param name="handlerConfiguration">Configuration creating handlers (used to copy into a <see cref="QueueCreationOptions"/> object</param> public JobQueue( IMessageQueueFactory queueFactory, IMessageFactory messageFactory, IPayloadFormatter formatter, IRequestSerializer serializer, HandlerConfiguration handlerConfiguration) { if (handlerConfiguration == null) { throw new ArgumentNullException(nameof(handlerConfiguration)); } _messageQueueFactory = queueFactory ?? throw new ArgumentNullException(nameof(queueFactory)); _messageFactory = messageFactory ?? throw new ArgumentNullException(nameof(messageFactory)); _formatter = formatter ?? throw new ArgumentNullException(nameof(formatter)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); _queue = _messageQueueFactory.Create(handlerConfiguration.ToQueueCreationOptions()); _queue.ReceivedMessage += OnReceivedJob; }
public Handler( IChaincode chaincode, string host, int port, IChaincodeStubFactory chaincodeStubFactory, ILogger <Handler> logger, IMessageQueueFactory messageQueueFactory, IChaincodeSupportClientFactory chaincodeSupportClientFactory ) { _chaincode = chaincode; _chaincodeStubFactory = chaincodeStubFactory; _logger = logger; // TODO: Secure channel? _client = chaincodeSupportClientFactory.Create(new Channel(host, port, ChannelCredentials.Insecure, new List <ChannelOption> { new ChannelOption("request-timeout", 30000) })); _messageQueue = messageQueueFactory.Create(this); }
public CheckScannerController(IConfigurationWrapper configuration, ICheckScannerService checkScannerService, IAuthenticationService authenticationService, ICommunicationService communicationService, ICryptoProvider cryptoProvider, IMessageQueueFactory messageQueueFactory = null, IMessageFactory messageFactory = null) { _checkScannerService = checkScannerService; _authenticationService = authenticationService; _communicationService = communicationService; _cryptoProvider = cryptoProvider; var b = configuration.GetConfigValue("CheckScannerDonationsAsynchronousProcessingMode"); _asynchronous = b != null && bool.Parse(b); if (_asynchronous) { var donationsQueueName = configuration.GetConfigValue("CheckScannerDonationsQueueName"); // ReSharper disable once PossibleNullReferenceException _donationsQueue = messageQueueFactory.CreateQueue(donationsQueueName, QueueAccessMode.Send); _messageFactory = messageFactory; } }
public AzureMessageQueue(AzureMessageQueueConnection connection, IMessageQueueFactory queueFactory) : base(connection, queueFactory) { AzureConnection = connection; switch (connection.Pattern) { case MessagePattern.PublishSubscribe: if (connection.Direction == Direction.Inbound) { Queue = new AzureSubscriptionClient(connection); } else { Queue = new AzureTopicClient(connection); } break; default: Queue = new AzureQueueClient(connection); break; } }
CreateHandlerMockWithStreamExpectation( ChaincodeMessage responseMessage, IClientStreamWriter <ChaincodeMessage> requestStream = null, IMessageQueueFactory messageQueueFactory = null, IChaincodeStubFactory chaincodeStubFactory = null, IChaincode chaincode = null ) { var responseStreamMock = new Mock <IAsyncStreamReader <ChaincodeMessage> >(); responseStreamMock.SetupSequence(m => m.MoveNext(It.IsAny <CancellationToken>())) .ReturnsAsync(true) .ReturnsAsync(false); responseStreamMock.Setup(m => m.Current) .Returns(responseMessage); var asyncDuplexStream = new AsyncDuplexStreamingCall <ChaincodeMessage, ChaincodeMessage>( requestStream ?? new Mock <IClientStreamWriter <ChaincodeMessage> >().Object, responseStreamMock.Object, null, null, null, null ); var chaincodeSupportClientMock = new Mock <ChaincodeSupport.ChaincodeSupportClient>(); chaincodeSupportClientMock.Setup(m => m.Register(null, null, It.IsAny <CancellationToken>())) .Returns(asyncDuplexStream); var chaincodeSupportClientFactoryMock = new Mock <IChaincodeSupportClientFactory>(); chaincodeSupportClientFactoryMock.Setup(m => m.Create(It.IsAny <Channel>())) .Returns(chaincodeSupportClientMock.Object); var handler = CreateHandler(messageQueueFactory ?? new Mock <IMessageQueueFactory>().Object, chaincodeSupportClientFactoryMock.Object, chaincodeStubFactory, chaincode); return(responseStreamMock, chaincodeSupportClientMock, chaincodeSupportClientFactoryMock, handler); }
public UnsubscribeHandler(ILogger <UnsubscribeHandler> logger, IMessageQueueFactory queueFactory) { _logger = logger; _queueFactory = queueFactory; }
/// <summary> /// Instantiates a <see cref="QueuePublisherFactory"/> /// </summary> /// <param name="messageQueueFactory"></param> public QueuePublisherFactory(IMessageQueueFactory messageQueueFactory) { _messageQueueFactory = messageQueueFactory; }
public UnsubscribeController(IMessageQueueFactory queueFactory) { _userExist = queueFactory.Get("doesuserexist"); _userExistResponse = _userExist.GetResponseQueue(); _unsubscribe = queueFactory.Get("unsubscribe"); }
public MessageQueueBase(IMessageQueueConnection connection, IMessageQueueFactory queueFactory) { Connection = connection; QueueFactory = queueFactory; }
public QueueProcessor(QueueProcessorConfig <T> queueProcessorConfig, IMessageQueueFactory messageQueueFactory) { _config = queueProcessorConfig; _queue = messageQueueFactory.CreateQueue(_config.QueueName, QueueAccessMode.Receive, _config.MessageFormatter); }
/// <summary> /// Parameterized Constructor. /// </summary> public DefaultEventProcessor(IMessageQueueFactory queueFactory, IEventExecutor eventExecutor, IMessageStore messageStore, ITextSerializer serializer) : base("Event", queueFactory.CreateGroup(10), eventExecutor, messageStore, serializer) { }
public UnsubscribeWorkflow(string emailAddress, IMessageQueueFactory queueFactory) { EmailAddress = emailAddress; _queueFactory = queueFactory; }