We consider a beam of two-level randomly excited atoms that pass one-by-one through a one-mode cavity. We show that in the case of an ideal cavity, i.e. no leaking of photons from the cavity, the pumping by the beam leads to an unlimited increase in the photon number in the cavity. We derive an expression for the mean photon number for all times. Taking into account leaking of the cavity, we prove that the mean photon number in the cavity stabilizes in time. The limiting state of the cavity in this case exists and it is independent of the initial state. We calculate the characteristic functional of this non-quasi-free non-equilibrium state. We also calculate the total energy variation in both the ideal and the open cavities as well as the entropy production in the ideal cavity.