Smart building management systems become very popular research topics due to high energy consumption of buildings in developed countries. Proposed approaches in the literature commonly focus on smart building energy management systems to improve this high consumption and on network communications between deployed devices. However, these approaches are specialized for a single monitoring application, and adopt static wireless sensor device configurations. In this study, we focus on the energy and lifetime of the monitoring architecture itself. We consider a monitoring system as a set of applications that exploit sensor measures in real-time, where these applications are declaratively expressed as (service-oriented) continuous queries over sensor data streams. We tackle the optimization of interactions between application real-time requirements for data and wireless sensor devices that produces those data. In this context, we present a novel approach, an energy-aware dynamic sensor configuration mechanism for a sustainable declarative monitoring architecture that can support multiple applications. We first introduce formalization of application requirements and sensor configuration based on data acquisition/transmission and continuous stream queries. We then propose a self-adaptive energy-aware algorithm that dynamically generates optimized sensor configurations based on real-time query requirements. We also present a SmartService Stream-oriented Sensor Management (3SoSM) Gateway that optimizes sensor configurations and manages sensor data streams. Finally, we present a set of experiments we conducted with a wireless sensor network simulator and with a real Smart Building platform.