Executing

A sequence of subscribers is executing upon publisher requests.

Executing Sequence

When a request from publisher is received, a sequence of jobs is processing one by one.

  1. Invokes ArgumentConvertingCallback defined in MessageBusPublisherOptions.

  2. Clones the sequence of the current linked subscribers.

      Note

    The cloning process is taken before processing each subscriber. Therefore, registering or unregistering subscriber does never interfere the sequences that are executing.

  3. For each sequence:

    1. Invokes ConditionCheckingCallback defined in MessageBusSubscriberOptions. If presents and false / False returned, the subscriber is skipped.

    2. Invokes ArgumentConvertingCallback defined in MessageBusSubscriberOptions.

    3. Runs the callback of the subscriber.

    4. Determines whether the result is accepted.

  4. For each left sequence which need to be execute (IsAlwaysExecuteAll in MessageBusPublisherOptions or IsAlwaysExecution in MessageBusSubscriberOptions):

    1. Invokes ConditionCheckingCallback defined in MessageBusSubscriberOptions. If presents and false / False returned, the subscriber is skipped.

    2. Invokes ArgumentConvertingCallback defined in MessageBusSubscriberOptions.

    3. Runs the callback of the subscriber.

    • If the executor need return value:

        • If accepted result is generated from one subscriber: Invokes ReturnValueConvertingCallback defined in MessageBusPublisherOptions.

        • If accepted result is NOT generated from one subscriber: Takes DefaultReturnValue defined in MessageBusPublisherOptions.

      1. Returns the value.

    • If the executor do NOT need return value: Returns.

  Note

Synchronous and Asynchronous callings are both supported. Check Sync / Async for details.

Message Instance

An instance of MessageInstance is creates every time the publisher requests.

The instance of MessageInstance contains an unique id that is different for each execution requested from executor and the message name. When IsSubscriberReturnValueAccepted is true / True, the instance contains the id and the returned value (if available) from the subscriber which generated the accepted return value.

Get Message Instance

Subscribers can get the instance of MessageInstance through the parameter. When required, defines the method with the right signature. See Subscriber Register for details.

After publisher executed, the instance of MessageInstance can be returned in 3 ways:

Get Return Value from Message Instance

Otherwise,

  Note

The value stored in the instance of MessageInstance is from the subscriber. The value is not converted by the ReturnValueConvertingCallback defined in MessageBusPublisherOptions.

When the default value is returned, the instance of MessageInstance does not contains any return value.

See Also