List all the messages discovered for events, messages and commands when using custom convetions

we are using custom conventions for defining events, commands and messages.
Questions

  1. is there a way to get the list of the all the event, messages and commands discovered by the custom conventions, i am running into an issue where a namespace which is not part of the convention, is being handled without any issues.

Thanks -Nen

Hi

You can log a list of messages discovered by NServiceBus. In order to do so, you need to create a FeatureStartupTask that takes a dependency on MessageMetadataRegistry and queries it to get the list of all discovered message types.

Szymon

i was able to create a custom a feature and associate it with a featurestartuptask, but not sure on how to get hold of the MessageMetadataRegistry.

both FeatureConfigurationContext (in feature) and IMessageSession (in featurestartuptask) dont expose the metadataregistry.

Thanks -Nen

Hi

You need to add it as a constructor argument to your feature startup task. The MessageMetadataRepository is registered in the NServiceBus DI container which is used to instantiate feature startup tasks so it will get automatically passed to your task.

public class MyFeatureStartupTask : FeatureStartupTask
{
   readonly MessageMetadataRepository repository;

   public MyFeatureStartupTask(MessageMetadataRepository repository)
   {
      this.repository = repository;
   }
}

Szymon

1 Like