Depends on your queue semantics, ie is it just an at least once delivery or is there an ack back to the queue service.
If there is a two phase process then you just need idempotence and can safely transact with the db.
If there is a two phase process then you just need idempotence and can safely transact with the db.