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.
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)longgetNumberOfOutgoingMessages()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 outboxOutboxsendMessage(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 consumerOutboxsetMessageConsumer(Consumer<Message> messageConsumer)Set the message consumer.OutboxstartConsuming()Start consuming messages from theOutbox.OutboxstopConsuming()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
-
setMessageConsumer
public Outbox setMessageConsumer(Consumer<Message> messageConsumer)
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
public Outbox consume(Consumer<Message> messageConsumer)
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
public 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
public Outbox 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
public OutboxName name()
Description copied from interface:OutboxThe name of the outbox
-
sendMessage
public Outbox 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- Returns:
- this outbox instance
- 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
-
-