Package org.appng.api.messaging
Interface Receiver
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
HazelcastReceiver
,JedisReceiver
,MulticastReceiver
,RabbitMQReceiver
,TribesReceiver
public interface Receiver extends Closeable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close()
Closes the receiver, in particular blocking I/O resources need to be closed here.Receiver
configure(Serializer eventDeserializer)
Configures the receiverSender
createSender()
void
registerHandler(EventHandler<?> handler)
Registers a newEventHandler
void
runWith(ExecutorService executorService)
Since a receiver runs as a thread, the givenExecutorService
should be used to run this thread.void
setDefaultHandler(EventHandler<?> defaultHandler)
Sets the defaultEventHandler
, used when no other handler is registered for a certain event type
-
-
-
Method Detail
-
registerHandler
void registerHandler(EventHandler<?> handler)
Registers a newEventHandler
- Parameters:
handler
- theEventHandler
to register
-
setDefaultHandler
void setDefaultHandler(EventHandler<?> defaultHandler)
Sets the defaultEventHandler
, used when no other handler is registered for a certain event type- Parameters:
defaultHandler
- the defaultEventHandler
to use
-
configure
Receiver configure(Serializer eventDeserializer)
Configures the receiver- Parameters:
eventDeserializer
- theSerializer
for this receiver- Returns:
- the configured receiver
-
createSender
Sender createSender()
Creates and returns aSender
capable of sendingEvent
s that can be received by this type of receiver.- Returns:
- the
Sender
-
runWith
void runWith(ExecutorService executorService)
Since a receiver runs as a thread, the givenExecutorService
should be used to run this thread.- Parameters:
executorService
- theExecutorService
to run this receiver with
-
close
default void close() throws IOException
Closes the receiver, in particular blocking I/O resources need to be closed here.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-