Refactored message consuming process.