Implement gateway logic for PUB messages.