[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 833
  • Last Modified:

Using timer in Webservice to access Message queues

I need to create a webservice which checks if there are any messages in the Message queue.
If there are messages it gets them and processes them as required.

I need the webservice to check these messages periodically every few minutes. I have never used a timer in the web service. Is this doable?

Any help will be greatly appreciated. I will be developing this web service in vb.net.

Thanks in advance.
  • 2
2 Solutions
Well it can be done but not directly.

Create a webmethods call do work with a timer in it. The timer talks to the queue every tick. But this method has to be triggered by someone.

We can create another wbmethods called stop work which will write to a database or file which the DoWork method reads periodically to break the timer loop.

As far as i know there is no way for a web service to start behaving like a windows service and start pooling the moment the web service starts.
Jai STech ArchCommented:
Web Services are listeners, they should not be used to perform TIMER like tasks...

better to write a separate Serviced component(i mean like windows services) and and put it in the services which will always be listenning...
sorry for not being clear. What i meant by a timer was not the TIMER class in the framework but a while loop with a sleep. With this you wil be able to achieve exact what the timer does.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now