This paper presents an energy management scheme for residential microgrids where optimal energy utilization problems are formulated as distributed mixed integer linear programming problems for different types of houses (e.g., houses without solar photovoltaic or batteries, with solar photovoltaic, and with solar photovoltaic as well as batteries). The proposed distributed approach is adopted to solve optimal energy management problems of different houses in a neighborhood. The solutions of the proposed scheme allow different houses to make decisions for optimally utilizing their resources without sharing any private information with the central transactive energy management system. The energy excess and shortage information of different houses, after the optimal resource utilization, are shared with the central transactive energy management system and then with neighbors through a competitive market to ensure the maximum self-reliance as well as the minimum cost for purchasing energy from the grid. Simulation results on different houses in a residential microgrid show the effectiveness of the proposed approach in terms of the optimal resource utilization and effective energy sharing.