License Configuration
MassTransit v9 (and beyond) requires a license to use, which gives you a license key file. Once you receive your license key, it will look similar to the license shown below (with your own values):
-----BEGIN LICENSE KEY-----c1SDNOXHUwMDJCTUFkSVRqTExWSzMwc0xiUkxMM0JDa3ZhWUpXWFNUbXJ3N1x1MDAyQmRFRjR0WnZiblJ2WW1Wc0lpd2laVzFoYVd3aU9pSnpkRtWVc0dVpHRmxkSGQ1YkdWeVFIWnZiblJ2WW1WT2lJeU1ESMVEV5TFRBNVZEQXdPakF3T2pBd1dpSXNJbVY0Y0dseVpYTWlPaUl5TURJM0xUQXhMeyJ2ZXJzaW9uIjojEiLCJraW5kIjoiTGljZW5zZSIsIm1ldGEiOnsic2lnbmF0dXJlLWFsZ29yc0xtTnZiU0o5TENKamRYTjMjFsY2lJNmV5SnBaQ0k2SW1OMWMxOVVXbHBIYzFCUVlrOW1jRzR4T0NJc0ltNWhiV1VpT2lKQ1lXNJRlp2Ym5SdlltVnNJbjBzSW5CeWIyUjFZM1J6SWpwN0ltMWhjOXVJam9pVFdGemMxUnlZV6YVhRZ1RHbGpaVzV6WlNJc0ltVjRjR2x5WlhNaU9pSXlNREkyTFRFeUxUQTVWREF3T2pBd09qdXaUlzSW1abFlYUjFjbVZ6SWpwdWRXeHNmWDBzSW1OeVpXRjBaV1FpVEE0VkRBd09qQXdPakF3lKOSIsInNpZ25hdHVyZSI6IkFYMVRJNWE2c1dMZXVoNi9rLzcxNk8vaXRobSI6IkVDRHNhIn0sImRhdGEiJleUpqYjI1MFlXTjBJanA3SW01aGJXVWlPaUpDWVc1cklGM04wY21GdWMybDBJanA3SW01aGJXVWlPpOWVhOelZISmhibk5wZENJc0ltUmxjMk55YVhCMGFXVWJMMTF1R0libXd2YjlWR2ZhUTlkZ1FERExseDQUdrMVBvdmhaRkN2ajdWbDlQVFNiVkFFdUE3-----END LICENSE KEY-----Configure the license key
Section titled “Configure the license key”The license key can be configured in several ways, depending on your environment.
Environment Variable (Key)
Section titled “Environment Variable (Key)”Environment variables are a great way to store secrets and provide them to your application. They are easy to specify when using Docker or Kubernetes, both of which offer secure secret storage mechanisms.
Your license key can be set in an environment variable named MT_LICENSE and loaded automatically.
export MT_LICENSE="..."Environment Variable (File)
Section titled “Environment Variable (File)”You can store your license in a file and specify the file location using the MT_LICENSE_PATH environment variable. MassTransit will attempt to open and use
the license when the bus is configured.
export MT_LICENSE_PATH="/app/license.txt"License Key
Section titled “License Key”You can specify the license directly by calling SetLicense on the bus configurator. This allows you to store the key however you want and provide it to the
bus configuration.
services.AddMassTransit(x =>{ string licenseKey = ""; // load the key here
x.UsingRabbitMq((context, cfg) => { cfg.SetLicense(licenseKey);
cfg.ConfigureEndpoints(context); });});License File
Section titled “License File”You can store your license in a file that is deployed with your application and specify the file location by calling SetLicenseLocation on the bus
configurator.
services.AddMassTransit(x =>{ x.UsingRabbitMq((context, cfg) => { cfg.SetLicenseLocation("./license.txt");
cfg.ConfigureEndpoints(context); });});