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.

nyssr.net - Innovative Distributed System