title: Redis client blocks firebase listeners in Java
body: <p>I'm working in a service that uses Firebase SDK Admin (Java). It used to work fine until I added a Redis client (Jedis) to manage queues. Since that change, my firebase listeners stop working. I don't have any error.</p>
  
  <p><strong>Firebase Listener</strong> - Admin SDK for Java</p>
  
  <pre><code>LOGGER.info("1. Se inicio la sesion de firebase.");
    final FirebaseDatabase database = FirebaseDatabase.getInstance();
    listenerRef = database.getReference(ENVIRONMENT);
    DatabaseReference checkinRef = listenerRef.child(EFirebaseField.CHECKINS.getField());
    DatabaseReference collectRef;
  
    LOGGER.info("2. Carga de listeners de checkin para registro en base de datos.");
  
    checkinRef.orderByChild(EFirebaseField.STATUS.getField())
        .equalTo(EStatusFirebase.STARTED.getField())
        .addChildEventListener(new ChildEventListener() {
  
          @Override
          public void onChildRemoved(DataSnapshot dataSnapshot) {
            LOGGER.debug("Se elimino un checkin STARTED: {} {}", dataSnapshot.getKey(),
                dataSnapshot.getRef());
          }
  
          @Override
          public void onChildMoved(DataSnapshot dataSnapshot, String prevChildKey) {
            LOGGER.debug("Se reubico un checkin STARTED: {} {}", dataSnapshot.getKey(),
                dataSnapshot.getRef());
          }
  
          @Override
          public void onChildChanged(DataSnapshot dataSnapshot, String prevChildKey) {
            LOGGER.debug("Se modifico un checkin STARTED: {} {}", dataSnapshot.getKey(),
                dataSnapshot.getRef());
          }
  
          @Override
          public void onChildAdded(DataSnapshot dataSnapshot, String prevChildKey) {
            LOGGER.info("A. Se agrego un nuevo checkin STARTED: {} {}", dataSnapshot.getKey(),
                dataSnapshot.getRef());
            firebaseActuators.processCheckin(dataSnapshot);
          }
  
          @Override
          public void onCancelled(DatabaseError error) {
            LOGGER.error("Ocurrio un error en checkin STARTED: {}", error.getMessage());
          }
        });
  </code></pre>
  
  <p><strong>Redis Client</strong> - Jedis Client</p>
  
  <pre><code>@Configuration
  @PropertySource({"${propertiesDir:}/database-${envTarget:dev}.properties"})
  
  public class RedisConfig {
  private static final Logger LOGGER_REDIS = LogManager.getLogger(RedisConfig.class);
  
  @Value("${redis.url}")
  private String redisUrl;
  
  @Value("${redis.port}")
  private int redisPort;
  
  @Value("${redis.pw}")
  private String redisPw;
  
  @Value("${redis.maxTotal}")
  private int maxTotal;
  
  @Value("${redis.maxIdle}")
  private int maxIdle;
  
  @Value("${redis.minIdle}")
  private int minIdle;
  
  @Value("${redis.ssl.trustStore}")
  private String trustStore;
  @Value("${redis.ssl.trustStoreType}")
  private String trustStoreType;
  @Value("${redis.ssl.trustStorePassword}")
  private String trustStorePassword;
  @Value("${redis.ssl.keyStore}")
  private String keyStore;
  @Value("${redis.ssl.keyStorePassword}")
  private String keyStorePassword;
  @Value("${redis.ssl.keyStoreType}")
  private String keyStoreType;
  
  @Bean
  public RedisConnectionFactory connectionFactory() {
  try {
  
    System.setProperty("javax.net.ssl.trustStore", trustStore);
    System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);
    System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);     
    System.setProperty("javax.net.ssl.keyStore", keyStore);
    System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
    System.setProperty("javax.net.ssl.keyStoreType", keyStoreType);
  
    JedisConnectionFactory cf = new JedisConnectionFactory(jedisPoolConfig());
    cf.setHostName(redisUrl);
    cf.setPort(redisPort);
    cf.setUseSsl(true);
    cf.setUsePool(true);
    cf.afterPropertiesSet();
    return cf;
  } catch (RedisConnectionFailureException e) {
    LOGGER_REDIS.error("Error de conexion con Redis:" + e.getMessage(), e);
    return null;
  }
  }
  
  @Bean
  public JedisPoolConfig jedisPoolConfig() {
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setMaxTotal(maxTotal);
    jedisPoolConfig.setMaxIdle(maxIdle);
    jedisPoolConfig.setMinIdle(minIdle);
    jedisPoolConfig.setTestOnBorrow(true);
    jedisPoolConfig.setTestOnReturn(true);
    jedisPoolConfig.setTestWhileIdle(true);
    jedisPoolConfig.setMinEvictableIdleTimeMillis(
        Duration.ofSeconds(60).toMillis());
  
    jedisPoolConfig.setTimeBetweenEvictionRunsMillis(
        Duration.ofSeconds(30).toMillis());
    jedisPoolConfig.setNumTestsPerEvictionRun(3);
    jedisPoolConfig.setBlockWhenExhausted(true);
  
    return jedisPoolConfig;
   }
  
   @Bean
   public RedisTemplate&lt;String, Object&gt; redisTemplate(RedisConnectionFactory connectionFactory) {
   RedisTemplate&lt;String, Object&gt; template = new RedisTemplate&lt;&gt;();
  
   if (null == connectionFactory) {
      LOGGER_REDIS.error("Redis template service is not available");
      return null;
   };
  
   template.setConnectionFactory(connectionFactory);
   template.afterPropertiesSet();
  
   return template;
   }
  </code></pre>
  
  <p>¿Is there any problem if I have more than one kind of listener when I'm using firebase listeners? ¿Or maybe, my redis config have some problem?</p>