Class HazelcastReceiver
- java.lang.Object
-
- org.appng.core.controller.messaging.HazelcastReceiver
-
- All Implemented Interfaces:
com.hazelcast.topic.MessageListener<byte[]>
,Closeable
,AutoCloseable
,EventListener
,Receiver
public class HazelcastReceiver extends Object implements Receiver, com.hazelcast.topic.MessageListener<byte[]>
AReceiver
that uses a reliable topic for sendingEvent
s. Following platform properties are supported (default value in brackets):hazelcastTopicName
(appng-messaging): Name of the topic
- Author:
- Matthias Müller
- See Also:
HazelcastInstance.getReliableTopic(String)
-
-
Field Summary
Fields Modifier and Type Field Description protected com.hazelcast.core.HazelcastInstance
instance
protected Serializer
serializer
-
Constructor Summary
Constructors Constructor Description HazelcastReceiver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the receiver, in particular blocking I/O resources need to be closed here.Receiver
configure(Serializer serializer)
Configures the receiverSender
createSender()
protected com.hazelcast.topic.ITopic<byte[]>
getTopic()
protected String
getTopicName()
protected org.slf4j.Logger
logger()
void
onMessage(com.hazelcast.topic.Message<byte[]> message)
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
-
-
-
Field Detail
-
instance
protected com.hazelcast.core.HazelcastInstance instance
-
serializer
protected Serializer serializer
-
-
Method Detail
-
configure
public Receiver configure(Serializer serializer)
Description copied from interface:Receiver
Configures the receiver- Specified by:
configure
in interfaceReceiver
- Parameters:
serializer
- theSerializer
for this receiver- Returns:
- the configured receiver
-
createSender
public Sender createSender()
Description copied from interface:Receiver
Creates and returns aSender
capable of sendingEvent
s that can be received by this type of receiver.- Specified by:
createSender
in interfaceReceiver
- Returns:
- the
Sender
-
runWith
public void runWith(ExecutorService executorService)
Description copied from interface:Receiver
Since a receiver runs as a thread, the givenExecutorService
should be used to run this thread.- Specified by:
runWith
in interfaceReceiver
- Parameters:
executorService
- theExecutorService
to run this receiver with
-
close
public void close() throws IOException
Description copied from interface:Receiver
Closes the receiver, in particular blocking I/O resources need to be closed here.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceReceiver
- Throws:
IOException
-
onMessage
public void onMessage(com.hazelcast.topic.Message<byte[]> message)
- Specified by:
onMessage
in interfacecom.hazelcast.topic.MessageListener<byte[]>
-
logger
protected org.slf4j.Logger logger()
-
registerHandler
public void registerHandler(EventHandler<?> handler)
Description copied from interface:Receiver
Registers a newEventHandler
- Specified by:
registerHandler
in interfaceReceiver
- Parameters:
handler
- theEventHandler
to register
-
setDefaultHandler
public void setDefaultHandler(EventHandler<?> defaultHandler)
Description copied from interface:Receiver
Sets the defaultEventHandler
, used when no other handler is registered for a certain event type- Specified by:
setDefaultHandler
in interfaceReceiver
- Parameters:
defaultHandler
- the defaultEventHandler
to use
-
getTopic
protected com.hazelcast.topic.ITopic<byte[]> getTopic()
-
getTopicName
protected String getTopicName()
-
-