7 Replies Latest reply on Sep 1, 2015 7:49 AM by Wolfgang Mayer

    Wildfly9 @Observes Consumer<Object> bug?

    ark lopie Newbie

      When I run localhost:8080/app/res/observer browser is 'working' waiting for answer but it never comes.

      It is like fired object is not caught by Observes.

      It is working on Glassfish without any problems.

      So, is it WF bug or I missed something?

       

      @Path("observer")

      public class Test {

       

          @Inject

          Event<Consumer<Object>> event;

       

          @GET

          public void getResult(@Suspended AsyncResponse response) {

              Consumer<Object> consumer = response::resume;

              event.fire(consumer);

              Logger.getLogger(this.getClass().getName()).info("getResult() called");

          }

      }

       

      @Singleton

      public class Helper implements Serializable {

       

          @Resource

          ManagedExecutorService mes;

       

          public void observer(@Observes Consumer<Object> consumer) {

              Logger.getLogger(this.getClass().getName()).info("observer() called " + consumer.toString());

              Supplier<String> supplier = this::info;

              try {

                  CompletableFuture.supplyAsync(supplier, mes).thenAccept(consumer).get();

              } catch (InterruptedException | ExecutionException e) {

                  Logger.getLogger(this.getClass().getName()).info(e.getMessage());

              }

          }

       

          public String info() {

              return "Just testing";

          }

      }

       

       

      @ApplicationPath("res")

      public class JAXRSConfig extends Application {

       

          public JAXRSConfig() {

          }

      }