Abstract-The complexity of handling multiple -often conflicting -tasks, coupled with the collaboration required by wireless sensor network (WSN) nodes to accomplish such tasks, exacerbate concerns about the effectiveness and longevity of the network. Handling multiple dynamic contexts and offering autonomic context-aware WSN management are severely limited by the network's resource constraints. This may affect the ability of sensors to join fully or partially in the missions of the network, restricting the quality of users' experience. Moreover, WSNs should work unattended and cannot assume global visibility or centralized services. Hence, we conceptualize next generation WSNs as autonomous distributed systems capable of dynamic and adaptive reconfiguration. Such networks should be capable of performing dynamic task allocation according to application demand, network conditions, and task context. In this paper we present an efficient distributed task allocation method for WSNs. We look at the task allocation problem in WSNs from a new perspective, where we show how it can be mapped to a clustering problem, and we leverage our previously proposed Affinity Propagation (AP) inspired clustering protocol [1] to solve it. We contrast our approach against both optimal and naïve greedy solutions. By means of simulation, we show that our method is capable of achieving near-optimal results at only a fraction of the optimal solution cost.