示例#1
0
        public async void Feed(Message message)
        {
            if (message.LeadScoreConditionType == (int)LeadScoreConditionType.WorkflowActivated)
            {
                IEnumerable <Message> messages = await loadWorkflow((short)message.EntityId, message.AccountId);

                client.Complete(message.LockToken);

                foreach (var feedMessage in messages)
                {
                    blockingCollection.Add(feedMessage);
                }
            }
            else if (message.LeadScoreConditionType == (int)LeadScoreConditionType.WorkflowInactive || message.LeadScoreConditionType == (int)LeadScoreConditionType.WorkflowPaused)
            {
                AutomationWorkflow workflow = null;
                bool result = automationWorkflows.TryRemove(message.EntityId, out workflow);
                if (message.ConditionValue != null && message.ConditionValue.Equals("delayed") && message.ConditionValue.Equals("delayed"))
                {
                    workflowService.DeactivateWorkflow(new DeactivateWorkflowRequest()
                    {
                        WorkflowId = message.EntityId
                    });
                }

                if (result && workflow != null)
                {
                    client.Complete(message.LockToken);
                }
            }
            else
            {
                blockingCollection.Add(message);
            }
        }
示例#2
0
        void consumeMessages()
        {
            MessageProcessor processor = new MessageProcessor();

            foreach (Message message in blockingCollection.GetConsumingEnumerable())
            {
                Logger.Current.Informational("Processing message:" + message.MessageId);
                MessageHandlerStatus status = processor.Process(message);
                if (status == MessageHandlerStatus.LeadScoreAuditedSuccessfully)
                {
                    client.Complete(message.LockToken);
                    Logger.Current.Informational("Processed message, marked as complete:" + message.MessageId);
                }
                else if (status == MessageHandlerStatus.LeadScoreRuleNotDefined)
                {
                    client.Complete(message.LockToken);
                    Logger.Current.Informational("Rule not defined for this message, marked as complete:" + message.MessageId);
                }
                else if (status == MessageHandlerStatus.InvalidMessageHandler)
                {
                    client.Complete(message.LockToken);
                    Logger.Current.Informational("Handler not defined for this message, marked as complete:" + message.MessageId);
                }
                else if (status == MessageHandlerStatus.DuplicateLeadScoreRequest)
                {
                    client.Complete(message.LockToken);
                    Logger.Current.Informational("A duplicate lead score request, marked as complete:" + message.MessageId);
                }
                else if (status == MessageHandlerStatus.FailedToAuditScore)
                {
                    client.Abandon(message.LockToken);
                    Logger.Current.Informational("Failed to process this message, Abandoned message to fall back in the queue:" + message.MessageId);
                }
            }
        }
示例#3
0
        // Delete the first published message from service bus subscription
        public void RemoveFirstPublishedMessage(string ServiceBusConnectionString, string TopicName, string SubscriptionName)
        {
            // Create service Bus namespace manager
            var namespaceManager = NamespaceManager.CreateFromConnectionString(ServiceBusConnectionString);
            // Get subscrition information of the topic
            var subscriptionDesc = namespaceManager.GetSubscription(TopicName, SubscriptionName);
            // Check number of published messages
            long messageCount = subscriptionDesc.MessageCount;

            // Skip removing message if none exists
            if (messageCount != 0)
            {
                // Create service bus messageing factory
                Factory = MessagingFactory.CreateFromConnectionString(ServiceBusConnectionString);
                // Create subscription client for the topic
                SubscriptionClient mySubscriptionClient = Factory.CreateSubscriptionClient(TopicName, SubscriptionName);

                // Get first broker message from the subscription.
                // Use Receive function
                BrokeredMessage MessageReceived = mySubscriptionClient.Receive();

                // Use lock token of the received brokered message to mark the message is completed.
                // The message will be removed from the subscription
                mySubscriptionClient.Complete(MessageReceived.LockToken);

                //Clean up
                MessageReceived.Dispose();
                mySubscriptionClient.Close();
            }
        }
示例#4
0
 private void btnConfirm_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         m_clientAll.Complete(m_msg.LockToken);
         txtInfo.Text = "";
     }
     catch (Exception ex)
     {
         //Too slow,lock timeout, message was processed on another station
     }
     btnConfirm.IsEnabled = false;
     Task.Factory.StartNew(waitForMessage);
 }
示例#5
0
        public void Receive()
        {
            _client.OnMessage(m =>
            {
                Console.WriteLine("Message body: " + m.GetBody <String>());
                Console.WriteLine("Message id: " + m.MessageId);

                _client.Complete(m.LockToken);

                Thread.Sleep(1000);
            }, new OnMessageOptions()
            {
                AutoComplete = false
            });
        }