Target Registry

The target registry is used to register targets. This is the prerequisite for receiving messages.

Target registries are always bound to a namespace, or the other way around, each namespace has a target registry.

Registering Targets

When registering, targets are assigned an ID; either their wish ID, which is given when registering, or a random ID.

If the target is to be bound to a particular thread, the corresponding queue ID can be specified. If the QID is missing, the target is bound to the first queue of the namespace. This is the normal case, since namespaces usually have only one queue. In any case, the target will receive all messages it receives in the thread of this queue. This ensures simple data handling without regard to problems of concurrency. It is recommended that you register all targets that share data (without messages) with each other in the same namespace and queue.

The following methods are available for registration:

// Default QID, "random" TID
void registerTarget(ITarget aTarget) throws CException;

// Default QID
void registerTarget(ITarget aTarget,
                    IId aTID) throws CException;

void registerTarget(ITarget aTarget,
                    IId aTID,
                    IId aQID) throws CException;

Deregistration of Targets

The following methods are responsible for deregistration:

void deregisterTarget(IId aTID) throws CException;

void deregisterTarget(ITarget aTarget) throws CException;

void deregisterTarget(ITargetAddress aAddress) throws CException;

Accessing Targets

Registered targets can be determined:

// By TID
ITarget getTarget(IId aTID);

Details can also be retrieved using the synchronous method or a request message.:

// Details
void getTargetInfo(IId aTID,
                   CRecord aRecord) throws CException;

The completed record is of type CRecordGetTargetInfo.

You can get a list of all targets of a namespace by calling:

IId[] getTIDs();

If you want to restrict the list to a particular message queue, choose the following method:

IId[] getTIDs(IId aQID);

An Exist method also exists:

boolean isTargetRegistered(IId aTID);

Message Queues of Targets

The message queues of targets can be determined easily:

IMessageQueue getQueue(IId aTID);

IId getQueueId(IId aTID);

Target Monitors

To monitor the registration and deregistration of specific targets, you can use the following methods:

void registerTargetMonitor(IId aTID,
                           ITargetAddress aObserver) throws CException;

void deregisterTargetMonitor(IId aTID,
                             ITargetAddress aObserver);

Clients then receive the messages

  • CRecordNotifyTargetRegistered.ID when registering the target
  • CRecordNotifyTargetDeregistered.ID when deregistering the target.

More generally, the Target Listeners are the ones who receive a message with each target that is registered or deregistered.:

ITargetAddress[] registerTargetListener(ITargetAddress aAddress);

void deregisterTargetListener(ITargetAddress aAddress);

Internal methods

The following methods are called by the framework itself.

If a target does not exist, it could be that the message that creates the target has not yet arrived (priority, delay). Therefore, the message addressed to a non-existent target is held back for a short time. If the target is registered during this time, the target receives the waiting message. However, if the time runs out, the message is returned with an error code.

Internally, this method is called for saving the message:

void addPendingMessage(CMessage aMsg);

Another method informs the TargetRegistry that a queue has been removed. All targets belonging to this queue are removed.

void notifyQueueDeregistered(IId aQueueId);