示例#1
0
        void PossiblyInitializeFromConfigurationSection()
        {
            var config = RebusConfigurationSection.LookItUp(returnNullIfNotFound: true);

            if (config == null)
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(config.AuditQueue))
            {
                PerformMessageAudit(config.AuditQueue);
            }
        }
示例#2
0
        void PossiblyInitializeFromConfigurationSection()
        {
            var config = RebusConfigurationSection.LookItUp();

            if (config == null)
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(config.AuditQueue))
            {
                PerformMessageAudit(config.AuditQueue);
            }
            BackoffBehavior = BackoffBehavior.Default();
        }
        /// <summary>
        /// Constructs the endpoint mapper, using the specified type filter to determine whether an encountered
        /// type should be mapped. Can be used to avoid mapping e.g. factories and stuff if you want to put
        /// helper classes inside your message assembly
        /// </summary>
        public DetermineMessageOwnershipFromRebusConfigurationSection(Func <Type, bool> typeFilter)
        {
            this.typeFilter = typeFilter;

            try
            {
                var section = RebusConfigurationSection.LookItUp();

                PopulateMappings(section);
            }
            catch (ConfigurationErrorsException e)
            {
                throw new ConfigurationException(
                          @"
An error occurred when trying to parse out the configuration of the RebusConfigurationSection:

{0}

-

For this way of configuring endpoint mappings to work, you need to supply a correct configuration
section declaration in the <configSections> element of your app.config/web.config - like so:

    <configSections>
        <section name=""rebus"" type=""Rebus.Configuration.RebusConfigurationSection, Rebus"" />
        <!-- other stuff in here as well -->
    </configSections>

-and then you need a <rebus> element some place further down the app.config/web.config,
like so:

{1}

This example shows how it's possible to map all types from an entire assembly to an endpoint. 

This is the preferred way of mapping message types, because it is a sign that you have structured your code
in a nice 1-message-assembly-to-1-endpoint kind of way, which requires the least amount of configuration
and maintenance on your part.

You CAN, however, map a single type at a time, and these explicit mappings WILL OVERRIDE assembly
mappings. So if you map an entire assembly to an endpoint, and you map one of the types from that
assembly to another endpoint explicitly, the explicit mapping will be the one taking effect.

Note also, that specifying the input queue name with the 'inputQueue' attribute is optional.
",
                          e, RebusConfigurationSection.ExampleSnippetForErrorMessages);
            }
        }