none
Queue Message - delete after firing

    Question

  • I have a Webjob that handles queue messages that should become visible in an hour. When it fires in an hour and is processed in the WebJob...I recreate the message with visibility in an hour. So the message for this subscriber gets fired/handled once an hour, every hour. How can I delete the message before I recreate it? They all have the same name... If I don't delete the queued message that fired they seem to be reappearing. I know I am missing something...

    Tuesday, April 12, 2016 11:22 AM

All replies

  • You can delete the message from the queue after retrieving it, and before adding the new message.

    q.DeleteMessage(msg);

    Tuesday, April 12, 2016 4:25 PM
  • I get the message in my QueueTrigger function in the WebJob - "newsubscriber": 

      public static async Task AddNewSubscriber(
              [QueueTrigger("newsubscriber")] NewSubscriber subscriber,
              [Queue("processsubscriber")] ICollector<NewSubscriber> alertMessageCollector,
              TextWriter logger)
            {
                var alertProcessor = new AlertProcessor(new CollectorAlertService(alertMessageCollector));
                await alertProcessor.AddSubscriberToQueue(subscriber);
              
            }
    How do I get a reference to this message just triggered?


    • Edited by Donate IAP Tuesday, April 12, 2016 5:03 PM edit
    Tuesday, April 12, 2016 5:02 PM
  • you shouldn't have to do anything special to delete the message that triggered the webjob function... webjob does that for you already (assuming no error, otherwise it will retry and then eventually move the message to the poison queue if continues to fail).

    are you sure it's re-appearing and it's not the newly enqueued message that causes the trigger again?

    Wednesday, April 13, 2016 3:59 PM
  • Yup...it was a couple of old exceptions requeued. I would still like to be able to access the queuetriggerd/current message somehow...
    Wednesday, April 13, 2016 4:30 PM