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
public class Outboxes.DurableQueueBasedOutboxes.DurableQueueBasedOutbox extends Object implements Outbox
-
-
Field Summary
Fields Modifier and Type Field Description OutboxConfigconfigQueueNameoutboxQueueName
-
Constructor Summary
Constructors Constructor Description DurableQueueBasedOutbox(OutboxConfig config)DurableQueueBasedOutbox(OutboxConfig config, Consumer<Message> messageConsumer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Outboxconsume(Consumer<Message> messageConsumer)Start consuming messages from the Outbox using the provided message consumer.
Only needs to be called if the instance was created without a message consumerlonggetNumberOfOutgoingMessages()Get the number of message in the outbox that haven't been sent yetbooleanhasAMessageConsumer()Has the instance been created with a Message consumer or hasOutbox.consume(Consumer)been calledbooleanisConsumingMessages()Is the provided Message consumer consuming messages from theOutboxOutboxNamename()The name of the outboxvoidsendMessage(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 consumervoidstopConsuming()Stop consuming messages from theOutbox.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface dk.cloudcreate.essentials.components.foundation.messaging.eip.store_and_forward.Outbox
sendMessage, sendMessage
-
-
-
-
Field Detail
-
outboxQueueName
public final QueueName outboxQueueName
-
config
public final OutboxConfig config
-
-
Constructor Detail
-
DurableQueueBasedOutbox
public DurableQueueBasedOutbox(OutboxConfig config, Consumer<Message> messageConsumer)
-
DurableQueueBasedOutbox
public DurableQueueBasedOutbox(OutboxConfig config)
-
-
Method Detail
-
consume
public Outbox consume(Consumer<Message> messageConsumer)
Description copied from interface:OutboxStart consuming messages from the Outbox using the provided message consumer.
Only needs to be called if the instance was created without a message consumerIf 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
-
stopConsuming
public void 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
-
name
public OutboxName name()
Description copied from interface:OutboxThe name of the outbox
-
sendMessage
public void sendMessage(Message payload)
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- See Also:
OrderedMessage
-
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
-
-