@Bean
  public ConnectionFactory amqConnectionFactory() {
    CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
    ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
    activeMQConnectionFactory.setBrokerURL("vm://localhost?broker.persistent=false");

    cachingConnectionFactory.setTargetConnectionFactory(activeMQConnectionFactory);
    cachingConnectionFactory.setSessionCacheSize(10);
    cachingConnectionFactory.setCacheProducers(true);
    cachingConnectionFactory.setReconnectOnException(true);
    return cachingConnectionFactory;
  }