Ejemplo n.º 1
0
        /// <summary>
        /// To initialize the service bus
        /// </summary>
        public async Task <bool> InitServiceBus()
        {
            var fqdn = ConfigurationManager.AppSettings["SB.Fqdn"];
            var ns   = ConfigurationManager.AppSettings["SB.Ns"];
            var hp   = ConfigurationManager.AppSettings["SB.HttpPort"];
            var tp   = ConfigurationManager.AppSettings["SB.TcpPort"];

            if (fqdn is null || ns is null || hp is null || tp is null)
            {
                logger.Debug("One of configuration manager expected values is null");
                return(false);
            }
            var hpi = int.Parse(hp);
            var tpi = int.Parse(tp);

            sbc.Log += Sbc_Log;
            bool ret = await sbc.Connect(EndpointUrl);

            logger.Debug($"sbc.Connect returned {ret}");
            sbc.Message += Sbc_Message;
            await sbc.ListenTo(TopicName, SubscriptionName /*, filterString*/);

            //_CoreService = ServiceProxy.Create<ICoreService>(new Uri("fabric:/Assistant/CoreService"));

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Endpoint URL for Service Bus
        /// </summary>
        private void Amqc_LineTopicMessage(object sender, OnMessageEventArgs e)
        {
            logger.Trace(sender.ToString() + "Amqc_LineTopicMessage called");
            //OldRouterCode(e.Content, e.Properties["ContentType"] as string);

            //Changes for Configurator DTO.
            var contentType = e.Properties["ContentType"] as string;

            if (contentType.CompareTo(BrokerCommands.CONFIGURE_ROUTES) == 0)
            {
                var isOk = BreanosConnectors.SerializationHelper.TryUnpack(e.Content, out RoutingRequest registrationRequest);
                if (!isOk)
                {
                    logger.Warn($"Unpack not successfull in Amqc_LineTopicMessage");
                }
                if (_router == null)
                {
                    logger.Debug($"_router was initialized in Amqc_LineTopicMessage");
                    _router = new ConfigurableContentTypeRouter();//new ContentTypeRouter(JsonDirectory);
                }

                (_router as ConfigurableContentTypeRouter).Config(registrationRequest);
            }
            RouterCode(e.Content, e.Properties["ContentType"] as string, e.Properties);
        }
Ejemplo n.º 3
0
        public async Task <bool> Init(int id, string action, BlackboardData arguments)
        {
            logger.Debug(string.Format("Init called with parameter {0},{1}", id, action));
            bool ret = await InitBlackboard();

            return(await Task.FromResult <bool>(true));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Diese Methode Startet die Nachrichtenverarbeitung
        /// </summary>
        public void StartProcessing()
        {
            logger.Debug("StartProcessing called in controller");

            Task.Factory.StartNew(() =>
            {
                logger.Debug("Start new Task in StartProcessing");

                while (true)
                {
                    foreach (IKnowledgeSource ks in OrderedKnowledgeSources)
                    {
                        if (ks.IsEnabled)
                        {
                            ks.ExecuteAction();
                        }
                    }
                }
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Service Bus helper
        /// </summary>
        /// <returns></returns>
        private bool CreateSubscription()
        {
            try
            {
                MessagingFactory = MessagingFactory.Create();

                NamespaceManager = NamespaceManager.Create();

                if (!NamespaceManager.SubscriptionExists(TopicName, SubscriptionName))
                {
                    logger.Trace("Subscription does not exist, create one.");
                    NamespaceManager.CreateSubscription(TopicName, SubscriptionName);
                }
                Client = MessagingFactory.CreateSubscriptionClient(TopicName, SubscriptionName, ReceiveMode.PeekLock);
                logger.Debug("Service Bus is ready");
            }
            catch (Exception e)
            {
                logger.Trace("Init exception caught {0}", e.ToString());
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
 public Task <bool> Init()
 {
     logger.Debug("Hello from Init");
     return(Task.FromResult <bool>(true));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Jede KS kennt das Blackboard
 /// </summary>
 /// <param name="blackboard"></param>
 public virtual void Configure(Blackboard.Blackboard blackboard)
 {
     logger.Debug("KnowledgeSourceBase.Configure called");
     this.blackboard = blackboard;
 }