CRecordStartTarget
The first message sent to a Target after registering with the TargetRegistry.
Description
<record id="42e31e06-40f6-4c84-870f-1e54bec696bd" name="START_TARGET" isService="false"> <description> The first message a target will get (asynchronously). </description> <slot key="1" name="TARGET_ADDRESS" answer="false" mandatory="true" type="TARGET_ADDRESS"> <description>The new target address.</description> </slot> <slot key="2" name="QID" answer="false" mandatory="true" type="ID"> <description>The message queue ID.</description> </slot> <slot key="3" name="TARGET_REGISTRY" answer="false" mandatory="true" type="OBJECT"> <description>The target registry the target was registered in.</description> </slot> <slot key="4" name="MESSAGE_SENDER" answer="false" mandatory="true" type="OBJECT"> <description>The message sender needed to send messages.</description> </slot> </record>
Example of use of the class CRecordStartTarget (after generating)
To catch this message, we need a message handler. We add it in the constructor of the message handler registry.
// constructor: addMessageHandler(CRecordStartTarget.ID, this::asyncStartTarget);
The message is handled in the local method asyncStartTarget
:
private boolean asyncStartTarget(@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { // In the thread of the namespace where the target was registered // do something... aEnvelope.setResultSuccess(); return true; }
Well, every time a target is deregistered in our node, we get this message.