예제 #1
0
        public bool InitActiveMQ()
        {
            try
            {
                AddEvent("ActiveMQ ClientId: " + ClientId);
                AddEvent("Trying to connect to ActiveMQ at: " + _activeMQSettings.BrokerUri);

                IConnectionFactory factory = new ConnectionFactory(_activeMQSettings.BrokerUri, ClientId);
                _connection = factory.CreateConnection();
                AQSession = _connection.CreateSession();

                AddEvent("ActiveMQ session was successfully created");

                AQSubscriberConceptNew = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameConceptNew);
                AQSubscriberKEUIRequest = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameKEUIRequest);
                // TODO: uncomment the next line. only for debugging purposes we directly subscribe to the forum sensor
                AQSubscriberForumPost = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameForumPost);
                //AQSubscriberForumPost = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameForumSensorPublishForumPost);
                AQSubscriberIssueNew = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameIssueNew);
                AQSubscriberIssueUpdate = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameIssueUpdate);
                AQSubscriberEmail = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameEmail);
                AQSubscriberSourceCode = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameCommit);
                AQSubscriberWikiPostNew = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameWikiPostNew);
                AQSubscriberWikiPostModified = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameWikiPostModified);
                AQSubscriberWikiPostDeleted = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameWikiPostDeleted);
                AQSubscriberTextToAnnotate = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameTextToAnnotate);
                AQSubscriberCustomItemToIndex = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameCustomItemToIndex);
                AQSubscriberIdentitySnapshot = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameIdentitySnapshot);

                AQSubscriberConceptNew.OnMessageReceived += AQSubscriberConceptNew_OnMessageReceived;
                AQSubscriberKEUIRequest.OnMessageReceived += AQSubscriberKEUIRequest_OnMessageReceived;
                AQSubscriberForumPost.OnMessageReceived += AQSubscriberForumPost_OnMessageReceived;
                AQSubscriberIssueNew.OnMessageReceived += AQSubscriberIssueNew_OnMessageReceived;
                AQSubscriberIssueUpdate.OnMessageReceived += AQSubscriberIssueUpdate_OnMessageReceived;
                AQSubscriberEmail.OnMessageReceived += AQSubscriberEmail_OnMessageReceived;
                AQSubscriberSourceCode.OnMessageReceived += AQSubscriberCommit_OnMessageReceived;
                AQSubscriberWikiPostNew.OnMessageReceived += AQSubscriberWikiPostNew_OnMessageReceived;
                AQSubscriberWikiPostModified.OnMessageReceived += AQSubscriberWikiPostModified_OnMessageReceived;
                AQSubscriberWikiPostDeleted.OnMessageReceived += AQSubscriberWikiPostDeleted_OnMessageReceived;
                AQSubscriberTextToAnnotate.OnMessageReceived += AQSubscriberTextToAnnotate_OnMessageReceived;
                AQSubscriberCustomItemToIndex.OnMessageReceived += AQSubscriberCustomItemToIndex_OnMessageReceived;
                AQSubscriberIdentitySnapshot.OnMessageReceived += AQSubscriberIdentitySnapshot_OnMessageReceived;

                AQSubscriberConceptNew.Start(AQConsumerConceptNewId);
                AQSubscriberKEUIRequest.Start(AQConsumerKEUIRequestId);
                AQSubscriberForumPost.Start(AQConsumerForumPostId);
                AQSubscriberIssueNew.Start(AQConsumerBugPostId);
                AQSubscriberIssueUpdate.Start(AQConsumerBugCommentId);
                AQSubscriberEmail.Start(AQConsumerEmailId);
                AQSubscriberSourceCode.Start(AQConsumerSourceCodeId);
                AQSubscriberWikiPostNew.Start(AQConsumerWikiPostNewId);
                AQSubscriberWikiPostModified.Start(AQConsumerWikiPostModifiedId);
                AQSubscriberWikiPostDeleted.Start(AQConsumerWikiPostDeletedId);
                AQSubscriberTextToAnnotate.Start(AQConsumerTextToAnnotateId);
                AQSubscriberCustomItemToIndex.Start(AQConsumerCustomItemToIndexId);
                AQSubscriberIdentitySnapshot.Start(AQConsumerIdentityUpdatedId);

                // start the connection last. this makes sure that we don't receive any events before we finish starting all the subscribers
                _connection.Start();

                AddEvent("ActiveMQ topic subscribers were created...");
            }
            catch (Exception ex)
            {
                AddEvent("Failed to create ActiveMQ topic subscribers. Error message: " + ex.Message);
                GenLib.Log.LogService.LogException("KEUI.InitActiveMQ exception.", ex);
                return false;
            }
            return true;
        }
        void ProjectSpecificConcepts_Load(object sender, EventArgs e)
        {
            try
            {
                IConnectionFactory factory = new ConnectionFactory(_activeMQSettings.BrokerUri);
                IConnection connection = factory.CreateConnection();
                connection.Start();
                AQSession = connection.CreateSession();

                //AQPublisherKEUI = new ActiveMqHelper.TopicPublisher(AQSession, Defaults.TopicNameKEUIRequest);

                AQSubscriberKEUI = new ActiveMqHelper.TopicSubscriber(AQSession, _activeMQSettings.TopicNameKEUIPublishResponse);
                AQSubscriberKEUI.Start(AQConsumerConceptExtractionId);
                AQSubscriberKEUI.OnMessageReceived += new ActiveMqHelper.TopicSubscriber.MessageReceivedDelegate(KEUIResponse_OnMessageReceived);

                LoadTags();
                SendRequestForTheAnnotationOntology();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while loading: " + ex.Message);
            }
        }