Process each message in a DB transaction (controlled by global setting)

Change-Id: Id1b280cf11c1a10d301bd9a5e1392f0a8ec302f5