@Override
 public void publish(EventMessage... events) {
   final Channel channel = connectionFactory.createConnection().createChannel(isTransactional);
   try {
     for (EventMessage event : events) {
       doSendMessage(
           channel,
           routingKeyResolver.resolveRoutingKey(event),
           asByteArray(event),
           isDurable ? DURABLE : null);
     }
     if (CurrentUnitOfWork.isStarted()) {
       CurrentUnitOfWork.get().registerListener(new ChannelTransactionUnitOfWorkListener(channel));
     } else if (isTransactional) {
       channel.txCommit();
     }
   } catch (IOException e) {
     if (isTransactional) {
       tryRollback(channel);
     }
     throw new EventPublicationFailedException(
         "Failed to dispatch Events to the Message Broker.", e);
   } catch (ShutdownSignalException e) {
     throw new EventPublicationFailedException(
         "Failed to dispatch Events to the Message Broker.", e);
   } finally {
     if (!CurrentUnitOfWork.isStarted()) {
       tryClose(channel);
     }
   }
 }
 @After
 public void tearDown() throws Exception {
   scheduledThreadPool.shutdownNow();
   while (CurrentUnitOfWork.isStarted()) {
     CurrentUnitOfWork.get().rollback();
   }
 }