Exemple #1
0
        /// <summary>
        /// Creates the required Sns topic in the configured Sns instance.
        /// Also creates an <see cref="SnsEventVerifier"/> for the topic.
        /// </summary>
        /// <typeparam name="T">The type used for the event payload</typeparam>
        /// <param name="topicName">The topic name required</param>
        /// <param name="topicArnEnvVarName">The name of the environment variable against which the created topic arn will be set.</param>
        /// <param name="snsAttrs">(Optional) List of additional attributes to use in the topic creation.</param>
        /// <returns>Task</returns>
        /// <exception cref="System.ArgumentNullException">If the topicName or topicArnEnvVarName are not provided</exception>
        public void CreateSnsTopic <T>(string topicName, string topicArnEnvVarName, Dictionary <string, string> snsAttrs = null) where T : class
        {
            if (string.IsNullOrEmpty(topicName))
            {
                throw new ArgumentNullException(nameof(topicName));
            }
            if (string.IsNullOrEmpty(topicArnEnvVarName))
            {
                throw new ArgumentNullException(nameof(topicArnEnvVarName));
            }

            snsAttrs = snsAttrs ?? new Dictionary <string, string>();
            snsAttrs.Add("fifo_topic", "true");
            snsAttrs.Add("content_based_deduplication", "true");

            var response = SimpleNotificationService.CreateTopicAsync(new CreateTopicRequest
            {
                Name       = topicName,
                Attributes = snsAttrs
            }).Result;

            Environment.SetEnvironmentVariable(topicArnEnvVarName, response.TopicArn);

            _snsVerifers[typeof(T).Name] = (new SnsEventVerifier(AmazonSQS, SimpleNotificationService, response.TopicArn));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var username = "******";
            var password = "******";
            var factory  = new ConnectionFactory()
            {
                HostName = "192.168.68.109",
                UserName = username,
                Password = password
            };

            using var conn = factory.CreateConnection();

            var exchangeName        = "rtsh_topics";
            var routeKey            = "master.control.*";
            var messenger           = new Messenger();
            var logManager          = new LogManager();
            var notificationService = new SimpleNotificationService();
            var backgroundHandler   = new SimpleBackgroundHandler(messenger, logManager, notificationService);

            var rabbitManager = new RabbitControlledDeviceManager();
            var mp            = new MasterControlProcessor(rabbitManager, backgroundHandler);

            var firstConsumer = new MasterControlConsumer(conn, null, exchangeName, routeKey).WithPrefetchCount(100);

            firstConsumer.Consume();



            Console.ReadLine();
        }
Exemple #3
0
        public static void Main()
        {
            IServiceLocator serviceLocator = TypeRegistry.RegisterTypes();

            SimpleNotificationService simpleNotificationService = serviceLocator.GetInstance <SimpleNotificationService>();

            ExceptionLogger.Instance.SetUpServices(simpleNotificationService);

            RepricingScript repricingScript = serviceLocator.GetInstance <RepricingScript>();

            repricingScript.Run();

            ExceptionLogger.Instance.LogMessage("Press any key to continue");
            Console.ReadLine();
        }
        private void CreateSnsTopic()
        {
            var snsAttrs = new Dictionary <string, string>();

            snsAttrs.Add("fifo_topic", "true");
            snsAttrs.Add("content_based_deduplication", "true");

            var response = SimpleNotificationService.CreateTopicAsync(new CreateTopicRequest
            {
                Name       = "repairs",
                Attributes = snsAttrs
            }).Result;

            var logger = TestContext.Out;

            logger.WriteLine($"Topic ARN: {response.TopicArn}");

            Environment.SetEnvironmentVariable("REPAIRS_SNS_ARN", response.TopicArn);
        }
Exemple #5
0
 public void SetUpServices(SimpleNotificationService simpleNotificationService)
 {
     m_simpleNotificationService = simpleNotificationService;
 }