Class RabbitMQReceiver
- java.lang.Object
-
- org.appng.core.controller.messaging.RabbitMQBase
-
- org.appng.core.controller.messaging.RabbitMQReceiver
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Receiver
public class RabbitMQReceiver extends RabbitMQBase implements Receiver
Message receiver implementingReceiver
to use a RabbitMQ message broker. Following platform properties are needed (default value in brackets):rabbitMQAdresses
(localhost:5672): A comma separated list of <host>:<port> for RabbitMQ server(s)rabbitMQUser
(guest): UsernamerabbitMQPassword
(guest): PasswordrabbitMQExchange
(appng-messaging): Name of the exchange where the receiver binds its messaging queue on. Be aware that this name must be different among different clusters using the same RabbitMQ serverrabbitMQAutoDeleteQueue
(true): If the queue to create should be marked as autodelete.rabbitMQDurableQueue
(false): If the queue to create should be marked as durable.rabbitMQExclusiveQueue
(true): If the queue to create should be marked as exclusive.
- Author:
- Claus Stümke, aiticon GmbH, 2015, Matthias Müller
-
-
Field Summary
-
Fields inherited from class org.appng.core.controller.messaging.RabbitMQBase
addresses, channel, connection, eventSerializer, exchange, factory, password, RABBIT_MQ_ADRESSES, RABBIT_MQ_EXCHANGE, RABBIT_MQ_PASSWORD, RABBIT_MQ_USER, user
-
-
Constructor Summary
Constructors Constructor Description RabbitMQReceiver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Receiver
configure(Serializer eventSerializer)
Configures the receiverRabbitMQSender
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-
Methods inherited from class org.appng.core.controller.messaging.RabbitMQBase
close, initialize
-
-
-
-
Method Detail
-
configure
public Receiver configure(Serializer eventSerializer)
Description copied from interface:Receiver
Configures the receiver- Specified by:
configure
in interfaceReceiver
- Parameters:
eventSerializer
- theSerializer
for this receiver- Returns:
- the configured receiver
-
createSender
public RabbitMQSender 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
-
-