Added support for prioritized responses in publishAndWait function