How would you implement a pub/sub messaging system?

Technical