Class JedisReceiver
- java.lang.Object
-
- org.appng.core.controller.messaging.JedisBase
-
- org.appng.core.controller.messaging.JedisReceiver
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Runnable
,Receiver
public class JedisReceiver extends JedisBase implements Receiver, Runnable
Message receiver implementingReceiver
to use a redis database with its build-in publish/subscribe function as message broker. Following platform properties are needed (default value in brackets):redisMessagingHost
(localhost): Host of the redis serverredisMessagingPort
(6379): Port of the redis serverredisMessagingPassword
(): Password of the redis serverredisMessagingTimeout
(): Timeout is optional. If not defined, Redis default is usedredisMessagingChannel
(appng-messaging): Channel where all cluster nodes should publish and subscribe. Be aware that this name must be different among different clusters using the same Redis server
- Author:
- Claus Stuemke, aiticon GmbH, 2015
-
-
Field Summary
-
Fields inherited from class org.appng.core.controller.messaging.JedisBase
channel, eventSerializer, host, password, port, REDIS_MESSAGING_CHANNEL, REDIS_MESSAGING_HOST, REDIS_MESSAGING_PASSWORD, REDIS_MESSAGING_PORT, REDIS_MESSAGING_TIMEOUT, timeout
-
-
Constructor Summary
Constructors Constructor Description JedisReceiver()
-
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 eventDeserializer)
Configures the receiverSender
createSender()
String
getHost()
int
getPort()
int
getTimeout()
void
registerHandler(EventHandler<?> handler)
Registers a newEventHandler
void
run()
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 typevoid
setHost(String host)
void
setPort(int port)
void
setTimeout(int timeout)
-
Methods inherited from class org.appng.core.controller.messaging.JedisBase
getJedis, initialize
-
-
-
-
Method Detail
-
configure
public Receiver configure(Serializer eventDeserializer)
Description copied from interface:Receiver
Configures the receiver- Specified by:
configure
in interfaceReceiver
- Parameters:
eventDeserializer
- 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
-
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
-
getHost
public String getHost()
- Returns:
- the host
-
setHost
public void setHost(String host)
- Parameters:
host
- the host to set
-
getPort
public int getPort()
- Returns:
- the port
-
setPort
public void setPort(int port)
- Parameters:
port
- the port to set
-
getTimeout
public int getTimeout()
- Returns:
- the timeout
-
setTimeout
public void setTimeout(int timeout)
- Parameters:
timeout
- the timeout to set
-
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
-
-