[Java]: Changed algorithm for determining the active buffer index so that Publications are prepared to used activeTermId stored in SHM.