Applications and services in ubiquitous computing systems often interact in a context-dependent, reactive manner. How information flows, and what services communicate when, is determined by the context of the physical space, the context of users, and the services that are available. Existing discovery systems provide basic facilities for finding services based on their static descriptions in the form of attributes. Context-dependent attributes are not included in the service advertisements as they may in turn be computed and stored in other services. We propose an infrastructure, called River, that provides various contextdependent, reactive communication primitives. These primitives are implemented using a single underlying technique called Relational Query Based Dispatching (RQD), which views the set of services in the system as a federation of databases, the discovery service as a distributed query processor for these databases, and communication as a combination of query processin...