Implementing GatewayEventQueue and helpers. Introducing persistence for messages on gateways [refs #336]

Some parts are missing yet:

- integration of the GatewayEventQueue into the channel handler
- error handling in the GatewayEventQueueImpl
- tests