IMessageQueueRegistry
Each namespace has a MessageQueueRegistry. All message queues of the namespaces are registered here. Each MessageQueueRegistry contains at least one message queue. However, the user can add more.
Access
The registry is obtained via getter from the namespace:
final IMessageQueueRegistry mqr = namespace.getMessageQueueRegistry();
Creating a message queue
This method creates a message queue and starts it.
@NotNull IMessageQueue createAndStartAsyncQueue(@NotNull IId aQueueId,
@NotNull String aDesc,
int aThreadPriority) throws CException;
It requires a valid queue ID, which can be created via CIdFactory.
final IId qid = CIdFactory.create("Thread2");
final IMessageQueue queue = createAndStartAsyncQueue(qid,
"Thread2ForSomething",
MIN_PRIORITY);
Delete a message queue
An existing message queue can be deleted by:
void deleteQueue(@NotNull IId aQID) throws CException;
Fetch a message queue
The first (and most important) queue of a namespace can be fetched via:
@Nullable IMessageQueue getFirstQueue();
An individual queue can be queried via ID. While the first method
can return null, the second method throws an exception in this case.
@Nullable IMessageQueue getQueue(@NotNull IId aQID);
@NotNull IMessageQueue getQueueEx(@NotNull IId aQID) throws CException;
All registered Queues in this registry can be fetched via:
IId @NotNull [] getQueueIdArray();
The number of registered queues in this registry can be retrieved via:
int size();
Queue information
For display purposes, information about the queues can also be queried:
void getQueueInfo(@NotNull IId aQID,
@NotNull CRecord aRecord) throws CException;
The record is of type CRecordServiceGetQueueInfo.
Namespace
The MessageQueueRegistry always belongs to a namespace. Therefore, there is also a method to get the namespace ID:
@NotNull IId getNamespaceId();
Observers
It is possible to monitor the MessageQueueRegistry via Observer:
IId @NotNull [] registerQueueListener(@NotNull CTargetAddress aListener);
void deregisterQueueListener(@NotNull CTargetAddress aListener);
The observers then receive the messages CRecordNotifyQueueRegistered and CRecordNotifyQueueDeregistered respectively.
Related Pages
Threads und Message-Queues
The Threads and Message Queues section describes the asynchronous processing infrastructure of NYSSR, where each Namespace utilizes threads that operate IMessageQueues to cache and deliver CMessage ob
INamespace
The INamespace interface provides the encapsulated working environment for NYSSR applications/microservices. It manages threads, local service registries (Nano and Target), and defines the boundaries
EThreadPriority
The EThreadPriority enumeration defines ten standardized priority levels for threads in NYSSR, ranging from LOWEST (1) to HIGHEST (10), used for resource allocation and management, e.g., in the Job En
IMessageQueue
The IMessageQueue interface represents the message queue for a single thread within a NYSSR Namespace, ensuring that all CMessage objects destined for an associated ITarget are processed sequentially