A multi-agent system architecture for coordination of just-in-time production and distribution is presented. The problem to solve is two-fold: first the right amount of resources at the right time should be produced, and then these resources should be distributed to the right consumers. In order to solve the first problem, which is hard when the production and/or distribution time is relatively long, each consumer is equipped with an agent that makes predictions of future needs that it sends to a production agent. The second part of the problem is approached by forming clusters of consumers within which it is possible to redistribute resources fast and at a low cost in order to cope with discrepancies between predicted and actual consumption. Redistribution agents are introduced (one for each cluster) to manage the redistribution of resources. The suggested architecture is evaluated in a case study concerning management of district heating systems. Results from a simulation study show...