
co.spraybot.messagerunner.ParcelProcessor Maven / Gradle / Ivy
package co.spraybot.messagerunner;
import io.vertx.core.Future;
import java.util.UUID;
/**
* An object that is responsible for processing a specific type of Parcel.
*
* Typically each ParcelProcessor should be its own Verticle; however it is possible for a Verticle to process many
* different types of Parcels. When the Verticle powering your ParcelProcessor starts up or shuts down it is your
* implementation's responsibility to send a ProcessorAvailabilityParcel to the Courier or Parcels will not be
* forwarded correctly.
*
* @param The Parcel that this ParcelProcessor is prepared to handle
* @since 0.1.0
*/
public interface ParcelProcessor {
/**
* This is an ephemeral address and should not be depended on to be a persisent identifier for this ParcelProcessor's
* EventBus address.
*
* @return A UUID who's string representation will be the address the Courier sends Parcels to
*/
default UUID getAddress() {
return UUID.randomUUID();
}
/**
* @return Class representing the type of Parcel this ParcelProcessor can handle
*/
Class getParcelType();
/**
* Process a Parcel delivered from the Courier, specific processing that takes place is processor dependent.
*
* If the replyAddress is present the originating sender expects there to be
*
* @param parcel The Parcel that we should process
* @param replyAddress The EventBus address that responses should be sent to, may be null
* @return Complete the Future when finished processing the parcel
*/
Future processParcel(T parcel, String replyAddress);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy