Class Outboxes.DurableQueueBasedOutboxes.DurableQueueBasedOutbox
java.lang.Object
dk.cloudcreate.essentials.components.foundation.messaging.eip.store_and_forward.Outboxes.DurableQueueBasedOutboxes.DurableQueueBasedOutbox
- All Implemented Interfaces:
Outbox
- Enclosing class:
- Outboxes.DurableQueueBasedOutboxes
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDurableQueueBasedOutbox(OutboxConfig config) DurableQueueBasedOutbox(OutboxConfig config, Consumer<Message> messageConsumer) -
Method Summary
Modifier and TypeMethodDescriptionStart consuming messages from the Outbox using the provided message consumer.
This is the same as callingOutbox.setMessageConsumer(Consumer)followed byOutbox.startConsuming()
Only needs to be called if the instance was created without a message consumer such as viaOutboxes.getOrCreateOutbox(OutboxConfig)longGet the number of message in the outbox that haven't been sent yetbooleanHas the instance been created with a Message consumer or hasOutbox.consume(Consumer)been calledbooleanIs the provided Message consumer consuming messages from theOutboxname()The name of the outboxsendMessage(Message payload) Send a message asynchronously.
This message will be stored durably (without any duplication check) in connection with the currently activeUnitOfWork(or a newUnitOfWorkwill be created in case no there isn't an activeUnitOfWork).
The message will be delivered asynchronously to the message consumersetMessageConsumer(Consumer<Message> messageConsumer) Set the message consumer.Start consuming messages from theOutbox.Stop consuming messages from theOutbox.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface dk.cloudcreate.essentials.components.foundation.messaging.eip.store_and_forward.Outbox
sendMessage, sendMessage
-
Field Details
-
outboxQueueName
-
config
-
-
Constructor Details
-
DurableQueueBasedOutbox
-
DurableQueueBasedOutbox
-
-
Method Details
-
setMessageConsumer
Description copied from interface:OutboxSet the message consumer. To start consuming callOutbox.startConsuming()- Specified by:
setMessageConsumerin interfaceOutbox- Parameters:
messageConsumer- the message consumer. SeePatternMatchingMessageHandler- Returns:
- this outbox instance
-
consume
Description copied from interface:OutboxStart consuming messages from the Outbox using the provided message consumer.
This is the same as callingOutbox.setMessageConsumer(Consumer)followed byOutbox.startConsuming()
Only needs to be called if the instance was created without a message consumer such as viaOutboxes.getOrCreateOutbox(OutboxConfig)If an
OrderedMessageis delivered via anOutboxusing aFencedLock(such as theOutboxes.durableQueueBasedOutboxes(DurableQueues, FencedLockManager)) to coordinate message consumption, then you can find theFencedLock.getCurrentToken()of the consumer in theMessage.getMetaData()under keyMessageMetaData.FENCED_LOCK_TOKEN- Specified by:
consumein interfaceOutbox- Parameters:
messageConsumer- the message consumer. SeePatternMatchingMessageHandler- Returns:
- this outbox instance
-
hasAMessageConsumer
public boolean hasAMessageConsumer()Description copied from interface:OutboxHas the instance been created with a Message consumer or hasOutbox.consume(Consumer)been called- Specified by:
hasAMessageConsumerin interfaceOutbox- Returns:
- Has the instance been created with a Message consumer or has
Outbox.consume(Consumer)been called
-
isConsumingMessages
public boolean isConsumingMessages()Description copied from interface:OutboxIs the provided Message consumer consuming messages from theOutbox- Specified by:
isConsumingMessagesin interfaceOutbox- Returns:
- Is the provided Message consumer consuming messages from the
Outbox
-
startConsuming
Description copied from interface:OutboxStart consuming messages from theOutbox. Requires callingOutbox.setMessageConsumer(Consumer)first
If anOrderedMessageis delivered via anOutboxusing aFencedLock(such asOutboxes.durableQueueBasedOutboxes(DurableQueues, FencedLockManager)to coordinate message consumption, then you can find theFencedLock.getCurrentToken()of the consumer in theMessage.getMetaData()under keyMessageMetaData.FENCED_LOCK_TOKEN- Specified by:
startConsumingin interfaceOutbox- Returns:
- this outbox instance
-
stopConsuming
Description copied from interface:OutboxStop consuming messages from theOutbox. Calling this method will remove the message consumer and to resume message consumption you need to callOutbox.consume(Consumer)- Specified by:
stopConsumingin interfaceOutbox- Returns:
- this outbox instance
-
name
Description copied from interface:OutboxThe name of the outbox -
sendMessage
Description copied from interface:OutboxSend a message asynchronously.
This message will be stored durably (without any duplication check) in connection with the currently activeUnitOfWork(or a newUnitOfWorkwill be created in case no there isn't an activeUnitOfWork).
The message will be delivered asynchronously to the message consumer- Specified by:
sendMessagein interfaceOutbox- Parameters:
payload- the message- Returns:
- this outbox instance
- See Also:
-
getNumberOfOutgoingMessages
public long getNumberOfOutgoingMessages()Description copied from interface:OutboxGet the number of message in the outbox that haven't been sent yet- Specified by:
getNumberOfOutgoingMessagesin interfaceOutbox- Returns:
- Get the number of message in the outbox that haven't been sent yet
-
toString
-