kandi background
Explore Kits

vert.x | Vert.x is a tool-kit for building reactive applications | Reactive Programming library

 by   eclipse-vertx Java Version: Current License: Non-SPDX

 by   eclipse-vertx Java Version: Current License: Non-SPDX

Download this library from

kandi X-RAY | vert.x Summary

vert.x is a Java library typically used in Programming Style, Reactive Programming applications. vert.x has no bugs, it has build file available and it has high support. However vert.x has 5 vulnerabilities and it has a Non-SPDX License. You can download it from GitHub.
This is the repository for Vert.x core. Vert.x core contains fairly low-level functionality, including support for HTTP, TCP, file system access, and various other features. You can use this directly in your own applications, and it's used by many of the other components of Vert.x. For more information on Vert.x and where Vert.x core fits into the big picture please see the website.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • vert.x has a highly active ecosystem.
  • It has 12848 star(s) with 1918 fork(s). There are 560 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 175 open issues and 2181 have been closed. On average issues are closed in 20 days. There are 65 open pull requests and 0 closed requests.
  • It has a positive sentiment in the developer community.
  • The latest version of vert.x is current.
vert.x Support
Best in #Reactive Programming
Average in #Reactive Programming
vert.x Support
Best in #Reactive Programming
Average in #Reactive Programming

quality kandi Quality

  • vert.x has 0 bugs and 0 code smells.
vert.x Quality
Best in #Reactive Programming
Average in #Reactive Programming
vert.x Quality
Best in #Reactive Programming
Average in #Reactive Programming

securitySecurity

  • vert.x has 5 vulnerability issues reported (2 critical, 1 high, 2 medium, 0 low).
  • vert.x code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
vert.x Security
Best in #Reactive Programming
Average in #Reactive Programming
vert.x Security
Best in #Reactive Programming
Average in #Reactive Programming

license License

  • vert.x has a Non-SPDX License.
  • Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
vert.x License
Best in #Reactive Programming
Average in #Reactive Programming
vert.x License
Best in #Reactive Programming
Average in #Reactive Programming

buildReuse

  • vert.x releases are not available. You will need to build from source code and install.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • vert.x saves you 119662 person hours of effort in developing the same functionality from scratch.
  • It has 134974 lines of code, 13332 functions and 917 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
vert.x Reuse
Best in #Reactive Programming
Average in #Reactive Programming
vert.x Reuse
Best in #Reactive Programming
Average in #Reactive Programming
Top functions reviewed by kandi - BETA

kandi has reviewed vert.x and discovered the below as its top functions. This is intended to give you an instant insight into vert.x implemented functionality, and help decide if they suit your requirements.

  • Returns the string value for the specified key .
    • Renders the given options and arguments .
      • Send file .
        • Configure the pipeline .
          • Checks if there are any files in the directory and if so return true .
            • Handle proxy connect .
              • Handles a short and long option .
                • Returns the HttpMethod object corresponding to the given string value .
                  • Handle parsing .
                    • Dispatch command line arguments .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      vert.x Key Features

                      Vert.x is a tool-kit for building reactive applications on the JVM

                      Building Vert.x artifacts

                      copy iconCopydownload iconDownload
                      > mvn package
                      

                      Running tests

                      copy iconCopydownload iconDownload
                      > mvn test
                      

                      Building documentation

                      copy iconCopydownload iconDownload
                      > mvn package -Pdocs -DskipTests
                      

                      How to unregister two vertx consumers and returns an rxjava completable?

                      copy iconCopydownload iconDownload
                      @Override
                      public Completable deregisterKeyEvents(String subscriptionId) {
                      
                          MessageConsumer<JsonObject> messageConsumer = consumerMap.get(subscriptionId);
                          MessageConsumer<JsonObject> subscriptionConsumer = subscriptionConsumerMap.get(subscriptionId);
                          
                          Completable c1;
                          if( subscriptionConsumer != null) {
                              subscriptionConsumerMap.remove(subscriptionId);
                              c1 = CompletableHelper.toCompletable(handler -> subscriptionConsumer.unregister(handler))
                                  .doOnSuccess(() -> LOGGER.debug("Subscription channel consumer deregistered successfully!"))
                                  .doOnError(t-> LOGGER.error("Unable to de-register Subscription channel consumer", t));
                          } else {
                              c1 = Completable.complete();
                          }
                          
                          Completable c2;
                          if (messageConsumer != null) {
                              consumerMap.remove(subscriptionId);
                              c2 = CompletableHelper.toCompletable(handler -> messageConsumer.unregister(handler));
                          } else {
                              LOGGER.warn("There was no consumer registered!");
                              c2 = Completable.error(new KvNoSuchElementException("Subscription '" + subscriptionId + "' not found"));
                      
                          }
                      
                          return c1.concatWith(c2);
                      }
                      

                      Quarkus: The return value of &quot;org.jboss.resteasy.reactive.server.mapping.RuntimeResource.getProduces()&quot; is null

                      copy iconCopydownload iconDownload
                      @Produces(MediaType.APPLICATION_JSON)
                      // Each element will be sent as JSON
                      @RestSseElementType(MediaType.APPLICATION_JSON)
                      

                      Spring Webflux: Extract a value from a Mono and save it into another variable

                      copy iconCopydownload iconDownload
                          private Mono<String> generateToken(User user) {
                              ArrayList<Long> usr_id = new ArrayList<Long>(Collections.singleton(user.getId()));
                              ArrayList<String> usr_name = new ArrayList<String>(Collections.singleton(user.getName()));
                              ArrayList<String> usr_lastname = new ArrayList<>(Collections.singleton(user.getLastName()));
                      
                              return myModelRepository.getMyModelInstance()
                                      .map(modelInstance -> {
                                          Map<String, Object> claims = new HashMap<>();
                      
                                          //put all values you need in claims map...
                      
                                          //update doGenerateToken code to return a Mono<String>
                                          return doGenerateToken(claims, user.getUsername());
                                      });
                          }
                      

                      How to subscribe to &quot;HttpClientResponse::toFlowable()&quot; outside of the vert.x &quot;rxResponse().subscribe&quot; callback

                      copy iconCopydownload iconDownload
                      package org.tests;
                      
                      import java.util.concurrent.CountDownLatch;
                      import java.util.concurrent.atomic.AtomicInteger;
                      import java.util.concurrent.atomic.AtomicReference;
                      
                      import org.assertj.core.api.Assertions;
                      import org.junit.jupiter.api.BeforeAll;
                      import org.junit.jupiter.api.RepeatedTest;
                      
                      import io.vertx.core.Vertx;
                      import io.vertx.core.buffer.Buffer;
                      import io.vertx.core.http.HttpClient;
                      import io.vertx.core.http.HttpClientRequest;
                      import io.vertx.core.http.HttpMethod;
                      import io.vertx.core.net.NetServer;
                      import io.vertx.core.streams.ReadStream;
                      
                      public class VxTestNonRx {
                          static NetServer server;
                          static HttpClient client;
                      
                          @BeforeAll
                          static void setUp() throws InterruptedException {
                              server = startServer();
                              client = Vertx.vertx().createHttpClient();
                          }
                      
                          @RepeatedTest(10000)
                          void shouldReachOnNextAndOnError() throws Exception {
                              CountDownLatch bodyReadLatch = new CountDownLatch(1);
                              CountDownLatch responseReadyToRead = new CountDownLatch(1);
                              AtomicReference<ReadStream<Buffer>> readStreamRef = new AtomicReference<>();
                              AtomicInteger ab = new AtomicInteger(0);
                              client.request(HttpMethod.GET,
                                             server.actualPort(),
                                             "localhost",
                                             "/")
                                    .compose(HttpClientRequest::send)
                                    .onSuccess(response -> {
                                        // Catches exceptions when they happen before we subscribed to the ReadStream
                                        response.netSocket().exceptionHandler(t -> System.out.println("NET EXCEPTION HANDLER" + t.getMessage()));
                                        //response.pause(); // Try to pause FIRST to avoid skipping buffers
                                        // When handlers are set here : 
                                        //  - with pause(): 100% times exceptionHandler only.
                                        //  - without pause(): 100% times : handler, then exceptionHandler
                                        readStreamRef.set(response);
                                        responseReadyToRead.countDown();
                                    });
                              responseReadyToRead.await();
                              // When handlers are set here : 
                              // - without pause() : 
                              //     - 66% times : handler, then exceptionHandler
                              //     - 33% times : only exceptionHandler gets called.
                              // - with pause() : 
                              //     - 99% times : only onError gets called 
                              //     - 1% times  : netSocket().exceptionHandler, then handler gets called. (but neither endHandler nor exceptionHandler are called !)
                              readStreamRef.get()
                                           .handler(buffer -> {
                                               System.out.println("HANDLER");
                                               ab.addAndGet(1);
                                           })
                                           .endHandler(unused -> {
                                               System.out.println("END HANDLER");
                                               bodyReadLatch.countDown();
                                           })
                                           .exceptionHandler(t -> {
                                               System.out.println("ERROR HANDLER");
                                               ab.addAndGet(2);
                                               bodyReadLatch.countDown();
                                           });
                              readStreamRef.get().resume();
                              bodyReadLatch.await();
                              // Should have been in onNext then onError callbacks.
                              Assertions.assertThat(ab.get()).isEqualTo(3);
                          }
                      
                          // This starts a server synchronously.
                          // It serves a static HTTP response with an illegal trailer name (making Vert.x fail)
                          private static NetServer startServer() throws InterruptedException {
                              CountDownLatch serverReady = new CountDownLatch(1);
                              AtomicReference<NetServer> servRef = new AtomicReference<>();
                              Vertx.vertx().createNetServer()
                                   .connectHandler(socket -> {
                                       String content1 = "HTTP/1.1 200 OK\r\n"
                                               + "transfer-encoding: chunked\r\n"
                                               + "\r\n"
                                               + "2\r\n"
                                               + "OK"
                                               + "\r\n"
                                               + "0\r\n"
                                               + "é: trailerValue\r\n" // é is an invalid trailer name
                                               + "\r\n";
                                       // Read the request content, then write content, then close the socket.
                                       socket.handler(b -> socket.write(content1, ar -> socket.close()));
                                   })
                                   .listen()
                                   .onSuccess(netServer -> {
                                       servRef.set(netServer);
                                       serverReady.countDown();
                                   });
                              serverReady.await();
                              return servRef.get();
                          }
                      

                      How to record each throwable when using .onFailure().retry() with delay between retries

                      copy iconCopydownload iconDownload
                      service.apiMethod(key)
                          .invoke(record -> logger.info("Succeeded to read record."))
                          .onFailure()
                              .invoke(exception -> logger.warn("Failed to read record."))
                          .onFailure()
                              .retry().withBackOff(delay).indefinitely();
                      

                      Quarkus SQS consumer

                      copy iconCopydownload iconDownload
                      Uni.createFrom().item(returnDataFromDb());
                      
                      import io.quarkus.scheduler.Scheduled
                      import io.quarkus.vertx.ConsumeEvent
                      import io.smallrye.mutiny.Uni
                      import io.vertx.mutiny.core.eventbus.EventBus
                      import org.eclipse.microprofile.config.inject.ConfigProperty
                      import org.jboss.logging.Logger
                      import software.amazon.awssdk.services.sqs.SqsAsyncClient
                      import software.amazon.awssdk.services.sqs.model.Message
                      import software.amazon.awssdk.services.sqs.model.ReceiveMessageResponse
                      import java.util.concurrent.CompletionStage
                      import javax.enterprise.context.ApplicationScoped
                      import javax.enterprise.inject.Instance
                      
                      @ApplicationScoped
                      class SqsConsumer(
                          private val eventBus: EventBus,
                          private val logger: Logger,
                          @ConfigProperty(name = "sqs.consumer.maxFetchedMessages")
                          private val maxFetchedEvents: Int,
                          private val handlers: Instance<MessageHandler>,
                          private val sqsClient: SqsAsyncClient,
                      ) {
                      
                          @Scheduled(every = "{sqs.consumer.interval}")
                          fun execute() {
                              handlers.stream().forEach { handler ->
                                  val handlerName = handler.javaClass.name
                                  logger.info("Fetching messages for $handlerName...")
                                  Uni
                                      .createFrom()
                                      .completionStage(fetchMessages(handler.queueUrl()))
                                      .subscribe()
                                      .with(
                                          { response ->
                                              val newEventsCount = response.messages().size
                                              if (newEventsCount > 0) {
                                                  logger.info("$newEventsCount message(s) fetched for $handlerName.")
                                                  eventBus.send("receive-message-responses", ResponseHolder(handler, response))
                                              } else {
                                                  logger.info("Queue was empty. Maybe next time.")
                                              }
                                          },
                                          { logger.error("Error fetching messages!", it) }
                                      )
                              }
                          }
                      
                          @ConsumeEvent("receive-message-responses")
                          fun processReceivedMessageResponse(holder: ResponseHolder): Uni<Void> {
                              val handler = holder.handler
                              val handlerName = handler.javaClass.name
                              val messageResponse = holder.receiveMessageResponse
                              logger.info("Processing messages for $handlerName...")
                              return Uni
                                  .createFrom()
                                  .item(holder)
                                  .flatMap { handler.process(messageResponse.messages().map { message -> message.body() }) }
                                  .onItem()
                                  .invoke { _ ->
                                      logger.info("Processing succeeded. Deleting processed events from the queue...")
                                      messageResponse
                                          .messages()
                                          .forEach { eventBus.send("processed-messages", MessageHolder(handler, it)) }
                                  }
                                  .replaceWithVoid()
                                  .onFailure()
                                  .invoke { it -> logger.error("Error processing messages!", it) }
                          }
                      
                          @ConsumeEvent("processed-messages")
                          fun deleteProcessedMessages(holder: MessageHolder): Uni<Void> {
                              val handler = holder.handler
                              val message = holder.message
                              return Uni
                                  .createFrom()
                                  .completionStage(
                                      sqsClient.deleteMessage {
                                          it
                                              .queueUrl(handler.queueUrl())
                                              .receiptHandle(message.receiptHandle())
                                      }
                                  )
                                  .onItem()
                                  .invoke { _ -> logger.info("Message ${message.messageId()} deleted from the queue!") }
                                  .onFailure()
                                  .invoke { it -> logger.error("Could not delete message ${message.messageId()} from the queue!", it) }
                                  .replaceWithVoid()
                          }
                      
                          private fun fetchMessages(queueUrl: String): CompletionStage<ReceiveMessageResponse> {
                              return sqsClient
                                  .receiveMessage {
                                      it
                                          .maxNumberOfMessages(maxFetchedEvents)
                                          .queueUrl(queueUrl)
                                  }
                          }
                      }
                      
                      class ResponseHolder(
                          val handler: MessageHandler,
                          val receiveMessageResponse: ReceiveMessageResponse,
                      )
                      
                      class MessageHolder(
                          val handler: MessageHandler,
                          val message: Message,
                      )
                      

                      How to configure Axon 4 context in Vert.x

                      copy iconCopydownload iconDownload
                      config -> MongoTokenStore.builder()
                                               .mongoTemplate(
                                                   DefaultMongoTemplate.builder()
                                                                       // optionally choose collection names here
                                                                       .mongoDatabase(mongoClient)
                                                                       .build())
                                               .serializer(Configuration::serializer)
                                               .build()
                      

                      Non-blocking gets on Hazelcast ReplicatedMap?

                      copy iconCopydownload iconDownload
                      DeploymentOptions options = new DeploymentOptions().setWorker(true);
                      vertx.deployVerticle("com.verticles.HazelcastVerticle", options);
                      

                      Eclipse Vert.x : parsing java.time date with jackson

                      copy iconCopydownload iconDownload
                      ObjectMapper mapper = DatabindCodec.mapper();
                      mapper.registerModule(new JavaTimeModule());
                      
                      ObjectMapper prettyMapper = DatabindCodec.prettyMapper();
                      prettyMapper.registerModule(new JavaTimeModule());
                      
                      public class MainVerticle extends AbstractVerticle {
                      
                        // code already exists
                      
                        @Override
                        public void start() {
                            ObjectMapper mapper = DatabindCodec.mapper();
                            mapper.registerModule(new JavaTimeModule());
                       
                            ObjectMapper prettyMapper = DatabindCodec.prettyMapper();
                            prettyMapper.registerModule(new JavaTimeModule());
                        
                        
                        // code already exists
                      
                      ObjectMapper mapper = DatabindCodec.mapper();
                      mapper.registerModule(new JavaTimeModule());
                      
                      ObjectMapper prettyMapper = DatabindCodec.prettyMapper();
                      prettyMapper.registerModule(new JavaTimeModule());
                      
                      public class MainVerticle extends AbstractVerticle {
                      
                        // code already exists
                      
                        @Override
                        public void start() {
                            ObjectMapper mapper = DatabindCodec.mapper();
                            mapper.registerModule(new JavaTimeModule());
                       
                            ObjectMapper prettyMapper = DatabindCodec.prettyMapper();
                            prettyMapper.registerModule(new JavaTimeModule());
                        
                        
                        // code already exists
                      
                      // Converting Date to timestamp and sending in Json
                      timestamp = Date().getTime()
                      new JsonObject().put("date", timestamp)
                      
                      
                      // Converting the timestamp to Date
                      Date(timestamp)
                      

                      How to start multiple message consumers in Quarkus?

                      copy iconCopydownload iconDownload
                      @ApplicationScoped
                      public class CoffeeRepositoryService {
                      
                          public CoffeeRepositoryService() {
                              System.out.println("Injection succeeded!");
                          }
                      }
                      
                      package org.acme;
                      
                      import io.smallrye.mutiny.Uni;
                      import io.smallrye.mutiny.vertx.core.AbstractVerticle;
                      import io.vertx.core.impl.logging.Logger;
                      import io.vertx.core.impl.logging.LoggerFactory;
                      import io.vertx.mutiny.core.eventbus.EventBus;
                      import io.vertx.mutiny.rabbitmq.RabbitMQClient;
                      import io.vertx.mutiny.rabbitmq.RabbitMQConsumer;
                      import io.vertx.rabbitmq.QueueOptions;
                      import io.vertx.rabbitmq.RabbitMQOptions;
                      
                      public class RQVerticle extends AbstractVerticle {
                      
                        private final Logger LOGGER = LoggerFactory.getLogger(org.acme.RQVerticle.class);
                      
                        //This doesn't work - returns null
                        @Inject
                        CoffeeRepositoryService coffeeRepositoryService;
                      
                        RQVerticle() {} // dummy constructor needed
                         
                        @Inject // constructor injection - this does work
                        RQVerticle(CoffeeRepositoryService coffeeRepositoryService) {
                          //Here coffeeRepositoryService is injected properly
                        }
                      
                        @Override
                        public Uni<Void> asyncStart() {
                          LOGGER.info(
                              "Creating RabbitMQ Connection after Quarkus successful initialization");
                      
                          RabbitMQOptions config = new RabbitMQOptions();
                          config.setUri("amqp://localhost:5672");
                          RabbitMQClient client = RabbitMQClient.create(vertx, config);
                          
                          Uni<Void> clientResp = client.start();
                          clientResp.subscribe()
                              .with(asyncResult -> {
                                LOGGER.info("RabbitMQ successfully connected!");
                                    
                              });
                      
                            return clientResp;
                        }
                      }
                      
                      package org.acme;
                      
                      import io.quarkus.runtime.Quarkus;
                      import io.quarkus.runtime.QuarkusApplication;
                      import io.quarkus.runtime.annotations.QuarkusMain;
                      import io.vertx.core.DeploymentOptions;
                      import io.vertx.mutiny.core.Vertx;
                      
                      @QuarkusMain
                      public class Main {
                      
                        public static void main(String... args) {
                          Quarkus.run(MyApp.class, args);
                        }
                      
                        public static class MyApp implements QuarkusApplication {
                      
                          @Override
                          public int run(String... args) throws Exception {
                            var vertx = Vertx.vertx();
                            System.out.println("Deployment Starting");
                      
                            DeploymentOptions options = new DeploymentOptions()
                                .setInstances(2);
                            vertx.deployVerticleAndAwait(RQVerticle::new, options);
                      
                            System.out.println("Deployment completed");
                      
                            Quarkus.waitForExit();
                            return 0;
                          }
                        }
                      }
                      
                      package org.acme;
                      
                      import io.quarkus.runtime.StartupEvent;
                      import io.vertx.mutiny.core.Vertx;
                      import javax.enterprise.context.ApplicationScoped;
                      import javax.enterprise.event.Observes;
                      import org.jboss.logging.Logger;
                      
                      @ApplicationScoped
                      public class MainVerticles {
                      
                        private static final Logger LOGGER = Logger.getLogger(MainVerticles.class);
                      
                        public void init(@Observes StartupEvent e, Vertx vertx, RQVerticle verticle) {
                          public void init(@Observes StartupEvent e, Vertx vertx, RQVerticle verticle) {
                          DeploymentOptions options = new DeploymentOptions()
                          .setInstances(2);
                          vertx.deployVerticle(verticle,options).await().indefinitely();
                        }
                      }
                      
                      @ApplicationScoped
                      public class CoffeeRepositoryService {
                      
                          public CoffeeRepositoryService() {
                              System.out.println("Injection succeeded!");
                          }
                      }
                      
                      package org.acme;
                      
                      import io.smallrye.mutiny.Uni;
                      import io.smallrye.mutiny.vertx.core.AbstractVerticle;
                      import io.vertx.core.impl.logging.Logger;
                      import io.vertx.core.impl.logging.LoggerFactory;
                      import io.vertx.mutiny.core.eventbus.EventBus;
                      import io.vertx.mutiny.rabbitmq.RabbitMQClient;
                      import io.vertx.mutiny.rabbitmq.RabbitMQConsumer;
                      import io.vertx.rabbitmq.QueueOptions;
                      import io.vertx.rabbitmq.RabbitMQOptions;
                      
                      public class RQVerticle extends AbstractVerticle {
                      
                        private final Logger LOGGER = LoggerFactory.getLogger(org.acme.RQVerticle.class);
                      
                        //This doesn't work - returns null
                        @Inject
                        CoffeeRepositoryService coffeeRepositoryService;
                      
                        RQVerticle() {} // dummy constructor needed
                         
                        @Inject // constructor injection - this does work
                        RQVerticle(CoffeeRepositoryService coffeeRepositoryService) {
                          //Here coffeeRepositoryService is injected properly
                        }
                      
                        @Override
                        public Uni<Void> asyncStart() {
                          LOGGER.info(
                              "Creating RabbitMQ Connection after Quarkus successful initialization");
                      
                          RabbitMQOptions config = new RabbitMQOptions();
                          config.setUri("amqp://localhost:5672");
                          RabbitMQClient client = RabbitMQClient.create(vertx, config);
                          
                          Uni<Void> clientResp = client.start();
                          clientResp.subscribe()
                              .with(asyncResult -> {
                                LOGGER.info("RabbitMQ successfully connected!");
                                    
                              });
                      
                            return clientResp;
                        }
                      }
                      
                      package org.acme;
                      
                      import io.quarkus.runtime.Quarkus;
                      import io.quarkus.runtime.QuarkusApplication;
                      import io.quarkus.runtime.annotations.QuarkusMain;
                      import io.vertx.core.DeploymentOptions;
                      import io.vertx.mutiny.core.Vertx;
                      
                      @QuarkusMain
                      public class Main {
                      
                        public static void main(String... args) {
                          Quarkus.run(MyApp.class, args);
                        }
                      
                        public static class MyApp implements QuarkusApplication {
                      
                          @Override
                          public int run(String... args) throws Exception {
                            var vertx = Vertx.vertx();
                            System.out.println("Deployment Starting");
                      
                            DeploymentOptions options = new DeploymentOptions()
                                .setInstances(2);
                            vertx.deployVerticleAndAwait(RQVerticle::new, options);
                      
                            System.out.println("Deployment completed");
                      
                            Quarkus.waitForExit();
                            return 0;
                          }
                        }
                      }
                      
                      package org.acme;
                      
                      import io.quarkus.runtime.StartupEvent;
                      import io.vertx.mutiny.core.Vertx;
                      import javax.enterprise.context.ApplicationScoped;
                      import javax.enterprise.event.Observes;
                      import org.jboss.logging.Logger;
                      
                      @ApplicationScoped
                      public class MainVerticles {
                      
                        private static final Logger LOGGER = Logger.getLogger(MainVerticles.class);
                      
                        public void init(@Observes StartupEvent e, Vertx vertx, RQVerticle verticle) {
                          public void init(@Observes StartupEvent e, Vertx vertx, RQVerticle verticle) {
                          DeploymentOptions options = new DeploymentOptions()
                          .setInstances(2);
                          vertx.deployVerticle(verticle,options).await().indefinitely();
                        }
                      }
                      
                      @ApplicationScoped
                      public class CoffeeRepositoryService {
                      
                          public CoffeeRepositoryService() {
                              System.out.println("Injection succeeded!");
                          }
                      }
                      
                      package org.acme;
                      
                      import io.smallrye.mutiny.Uni;
                      import io.smallrye.mutiny.vertx.core.AbstractVerticle;
                      import io.vertx.core.impl.logging.Logger;
                      import io.vertx.core.impl.logging.LoggerFactory;
                      import io.vertx.mutiny.core.eventbus.EventBus;
                      import io.vertx.mutiny.rabbitmq.RabbitMQClient;
                      import io.vertx.mutiny.rabbitmq.RabbitMQConsumer;
                      import io.vertx.rabbitmq.QueueOptions;
                      import io.vertx.rabbitmq.RabbitMQOptions;
                      
                      public class RQVerticle extends AbstractVerticle {
                      
                        private final Logger LOGGER = LoggerFactory.getLogger(org.acme.RQVerticle.class);
                      
                        //This doesn't work - returns null
                        @Inject
                        CoffeeRepositoryService coffeeRepositoryService;
                      
                        RQVerticle() {} // dummy constructor needed
                         
                        @Inject // constructor injection - this does work
                        RQVerticle(CoffeeRepositoryService coffeeRepositoryService) {
                          //Here coffeeRepositoryService is injected properly
                        }
                      
                        @Override
                        public Uni<Void> asyncStart() {
                          LOGGER.info(
                              "Creating RabbitMQ Connection after Quarkus successful initialization");
                      
                          RabbitMQOptions config = new RabbitMQOptions();
                          config.setUri("amqp://localhost:5672");
                          RabbitMQClient client = RabbitMQClient.create(vertx, config);
                          
                          Uni<Void> clientResp = client.start();
                          clientResp.subscribe()
                              .with(asyncResult -> {
                                LOGGER.info("RabbitMQ successfully connected!");
                                    
                              });
                      
                            return clientResp;
                        }
                      }
                      
                      package org.acme;
                      
                      import io.quarkus.runtime.Quarkus;
                      import io.quarkus.runtime.QuarkusApplication;
                      import io.quarkus.runtime.annotations.QuarkusMain;
                      import io.vertx.core.DeploymentOptions;
                      import io.vertx.mutiny.core.Vertx;
                      
                      @QuarkusMain
                      public class Main {
                      
                        public static void main(String... args) {
                          Quarkus.run(MyApp.class, args);
                        }
                      
                        public static class MyApp implements QuarkusApplication {
                      
                          @Override
                          public int run(String... args) throws Exception {
                            var vertx = Vertx.vertx();
                            System.out.println("Deployment Starting");
                      
                            DeploymentOptions options = new DeploymentOptions()
                                .setInstances(2);
                            vertx.deployVerticleAndAwait(RQVerticle::new, options);
                      
                            System.out.println("Deployment completed");
                      
                            Quarkus.waitForExit();
                            return 0;
                          }
                        }
                      }
                      
                      package org.acme;
                      
                      import io.quarkus.runtime.StartupEvent;
                      import io.vertx.mutiny.core.Vertx;
                      import javax.enterprise.context.ApplicationScoped;
                      import javax.enterprise.event.Observes;
                      import org.jboss.logging.Logger;
                      
                      @ApplicationScoped
                      public class MainVerticles {
                      
                        private static final Logger LOGGER = Logger.getLogger(MainVerticles.class);
                      
                        public void init(@Observes StartupEvent e, Vertx vertx, RQVerticle verticle) {
                          public void init(@Observes StartupEvent e, Vertx vertx, RQVerticle verticle) {
                          DeploymentOptions options = new DeploymentOptions()
                          .setInstances(2);
                          vertx.deployVerticle(verticle,options).await().indefinitely();
                        }
                      }
                      
                      @ApplicationScoped
                      public class CoffeeRepositoryService {
                      
                          public CoffeeRepositoryService() {
                              System.out.println("Injection succeeded!");
                          }
                      }
                      
                      package org.acme;
                      
                      import io.smallrye.mutiny.Uni;
                      import io.smallrye.mutiny.vertx.core.AbstractVerticle;
                      import io.vertx.core.impl.logging.Logger;
                      import io.vertx.core.impl.logging.LoggerFactory;
                      import io.vertx.mutiny.core.eventbus.EventBus;
                      import io.vertx.mutiny.rabbitmq.RabbitMQClient;
                      import io.vertx.mutiny.rabbitmq.RabbitMQConsumer;
                      import io.vertx.rabbitmq.QueueOptions;
                      import io.vertx.rabbitmq.RabbitMQOptions;
                      
                      public class RQVerticle extends AbstractVerticle {
                      
                        private final Logger LOGGER = LoggerFactory.getLogger(org.acme.RQVerticle.class);
                      
                        //This doesn't work - returns null
                        @Inject
                        CoffeeRepositoryService coffeeRepositoryService;
                      
                        RQVerticle() {} // dummy constructor needed
                         
                        @Inject // constructor injection - this does work
                        RQVerticle(CoffeeRepositoryService coffeeRepositoryService) {
                          //Here coffeeRepositoryService is injected properly
                        }
                      
                        @Override
                        public Uni<Void> asyncStart() {
                          LOGGER.info(
                              "Creating RabbitMQ Connection after Quarkus successful initialization");
                      
                          RabbitMQOptions config = new RabbitMQOptions();
                          config.setUri("amqp://localhost:5672");
                          RabbitMQClient client = RabbitMQClient.create(vertx, config);
                          
                          Uni<Void> clientResp = client.start();
                          clientResp.subscribe()
                              .with(asyncResult -> {
                                LOGGER.info("RabbitMQ successfully connected!");
                                    
                              });
                      
                            return clientResp;
                        }
                      }
                      
                      package org.acme;
                      
                      import io.quarkus.runtime.Quarkus;
                      import io.quarkus.runtime.QuarkusApplication;
                      import io.quarkus.runtime.annotations.QuarkusMain;
                      import io.vertx.core.DeploymentOptions;
                      import io.vertx.mutiny.core.Vertx;
                      
                      @QuarkusMain
                      public class Main {
                      
                        public static void main(String... args) {
                          Quarkus.run(MyApp.class, args);
                        }
                      
                        public static class MyApp implements QuarkusApplication {
                      
                          @Override
                          public int run(String... args) throws Exception {
                            var vertx = Vertx.vertx();
                            System.out.println("Deployment Starting");
                      
                            DeploymentOptions options = new DeploymentOptions()
                                .setInstances(2);
                            vertx.deployVerticleAndAwait(RQVerticle::new, options);
                      
                            System.out.println("Deployment completed");
                      
                            Quarkus.waitForExit();
                            return 0;
                          }
                        }
                      }
                      
                      package org.acme;
                      
                      import io.quarkus.runtime.StartupEvent;
                      import io.vertx.mutiny.core.Vertx;
                      import javax.enterprise.context.ApplicationScoped;
                      import javax.enterprise.event.Observes;
                      import org.jboss.logging.Logger;
                      
                      @ApplicationScoped
                      public class MainVerticles {
                      
                        private static final Logger LOGGER = Logger.getLogger(MainVerticles.class);
                      
                        public void init(@Observes StartupEvent e, Vertx vertx, RQVerticle verticle) {
                          public void init(@Observes StartupEvent e, Vertx vertx, RQVerticle verticle) {
                          DeploymentOptions options = new DeploymentOptions()
                          .setInstances(2);
                          vertx.deployVerticle(verticle,options).await().indefinitely();
                        }
                      }
                      

                      Community Discussions

                      Trending Discussions on vert.x
                      • How to list all consumers that are listening to an address on a vertex event bus?
                      • How to unregister two vertx consumers and returns an rxjava completable?
                      • Quarkus: The return value of &quot;org.jboss.resteasy.reactive.server.mapping.RuntimeResource.getProduces()&quot; is null
                      • Spring Webflux: Extract a value from a Mono and save it into another variable
                      • How to subscribe to &quot;HttpClientResponse::toFlowable()&quot; outside of the vert.x &quot;rxResponse().subscribe&quot; callback
                      • starting with reactive DB access in a blocking monolith
                      • How to record each throwable when using .onFailure().retry() with delay between retries
                      • Quarkus SQS consumer
                      • How to configure Axon 4 context in Vert.x
                      • How to use Axon with Vert.X
                      Trending Discussions on vert.x

                      QUESTION

                      How to list all consumers that are listening to an address on a vertex event bus?

                      Asked 2022-Mar-29 at 14:13

                      I have a vert.x program. I am creating a message consumer and attach it to listen on an address on the vertx event bus . later in the program I am unregistering that consumer . How do I know if the consumer is unregistered successfully ?

                      following code snippet shows how i register a consumer on an address on vertex event bus

                      MessageConsumer<JsonObject> consumer = vertx.eventBus().consumer("my_channel", eventHandler)
                      

                      later after sometime i am unregistering the consumer

                      consumer.unregister( res -> {
                        if(res.succeeded()) { System.out.println("consumer deregistered")}
                      });
                      

                      so my question is suppose i have reference to an vertx event bus vert.eventBus() object how can i verify it if there any consumers on it ?

                      ANSWER

                      Answered 2022-Mar-29 at 14:13

                      As for the first question, you can safely assume consumer is unregistered successfully when res.succeeded() returns true inside unregister handler (as per your example).

                      For the second part, afaik the event bus does not maintain the list of consumers registered to it, you have to maintain it yourself. The goal would be to have a map or some other collection where you store references for consumers when you register them with .consumer(...) method and remove them after unregister handler returns succeeded.

                      I think this would be the issue you are referring to (with the advice by the lead architect of vertx): https://groups.google.com/g/vertx/c/d70YlHLL7KU?pli=1

                      Source https://stackoverflow.com/questions/71650514

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      In Eclipse Vert.x 3.4.x up to 3.9.4, 4.0.0.milestone1, 4.0.0.milestone2, 4.0.0.milestone3, 4.0.0.milestone4, 4.0.0.milestone5, 4.0.0.Beta1, 4.0.0.Beta2, and 4.0.0.Beta3, StaticHandler doesn't correctly processes back slashes on Windows Operating systems, allowing, escape the webroot folder to the current working directory.
                      In version from 3.5.Beta1 to 3.5.3 of Eclipse Vert.x, the OpenAPI XML type validator creates XML parsers without taking appropriate defense against XML attacks. This mechanism is exclusively when the developer uses the Eclipse Vert.x OpenAPI XML type validator to validate a provided schema.
                      In version from 3.0.0 to 3.5.3 of Eclipse Vert.x, the StaticHandler uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '\' (forward slashes) sequences that can resolve to a location that is outside of that directory when running on Windows Operating Systems.
                      In version from 3.0.0 to 3.5.3 of Eclipse Vert.x, the WebSocket HTTP upgrade implementation buffers the full http request before doing the handshake, holding the entire request body in memory. There should be a reasonnable limit (8192 bytes) above which the WebSocket gets an HTTP response with the 413 status code and the connection gets closed.
                      In version from 3.0.0 to 3.5.2 of Eclipse Vert.x, the CSRFHandler do not assert that the XSRF Cookie matches the returned XSRF header/form parameter. This allows replay attacks with previously issued tokens which are not expired yet.
                      In Eclipse Vert.x version 3.0 to 3.5.1, the HttpServer response headers and HttpClient request headers do not filter carriage return and line feed characters from the header value. This allow unfiltered values to inject a new header in the client request or server response.

                      Install vert.x

                      You can download it from GitHub.
                      You can use vert.x like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the vert.x component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                      Support

                      Open target/docs/vertx-core/java/index.html with your browser.

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Share this Page

                      share link
                      Consider Popular Reactive Programming Libraries
                      Try Top Libraries by eclipse-vertx
                      Compare Reactive Programming Libraries with Highest Support
                      Compare Reactive Programming Libraries with Highest Quality
                      Compare Reactive Programming Libraries with Highest Security
                      Compare Reactive Programming Libraries with Permissive License
                      Compare Reactive Programming Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.