public void TestDeleteMessageType()
        {
            foreach (var dataService in DataServices)
            {
                // Arrange.
                ServiceBusMessageType messageType = new ServiceBusMessageType
                {
                    ID          = "messageType Id",
                    Name        = "messageType Name",
                    Description = "messageType Description"
                };

                var service = new DefaultSubscriptionsManager(dataService, GetMockStatisticsService());
                service.CreateMessageType(messageType);

                // Act && Assert.
                var messageTypesLcs = LoadingCustomizationStruct.GetSimpleStruct(typeof(MessageType), MessageType.Views.EditView);
                var messageTypes    = dataService.LoadObjects(messageTypesLcs).Cast <MessageType>().ToList();

                Assert.Equal(messageTypes.Count(), 1);
                Assert.Equal(messageTypes[0].ID, messageType.ID);
                Assert.Equal(messageTypes[0].Name, messageType.Name);
                Assert.Equal(messageTypes[0].Description, messageType.Description);

                service.DeleteMessageType(messageType.ID);

                var newMessageTypes = dataService.LoadObjects(messageTypesLcs).Cast <MessageType>().ToList();
                Assert.Equal(newMessageTypes.Count(), 0);
            }
        }
        /// <summary>
        /// Обновить тип сообщения.
        /// </summary>
        /// <param name="messageTypeId">Идентификатор типа сообщения.</param>
        /// <param name="messageType">Новые данные типа сообщения.</param>
        public void UpdateMessageType(string messageTypeId, ServiceBusMessageType messageType)
        {
            Guid        primaryKey         = ServiceHelper.ConvertMessageTypeIdToPrimaryKey(messageTypeId, _dataService, _statisticsService);
            MessageType currentMessageType = ServiceHelper.GetMessageType(primaryKey, _dataService, _statisticsService);

            if (messageType.Name != null)
            {
                currentMessageType.Name = messageType.Name;
            }
            if (messageType.Description != null)
            {
                currentMessageType.Description = messageType.Description;
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            _dataService.UpdateObject(currentMessageType);

            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;

            _statisticsService.NotifyAvgTimeSql(null, (int)time, "DefaultSubscriptionsManager.UpdateMessageType() update messageType.");
        }
Beispiel #3
0
        /// <summary>
        /// Создание точки обмена по типу сообщения.
        /// </summary>
        /// <param name="msgTypeInfo">Структура, описывающая тип сообщения.</param>
        public void CreateMessageType(ServiceBusMessageType msgTypeInfo)
        {
            var exchangeName = this._namingManager.GetExchangeName(msgTypeInfo.ID);
            var exchangeInfo = new ExchangeInfo(exchangeName, ExchangeType.Topic, autoDelete: false, durable: true, @internal: false, arguments: null);

            this._managementClient.CreateExchangeAsync(exchangeInfo, _vhost).Wait();
        }
Beispiel #4
0
        public void TestMessageTypeCreate()
        {
            // Arrange.
            var messageTypeInfo = new ServiceBusMessageType {
                ID = "123", Name = "TestMessageType", Description = "ForTest"
            };
            var dataServiceMock = new Mock <IDataService>();
            var service         = new DefaultSubscriptionsManager(dataServiceMock.Object, GetMockStatisticsService());

            // Act.
            service.CreateMessageType(messageTypeInfo);

            // Assert.
            dataServiceMock.Verify(f => f.UpdateObject(It.Is <MessageType>(t => t.ID == messageTypeInfo.ID && t.Name == messageTypeInfo.Name && t.Description == messageTypeInfo.Description)), Times.Once);
        }
        /// <summary>
        /// Создать тип сообщений.
        /// </summary>
        /// <param name="msgTypeInfo">Информация о создаваемом типе сообщений: идентификатор, наименование, комментарий.</param>
        public void CreateMessageType(ServiceBusMessageType msgTypeInfo)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            _dataService.UpdateObject(new MessageType {
                ID = msgTypeInfo.ID, Name = msgTypeInfo.Name, Description = msgTypeInfo.Description
            });

            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;

            _statisticsService.NotifyAvgTimeSql(null, (int)time, "DefaultSubscriptionsManager.CreateMessageType() update TypeMessage.");
        }
        /// <summary>
        /// Subscribes for messages from other instance Flexberry Service Bus.
        /// Clones message types and updates subscriptions in all remote instance Flexberry Service Bus.
        /// </summary>
        /// <param name="cloneMessageTypes">Clone all message types from remote instance Flexberry Service Bus.</param>
        private void Subscribe(bool cloneMessageTypes)
        {
            foreach (Bus serviceBus in _repository.GetAllServiceBuses())
            {
                try
                {
                    _logger.LogDebugMessage(nameof(CrossBusCommunicationService), $"Working with remote SB '{serviceBus.Name ?? "<noname>"}' ({serviceBus.ManagerAddress}).");

                    var client = new ChannelFactory <IServiceBusInterop>(new BasicHttpBinding()).CreateChannel(new EndpointAddress(serviceBus.ManagerAddress));
                    if (client == null)
                    {
                        throw new InvalidOperationException($"Unable to create WCF client to the SB ({serviceBus.ManagerAddress}).");
                    }

                    if (cloneMessageTypes)
                    {
                        NameCommentStruct[] msgTypes = client.GetMsgTypesFromBus(ServiceID4SB);

                        _logger.LogDebugMessage(nameof(CrossBusCommunicationService), $"Loaded {msgTypes.Length} message types from remote SB '{serviceBus.Name ?? "<noname>"}'.");

                        foreach (NameCommentStruct type in msgTypes.Where(type => _repository.GetAllMessageTypes().All(t => t.ID != type.Id)))
                        {
                            _logger.LogDebugMessage(nameof(CrossBusCommunicationService), $"Cloning message type {type.Id} ({type.Name}).");

                            ServiceBusMessageType newType = new ServiceBusMessageType {
                                Name = type.Name, Description = type.Comment, ID = type.Id
                            };
                            _subscriptionsManager.CreateMessageType(newType);
                        }
                    }
                    else
                    {
                        client.UpdateClientSubscribesForMsgs(ServiceID4SB);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogUnhandledException(e, title: nameof(CrossBusCommunicationService));
                }
            }
        }
Beispiel #7
0
 public void UpdateMessageType(string messageTypeId, ServiceBusMessageType messageType)
 {
     throw new NotImplementedException();
 }
Beispiel #8
0
 /// <summary>
 /// Создание точки обмена для события.
 /// В RabbitMQ аналогично созданию обычного типа сообщения.
 /// </summary>
 /// <param name="eventTypeInfo">Структура, описывающая тип сообщения.</param>
 public void CreateEventType(ServiceBusMessageType eventTypeInfo)
 {
     this.CreateMessageType(eventTypeInfo);
 }