Refactored code implementing message posting in streams