Support
Quality
Security
License
Reuse
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.
Vert.x is a tool-kit for building reactive applications on the JVM
Building Vert.x artifacts
> mvn package
Running tests
> mvn test
Building documentation
> mvn package -Pdocs -DskipTests
How to unregister two vertx consumers and returns an rxjava completable?
@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 "org.jboss.resteasy.reactive.server.mapping.RuntimeResource.getProduces()" is null
@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
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 "HttpClientResponse::toFlowable()" outside of the vert.x "rxResponse().subscribe" callback
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
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
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
config -> MongoTokenStore.builder()
.mongoTemplate(
DefaultMongoTemplate.builder()
// optionally choose collection names here
.mongoDatabase(mongoClient)
.build())
.serializer(Configuration::serializer)
.build()
Non-blocking gets on Hazelcast ReplicatedMap?
DeploymentOptions options = new DeploymentOptions().setWorker(true);
vertx.deployVerticle("com.verticles.HazelcastVerticle", options);
Eclipse Vert.x : parsing java.time date with jackson
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?
@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();
}
}
QUESTION
How to list all consumers that are listening to an address on a vertex event bus?
Asked 2022-Mar-29 at 14:13I 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:13As 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
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit