add a counter to count the number of the publish messages