Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();

            string rabbitMQBrokerHost = "localhost";
            string virtualHost        = "command-pipeline";
            string username           = "******";
            string password           = "******";

            string connectionString = string.Format(
                "host={0};virtualHost={1};username={2};password={3}",
                rabbitMQBrokerHost, virtualHost, username, password);

            _bus = RabbitHutch.CreateBus(connectionString);

            _publishBuildCommandChannel  = _bus.OpenPublishChannel(x => x.WithPublisherConfirms());
            _publishSystemCommandChannel = _bus.OpenPublishChannel();

            _buildCommandVM = new CommandViewModel();
            _buildCommandVM.AlertMessage    = "[Alert Message]";
            _buildCommandVM.AnnounceMessage = "Hello Build Slave";

            DataContext = _buildCommandVM;

            _buildCommandVM.BuildSlaveList.Add("cb-slave-1");
            _buildCommandVM.BuildSlaveList.Add("cb-slave-2");
        }
Esempio n. 2
0
 protected virtual void Publish(RoutedEventMessage message, RaiseScope raiseScope = null)
 {
     using (IPublishChannel channel = MessageBus.OpenPublishChannel())
     {
         var messageProperties = new MessageProperties()
         {
             DeliveryMode = 2
         };
         var body = Serializer.MessageToBytes(message);
         channel.Publish(RoutedEventExchange, GetRoutingKey(raiseScope), messageProperties, body);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Schedule a message to be published at some time in the future.
        /// This required the EasyNetQ.Scheduler service to be running.
        /// </summary>
        /// <typeparam name="T">The message type</typeparam>
        /// <param name="publishChannel">The publish channel to publish the future message on</param>
        /// <param name="timeToRespond">The time at which the message should be sent (UTC)</param>
        /// <param name="message">The message to response with</param>
        public static void FuturePublish <T>(this IPublishChannel publishChannel, DateTime timeToRespond, T message)
        {
            Preconditions.CheckNotNull(message, "message");

            var advancedBus = publishChannel.Bus.Advanced;
            var typeName    = advancedBus.SerializeType(typeof(T));
            var messageBody = advancedBus.Serializer.MessageToBytes(message);

            publishChannel.Publish(new ScheduleMe
            {
                WakeTime     = timeToRespond,
                BindingKey   = typeName,
                InnerMessage = messageBody
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Schedule a message to be published at some time in the future.
        /// This required the EasyNetQ.Scheduler service to be running.
        /// </summary>
        /// <typeparam name="T">The message type</typeparam>
        /// <param name="publishChannel">The publish channel to publish the future message on</param>
        /// <param name="timeToRespond">The time at which the message should be sent (UTC)</param>
        /// <param name="message">The message to response with</param>
        public static void FuturePublish <T>(this IPublishChannel publishChannel, DateTime timeToRespond, T message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            var advancedBus = publishChannel.Bus.Advanced;
            var typeName    = advancedBus.SerializeType(typeof(T));
            var messageBody = advancedBus.Serializer.MessageToBytes(message);

            publishChannel.Publish(new ScheduleMe
            {
                WakeTime     = timeToRespond,
                BindingKey   = typeName,
                InnerMessage = messageBody
            });
        }
        private static void CreateReflectyPublisher(Type messageType, MethodInfo closedPublishMethod, string[] filecontents, IPublishChannel channel, CancellationToken token)
        {
            var rnd = new Random();

            while (!token.IsCancellationRequested) //Infinte Loop. Keep publishing until program is stopped.
            {
                var args = new object[1];
                args[0] = Activator.CreateInstance(messageType);
                ((BaseMessage)args[0]).XMLString = filecontents[rnd.Next(filecontents.Length)];
                closedPublishMethod.Invoke(channel, args);
                logger.Log(messageType.Name);
            }
            //var bus = channel.Bus;
            channel.Dispose();
            //bus.Dispose();
        }