The development of middleware for wireless sensor networks (WSNs) places new challenges to middleware developers due to low availability of resources (e.g., memory, processor, bandwidth and power) of sensor nodes. This paper presents the steps of designing, implementing and evaluating a middleware for Wireless Sensor Network (WSNs). The proposed middleware incorporates characteristics of traditional message-oriented middleware systems and an aggregation service that has been specially designed to save energy. In order to illustrate how these features are effective, we carry out an evaluation of the middleware regarding energy consumption.