Example #1
0
        /// <summary>
        /// Initialize instance
        /// </summary>
        public override void Initialize(MessageInstance messageInstance)
        {
            //We always have subscribers
            HasSubscribers = true;

            //Check if port is defined
            var foundport = Config.TryGetEnvVariable("NetMQRunnerPort", Config.GlobalConfig.NetMQRunnerPort);

            if (string.IsNullOrWhiteSpace(foundport) || !int.TryParse(foundport, out var port))
            {
                throw new Exception($"Could not find port number in configuration for setting up outbound event messages. Please set the port number in Global config or via environment variable.");
            }

            //Check if port is available for usage
            if (!Util.CheckPortAvailability(port))
            {
                throw new Exception($"Port with number {port} is unavailable. Cannot start EventRunner, please check your firewall settings or if the port is already in use by another application");
            }

            //Initialize socket
            _socket = new PublisherSocket("@tcp://*:" + port);

            //Set default manipulation logic (so we only send deltas)
            EventKeeper.SetManipulationLogic(EventMessageType.PerformanceInfo, EventKeeper.DefaultManipulationLogic(EventMessageType.PerformanceInfo));

            //Send data asap (1ms)
            MinWait = 1;
        }
Example #2
0
        /// <summary>
        /// Initialize instance
        /// </summary>
        /// <exception cref="Exception"></exception>
        public override void Initialize(MessageInstance messageInstance)
        {
            //We always have subscribers
            HasSubscribers = true;

            //Get dweet url
            _dweetUrl = Environment.GetEnvironmentVariable("dweeturl");

            //Check url
            if (!Uri.IsWellFormedUriString(_dweetUrl, UriKind.RelativeOrAbsolute))
            {
                throw new Exception($"Incorrect dweet url was supplied: {_dweetUrl}");
            }

            //Slow down the sending interval
            int minsecondsinterval = 5; //Will only send updates every 5 seconds

            EventKeeper.SetCompareLogic((prev, current) =>
                                        !prev.Equals(current) &&
                                        (current.OccuredUtc - prev.OccuredUtc).TotalSeconds > minsecondsinterval);

            //We are not be able to send performance information as it is larger than 2.000 characters
            //You can always add a manipulator to make the message smaller (only sending the data you want to show via dweet)
            EventKeeper.SetCompareLogic(EventMessageType.PerformanceInfo, (prev, current) => false);
        }