Package org.kryonite.kryomessaging.api
Interface MessagingService
- All Known Implementing Classes:
DefaultMessagingService
public interface MessagingService
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bindQueueToExchange
(String queue, String exchange) Bind a queue to an existing exchange.void
bindQueueToExchange
(String queue, String exchange, String routingKey) Bind a queue to an exchange with a specific routing key.void
sendMessage
(Message<?> message) Send a message with any class as a payload.void
setupExchange
(String exchange, com.rabbitmq.client.BuiltinExchangeType exchangeType) Setup an exchange with a specific type and name.<T> void
startConsuming
(String queue, MessageCallback<T> messageCallback, Class<T> classOfCallback) Start consuming messages from a queue.
-
Method Details
-
sendMessage
Send a message with any class as a payload.- Parameters:
message
- to send into the queue.
-
setupExchange
void setupExchange(String exchange, com.rabbitmq.client.BuiltinExchangeType exchangeType) throws IOException Setup an exchange with a specific type and name.- Parameters:
exchange
- The exchanges nameexchangeType
- The exchangesBuiltinExchangeType
- Throws:
IOException
- when an error is encountered during exchange setup.
-
bindQueueToExchange
Bind a queue to an existing exchange.If the given queue doesn't exist it will be created automatically.
- Parameters:
queue
- The queues nameexchange
- The exchanges name- Throws:
IOException
- when an error is encountered during binding process.
-
bindQueueToExchange
Bind a queue to an exchange with a specific routing key.If the given queue doesn't exist it will be created automatically.
- Parameters:
queue
- The queues nameexchange
- The exchanges nameroutingKey
- a exchange look at when deciding how to route the message.- Throws:
IOException
- when an error is encountered during binding process.
-
startConsuming
<T> void startConsuming(String queue, MessageCallback<T> messageCallback, Class<T> classOfCallback) throws IOException Start consuming messages from a queue.- Type Parameters:
T
- is the type of the message.- Parameters:
queue
- The queues namemessageCallback
- used for consuming the messages.classOfCallback
- is the class of the messages that should be consumed.- Throws:
IOException
- when an error is encountered during consumption.
-