A single-server queueing system with an infinite buffer is considered. The service of a customer is possible only in the presence of at least one unit of energy, and during the service the number of available units decreases by one. New units of energy arrive in the system at random instants of time if the finite buffer for maintenance of energy is not full. Customers are impatient and leave the system without service after a random amount of waiting time. Such a queueing system describes, e.g., the operation of a sensor node which harvests energy necessary for information transmission from the environment. Aiming to minimize the loss of customers due to their impatience (and maximize the throughput of the system), a new strategy of control by providing service is proposed. This strategy suggests that service temporarily stops if the number of customers or units of energy in the system becomes zero. The server is switched off (is in sleep mode) for some time. This time finishes (the server wakes up) if both the number of customers in the buffer and the number of energy units reach some fixed threshold values or when the number of energy units reaches some threshold value and there are customers in the buffer. Arrival flows of customers and energy units are assumed to be described by an independent Markovian arrival process. The service time has a phase-type distribution. The system behavior is described by a multi-dimensional Markov chain. The generator of this Markov chain is derived. The ergodicity condition is presented. Expressions for key performance measures are given. Numerical results illustrating the dependence of a customer's loss probability on the thresholds defining the discipline of waking up the server are provided. The importance of the account of correlation in arrival processes is numerically illustrated.