title: Best practice design on vertx. Eventbus or Singleton for repositories
body: <p>I am using vertx3</p>
  
  <p>I need to use redis in order to set and get values.(Redis might be changed to something else in the future)</p>
  
  <p>Iam looking for best practice design for my implementation.</p>
  
  <p>I am working on vertx cluster and I need to retrieve a messages via the eventbus extract the message and insert into Redis.</p>
  
  <p>In the other hand I can get requests via web and also extract the messages and insert them into redis</p>
  
  <p>Two options:</p>
  
  <ol>
  <li><p>Should I have a "redis-verticle" that get the messages via the bus and write them.</p></li>
  <li><p>Should I create a "Listener verticle" that will hold DAO which will hold RedisRepo object which will write them. </p>
  
  <p>I will also be able to handle the web calls and hold this DAO object </p></li>
  </ol>
  
  <p>If I was on spring-app I would create a DAO which holds RedisRepo and Inject it into my service layer but here we got the eventbus so I am not sure.</p>
  
  <p>(btw the redis datasource me be changed to something else so I gotta think about generic wrappers)</p>
  
  <pre><code>1. 
  
  public class RedisRepoVerticle extends AbstractVerticle {
  
  ...
   public void start() {
   client = new RedisClient("localhost", 6379);
                   connection = client.connect();
  ...
  
  vertx.eventBus().consumer("redis-operation", (handler) -&gt; {
              {
                  JsonObject msg = new JsonObject(handler.body().toString());
                 //write straight to Redis 
  
              }
          });
  
  }
  
  
  
  
  
  
  2. 
  
       public class RedisMessageListener extends AbstractVerticle {
          DatasourceDAO datasource
          ...
           public void start() {
           client = new RedisClient("localhost", 6379);
                           connection = client.connect();
      ...
  
      vertx.eventBus().consumer("redis-operation", (handler) -&gt; {
                  {
                      JsonObject msg = new JsonObject(handler.body().toString());
                     datasourceDAO.writeToRedis(..); 
  
                  }
              });
  
      }
  
  //datasourceDAO will hold RedisRepo object
  </code></pre>
  
  <p>If I take the second option should I start maintain singletons? I dont want to duplicate my daos which will duplicate my redisrepo's classes</p>