improve session.publish robustness. Prevents session.publish from being called multiple times