add connection interface and implementation
use Countable interface instead of numMessages()
add reconnect method