/** Configures the given connection factory */
 public void configure(ActiveMQConnectionFactory factory, MessageActivationSpec activationSpec) {
   if (serverUrl != null) {
     factory.setBrokerURL(serverUrl);
   }
   if (clientid != null) {
     factory.setClientID(clientid);
   }
   if (redeliveryPolicy != null) {
     factory.setRedeliveryPolicy(redeliveryPolicy);
   }
   if (prefetchPolicy != null) {
     factory.setPrefetchPolicy(prefetchPolicy);
   }
   if (factory instanceof ActiveMQSslConnectionFactory) {
     String trustStore =
         defaultValue(
             activationSpec == null ? null : activationSpec.getTrustStore(), getTrustStore());
     String trustStorePassword =
         defaultValue(
             activationSpec == null ? null : activationSpec.getTrustStorePassword(),
             getTrustStorePassword());
     String keyStore =
         defaultValue(activationSpec == null ? null : activationSpec.getKeyStore(), getKeyStore());
     String keyStorePassword =
         defaultValue(
             activationSpec == null ? null : activationSpec.getKeyStorePassword(),
             getKeyStorePassword());
     String keyStoreKeyPassword =
         defaultValue(
             activationSpec == null ? null : activationSpec.getKeyStoreKeyPassword(),
             getKeyStoreKeyPassword());
     ActiveMQSslConnectionFactory sslFactory = (ActiveMQSslConnectionFactory) factory;
     if (trustStore != null) {
       try {
         sslFactory.setTrustStore(trustStore);
       } catch (Exception e) {
         log.warn("Unable to set TrustStore", e);
       }
     }
     if (trustStorePassword != null) {
       sslFactory.setTrustStorePassword(trustStorePassword);
     }
     if (keyStore != null) {
       try {
         sslFactory.setKeyStore(keyStore);
       } catch (Exception e) {
         log.warn("Unable to set KeyStore", e);
       }
     }
     if (keyStorePassword != null) {
       sslFactory.setKeyStorePassword(keyStorePassword);
     }
     if (keyStoreKeyPassword != null) {
       sslFactory.setKeyStoreKeyPassword(keyStoreKeyPassword);
     }
   }
 }
 protected ConnectionFactory createConnectionFactory(final BrokerService broker) throws Exception {
   String url = broker.getTransportConnectors().get(0).getServer().getConnectURI().toString();
   ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
   connectionFactory.setOptimizedMessageDispatch(true);
   connectionFactory.setCopyMessageOnSend(false);
   connectionFactory.setUseCompression(false);
   connectionFactory.setDispatchAsync(false);
   connectionFactory.setUseAsyncSend(false);
   connectionFactory.setOptimizeAcknowledge(false);
   connectionFactory.setWatchTopicAdvisories(true);
   ActiveMQPrefetchPolicy qPrefetchPolicy = new ActiveMQPrefetchPolicy();
   qPrefetchPolicy.setQueuePrefetch(100);
   qPrefetchPolicy.setTopicPrefetch(1000);
   connectionFactory.setPrefetchPolicy(qPrefetchPolicy);
   connectionFactory.setAlwaysSyncSend(true);
   return connectionFactory;
 }