Exemplo n.º 1
0
        /// <summary>
        /// Given a type, this will return destination queue name.
        /// </summary>
        /// <param name="jarvisRebusConfiguration"></param>
        /// <param name="type">This can be a type representing a command or it can also be any other type (like
        /// aggregateId for mixin command)</param>
        /// <returns></returns>
        public static string GetEndpointFor(this JarvisRebusConfiguration jarvisRebusConfiguration, Type type)
        {
            String returnValue = "";

            //we can have in endpoints configured a namespace or a fully qualified name
            var asqn = type.FullName + ", " + type.Assembly.GetName().Name;

            if (jarvisRebusConfiguration.EndpointsMap.ContainsKey(asqn))
            {
                //exact match
                returnValue = jarvisRebusConfiguration.EndpointsMap[asqn];
            }
            else
            {
                //find the most specific namespace that contains the type to dispatch.
                var endpointElement =
                    jarvisRebusConfiguration.EndpointsMap
                    .Where(e => asqn.StartsWith(e.Key, StringComparison.OrdinalIgnoreCase))
                    .OrderByDescending(e => e.Key.Length)
                    .FirstOrDefault();
                if (!String.IsNullOrEmpty(endpointElement.Key))
                {
                    returnValue = endpointElement.Value;
                }
            }

            return(returnValue);
        }
Exemplo n.º 2
0
 public BusStarter(
     RebusConfigurer rebusConfigurer,
     JarvisRebusConfiguration configuration)
 {
     _rebusConfigurer = rebusConfigurer;
     _configuration   = configuration;
 }
Exemplo n.º 3
0
 public BusStarter(
     IStartableBus startableBus,
     JarvisRebusConfiguration configuration,
     IBus bus)
 {
     _startableBus  = startableBus;
     _configuration = configuration;
     _bus           = bus;
 }
Exemplo n.º 4
0
 public JarvisFrameworkErrorHandler(
     JarvisRebusConfiguration jarvisRebusConfiguration,
     JsonSerializerSettings jsonSerializerSettings,
     IWindsorContainer container,
     ILogger logger)
 {
     _jsonSerializerSettings = jsonSerializerSettings;
     _container                = container;
     _lazyBus                  = new Lazy <IBus>(() => _container.Resolve <IBus>());
     _lazyMessageTracker       = new Lazy <IMessagesTracker>(() => _container.Resolve <IMessagesTracker>());
     _logger                   = logger;
     _jarvisRebusConfiguration = jarvisRebusConfiguration;
 }
Exemplo n.º 5
0
        protected BusBootstrapper(
            IWindsorContainer container,
            JarvisRebusConfiguration configuration,
            IMessagesTracker messagesTracker,
            Boolean useCustomJarvisFrameworkBinder)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            if (messagesTracker == null)
            {
                throw new ArgumentNullException(nameof(messagesTracker));
            }

            if (configuration.AssembliesWithMessages?.Any() == false)
            {
                var message = @"Rebus configuration has no AssembliesWithMessages. It is necessary to 
at least configure one assembly with messages to be dispatched.";
                throw new InvalidOperationException(message);
            }

            _container = container;
            JarvisRebusConfiguration = configuration;
            var mongoUrl    = new MongoUrl(configuration.ConnectionString);
            var mongoClient = mongoUrl.CreateClient(false);

            _mongoDatabase = mongoClient.GetDatabase(mongoUrl.DatabaseName);
            var factory = container.Resolve <ILoggerFactory>();

            Logger = factory.Create(GetType());

            // PRXM
            JsonSerializerSettingsForRebus.ContractResolver    = new MessagesContractResolver();
            JsonSerializerSettingsForRebus.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
            if (useCustomJarvisFrameworkBinder)
            {
                JsonSerializerSettingsForRebus.SerializationBinder = new JarvisFrameworkRebusSerializationBinder(factory.Create(typeof(JarvisFrameworkRebusSerializationBinder)));
            }
            _messagesTracker = messagesTracker;
            // PRXM
        }
Exemplo n.º 6
0
 public JarvisRebusConfigurationManagerRouterHelper(
     JarvisRebusConfiguration configuration)
 {
     _configuration = configuration;
 }