extract method to process publish message