2017-11-01 26 views
1

配布された頂点が残りのエンドポイントにリンクされているサービスを作成します。サービスは100%稼働しています(私はVerticleを動的に配置し、RESTエンドポイントを呼び出してVerticleに関数を実行します)。問題は、提供された補完ハンドラが決して呼び出されないことです。何か案は?それはあなたがあなたのverticleを実装しているかに依存します。この場合、Vertx.deployVerticleは、指定された補完ハンドラを呼び出さない

 LOGGER.debug(String.format("Starting runner %s:%s:%s" ,functionName, faasFunctionClass, fileName)); 

     DeploymentOptions deploymentOptions = new DeploymentOptions(); 
     deploymentOptions.setInstances(1); 
     JsonObject jsonObject = new JsonObject(); 
     jsonObject.put(FUNCTION_NAME, functionName); 
     jsonObject.put(FUNCTION_CLASS, faasFunctionClass); 
     jsonObject.put(FUNCTION_FILENAME, fileName); 

     deploymentOptions.setConfig(jsonObject); 

     LOGGER.debug(String.format("Deploying [%s]" ,jsonObject.encode())); 
     this.vertx.deployVerticle("faas:" + VertxFaasRunner.class.getCanonicalName(),deploymentOptions, event->{ 
      if (event.succeeded()) { 
       System.out.println("Deployment id is: " + event.result()); 
      } else { 
       System.out.println("Deployment failed!"); 
      } 
     }); 
+0

faasファクトリとは何ですか? ブロッキングが発生すると、イベントハンドラは決して呼び出されません –

答えて

2

:後

は私のコードです。

future.complete()が実行されると、event.succeeded()のみがtrueになります。

public class MainVerticle extends AbstractVerticle { 

    @Override 
    public void start() throws Exception { 
     System.out.println("[Main] Running in " + Thread.currentThread().getName()); 
     vertx 
       .deployVerticle("io.vertx.example.core.verticle.worker.WorkerVerticle", 
         new DeploymentOptions().setWorker(true), event -> { 
          if (event.succeeded()) { 
           System.out.println("Deployment id is: " + event.result()); 
          } else { 
           System.out.println("Deployment failed!"); 
          } 
         }); 

    } 
} 

public class WorkerVerticle extends AbstractVerticle { 
    @Override 
    public void start(Future future) throws Exception { 
    System.out.println("[Worker] Starting in " + Thread.currentThread().getName()); 

    vertx.eventBus().<String>consumer("sample.data", message -> { 
     System.out.println("[Worker] Consuming data in " + Thread.currentThread().getName()); 
     String body = message.body(); 
     message.reply(body.toUpperCase()); 
    }); 
    // this notifies that the verticle is deployed successfully. 
    future.complete(); 
    } 
} 
関連する問題