Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get notifications from my TFS server, when a work item is changed?

Tags:

tfs

I am writing a simple custom work item browser and I'd like it to follow the real-time changes happening to work items on my TFS server.

For example, if someone has changed a work item's Title or State, I'd update my work item tree with this new information.

How can I subscribe to such events?

like image 962
Max Galkin Avatar asked Feb 27 '10 14:02

Max Galkin


1 Answers

You can use the TFS eventing mechanism to subscribe a web service endpoint to get notified when a work item changes. However this is designed for server->server communication and this push notification mechanism does not work well for client applications.

Instead I would recommend that you use the TFS .NET Api to poll the server periodically for updates. To make the poll operation efficient after you have got a full set of results using your query, you could modify the WIQL to just look for work items where the changed date is greater than the last time that you polled the server.

The reason the "pull" model works better than the "push" model in this case is as follow:

  1. To send a web service push notification to your client machine, the TFS instance needs to be able to talk directly to the port on your client box. That means that you must have the appropriate port open and allow traffic in that direction from you firewall.
  2. Push notifications need Team Foundation Server Administration level user permissions to create which means that only Administration users can use your application
  3. The server will attempt to send notifications to the subscribers until the subscriber removes the event subscription. This means that is your application crashes or doesn't clean up it's subscriptions correctly then the server will be attempting to send messages to machines that are not listening for them. This will use up resources on your TFS server and generate errors in the TFS Server event logs. Your application will need a significant amount of logic to ensure that it records which subscriptions are in place and manage them appropriately.

Hope that makes sense.

like image 145
Martin Woodward Avatar answered Oct 26 '22 03:10

Martin Woodward