fix bug of formatKey()

the function can't deal with None in routingKey.
use datetime instead of datetime.datetime in _toJson