io.github.sinri.keel.maids.pleiades.Pleiades Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Keel Show documentation
Show all versions of Keel Show documentation
A website framework with VERT.X for ex-PHP-ers, exactly Ark Framework Users.
The newest version!
package io.github.sinri.keel.maids.pleiades;
import io.github.sinri.keel.core.TechnicalPreview;
import io.github.sinri.keel.verticles.KeelVerticleImplWithEventLogger;
import io.vertx.core.Promise;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.eventbus.Message;
import io.vertx.core.eventbus.MessageConsumer;
import io.vertx.core.eventbus.MessageProducer;
import static io.github.sinri.keel.facade.KeelInstance.Keel;
/**
* A queue impl based on EventBus and Messages.
* Pleiades (戦闘メイド) is the combat maid squad of the Great Tomb of Nazarick [REF: Overlord].
*
* @since 3.2.19
*/
@TechnicalPreview(since = "3.2.19")
public abstract class Pleiades extends KeelVerticleImplWithEventLogger {
private MessageConsumer consumer;
public static MessageProducer generateMessageProducer(String address) {
return generateMessageProducer(address, new DeliveryOptions());
}
public static MessageProducer generateMessageProducer(String address, DeliveryOptions deliveryOptions) {
return Keel.getVertx().eventBus().sender(address, deliveryOptions);
}
abstract public String getAddress();
abstract protected void handleMessage(Message message);
@Override
protected void startAsKeelVerticle(Promise startPromise) {
// register
consumer = Keel.getVertx().eventBus().consumer(getAddress(), this::handleMessage);
// ready!
startPromise.complete();
}
@Override
protected void stopAsKeelVerticle(Promise stopPromise) {
if (consumer != null) {
consumer.unregister()
.onSuccess(unused -> stopPromise.complete())
.onFailure(stopPromise::fail);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy