Beispiel #1
0
        // TODO -- just pull in MessagingRoot?
        public MessageContext(IMessageRouter router, IReplyWatcher watcher, IHandlerPipeline pipeline, MessagingSerializationGraph serialization, MessagingSettings settings, IChannelGraph channels, IDurableMessagingFactory factory, IMessageLogger logger, Envelope originalEnvelope)
        {
            _router        = router;
            _watcher       = watcher;
            _pipeline      = pipeline;
            _serialization = serialization;
            _settings      = settings;
            _channels      = channels;
            Factory        = factory;
            _logger        = logger;

            Envelope = originalEnvelope;
            _sagaId  = originalEnvelope.SagaId;


            var persistor = new InMemoryEnvelopeTransaction();

            EnlistedInTransaction = true;
            Transaction           = persistor;

            if (Envelope.AckRequested)
            {
                var ack = buildAcknowledgement();

                persistor.Queued.Fill(ack);
                _outstanding.Add(ack);
            }
        }
Beispiel #2
0
 public ServiceBus(IEnvelopeSender sender, IReplyWatcher watcher, IHandlerPipeline pipeline, SerializationGraph serialization)
 {
     _sender        = sender;
     _watcher       = watcher;
     _pipeline      = pipeline;
     _serialization = serialization;
 }
Beispiel #3
0
 public MessageRouter(SerializationGraph serializers, IChannelGraph channels, ISubscriptionsRepository subscriptions, HandlerGraph handlers, CompositeLogger logger, UriAliasLookup lookup)
 {
     _serializers   = serializers;
     _channels      = channels;
     _subscriptions = subscriptions;
     _handlers      = handlers;
     _logger        = logger;
     _lookup        = lookup;
 }
Beispiel #4
0
        public ConnegRules(SerializationGraph serializers, IEnumerable <IReaderRule> readerRules, IEnumerable <IWriterRule> writeRules)
        {
            _serializers = serializers;

            _writers.AddRange(writeRules);
            _readers.AddRange(readerRules);

            addDefaultRules();
        }
Beispiel #5
0
 public MessageRouter(IMessagingRoot root, HandlerGraph handlers)
 {
     _serializers = root.Serialization;
     _subscribers = root.Subscribers;
     _handlers    = handlers;
     _logger      = root.Logger;
     _settings    = root.Settings;
     _workers     = _handlers.Workers;
 }
 public ServiceBusActivator(BusSettings settings, IHandlerPipeline pipeline, IDelayedJobProcessor delayedJobs, SerializationGraph serialization, IEnumerable <ITransport> transports, UriAliasLookup lookups, INodeDiscovery nodes)
 {
     _settings      = settings;
     _pipeline      = pipeline;
     _delayedJobs   = delayedJobs;
     _serialization = serialization;
     _transports    = transports.ToArray();
     _lookups       = lookups;
     _nodes         = nodes;
 }
Beispiel #7
0
        public MartenBackedMessagePersistence(IDocumentStore store, CompositeTransportLogger logger, BusSettings settings, EnvelopeTables tables, BusMessageSerializationGraph serializers)
        {
            _store       = store;
            _logger      = logger;
            Settings     = settings;
            Tables       = tables;
            _serializers = serializers;

            _retries = new MartenRetries(_store, tables, _logger, Settings);
        }
Beispiel #8
0
 public ServiceBus(IEnvelopeSender sender, IReplyWatcher watcher, IHandlerPipeline pipeline, BusMessageSerializationGraph serialization, BusSettings settings, IChannelGraph channels, IPersistence persistence)
 {
     _sender        = sender;
     _watcher       = watcher;
     _pipeline      = pipeline;
     _serialization = serialization;
     _settings      = settings;
     _channels      = channels;
     _persistence   = persistence;
 }
Beispiel #9
0
 public MessageRouter(MessagingSerializationGraph serializers, IChannelGraph channels, ISubscriptionsRepository subscriptions, HandlerGraph handlers, IMessageLogger logger, UriAliasLookup lookup, MessagingSettings settings)
 {
     _serializers   = serializers;
     _channels      = channels;
     _subscriptions = subscriptions;
     _handlers      = handlers;
     _logger        = logger;
     _lookup        = lookup;
     _settings      = settings;
 }
Beispiel #10
0
 public LocalSendingAgent(Uri destination, IWorkerQueue queues, IDocumentStore store, EnvelopeTables marker, SerializationGraph serializers, MartenRetries retries, CompositeTransportLogger logger)
 {
     _queues      = queues;
     _store       = store;
     _marker      = marker;
     _serializers = serializers;
     _retries     = retries;
     _logger      = logger;
     Destination  = destination;
 }
Beispiel #11
0
 public ServiceBus(IMessageRouter router, IReplyWatcher watcher, IHandlerPipeline pipeline, BusMessageSerializationGraph serialization, BusSettings settings, IChannelGraph channels, IPersistence persistence, CompositeMessageLogger logger)
 {
     _router        = router;
     _watcher       = watcher;
     _pipeline      = pipeline;
     _serialization = serialization;
     _settings      = settings;
     _channels      = channels;
     Persistence    = persistence;
     _logger        = logger;
 }
Beispiel #12
0
        public DurableLoopbackSendingAgent(Uri destination, IWorkerQueue queues, IEnvelopePersistence persistence,
                                           SerializationGraph serializers, ITransportLogger logger)
        {
            _queues      = queues;
            _serializers = serializers;
            _logger      = logger;

            _persistence = persistence;

            Destination = destination;
        }
Beispiel #13
0
 // TODO -- just pull in MessagingRoot?
 public MessageContext(IMessageRouter router, IReplyWatcher watcher, IHandlerPipeline pipeline, MessagingSerializationGraph serialization, MessagingSettings settings, IChannelGraph channels, IDurableMessagingFactory factory, IMessageLogger logger)
 {
     _router        = router;
     _watcher       = watcher;
     _pipeline      = pipeline;
     _serialization = serialization;
     _settings      = settings;
     _channels      = channels;
     Factory        = factory;
     _logger        = logger;
 }
Beispiel #14
0
        private PublishedMessage[] determinePublishedMessages(SerializationGraph serialization, JasperRuntime runtime, string[] validTransports)
        {
            foreach (var published in _published)
            {
                published.ServiceName = runtime.ServiceName;
                var writer = serialization.WriterFor(published.DotNetType);
                published.ContentTypes = writer.ContentTypes;
                published.Transports   = validTransports;
            }

            return(_published.ToArray());
        }
Beispiel #15
0
        public HandlerPipeline(IEnvelopeSender sender, SerializationGraph serializers, HandlerGraph graph, IReplyWatcher replies, IDelayedJobProcessor delayedJobs, CompositeLogger logger, IChannelGraph channels, IEnumerable <IMissingHandler> missingHandlers)
        {
            _sender          = sender;
            _serializer      = serializers;
            _graph           = graph;
            _replies         = replies;
            _delayedJobs     = delayedJobs;
            _channels        = channels;
            _missingHandlers = missingHandlers.ToArray();

            Logger = logger;
        }
        public LocalSendingAgent(Uri destination, IWorkerQueue queues, IEnvelopePersistor persistor,
                                 SerializationGraph serializers, IRetries retries, ITransportLogger logger)
        {
            _queues      = queues;
            _serializers = serializers;
            _retries     = retries;
            _logger      = logger;

            _persistor = persistor;

            Destination = destination;
        }
Beispiel #17
0
        public void ApplyConneg(SerializationGraph graph)
        {
            if (InputType != null)
            {
                ConnegReader = graph.ReaderFor(InputType);
            }

            if (ResourceType != null)
            {
                ConnegWriter = graph.WriterFor(ResourceType);
            }
        }
 public ServiceBusActivator(BusSettings settings, IHandlerPipeline pipeline, IDelayedJobProcessor delayedJobs, BusMessageSerializationGraph serialization, IEnumerable <ITransport> transports, UriAliasLookup lookups, IWorkerQueue workerQueue, CompositeLogger logger, IPersistence persistence)
 {
     _settings      = settings;
     _pipeline      = pipeline;
     _delayedJobs   = delayedJobs;
     _serialization = serialization;
     _transports    = transports.ToArray();
     _lookups       = lookups;
     _workerQueue   = workerQueue;
     _logger        = logger;
     _persistence   = persistence;
 }
Beispiel #19
0
        private Subscription[] determineSubscriptions(HandlerGraph handlers, SerializationGraph serialization)
        {
            var messageTypes = handlers.Chains
                               .Select(x => x.MessageType)
                               .Where(t => t.GetTypeInfo().Assembly != GetType().GetTypeInfo().Assembly)
                               .ToArray();


            return(_requirements.SelectMany(x =>
                                            x.DetermineSubscriptions(serialization, messageTypes, DefaultReceiverLocation))
                   .Distinct()
                   .ToArray());
        }
Beispiel #20
0
        }                                         // could be a default here

        public IEnumerable <Subscription> DetermineSubscriptions(SerializationGraph serialization, Type[] allTypes, Uri defaultReceiver)
        {
            var receiver = ReceiverLocation ?? defaultReceiver;

            return(Includes.SelectMany(allTypes.Where)
                   .Concat(MessageTypes)
                   .Distinct()
                   .Select(type =>
            {
                var reader = serialization.ReaderFor(type);
                return new Subscription(type, receiver)
                {
                    Accept = reader.ContentTypes
                };
            }));
        }
Beispiel #21
0
        public void can_try_to_deserialize_an_envelope_with_no_message_type_or_content_type()
        {
            var serialization = SerializationGraph.Basic();

            var json = JsonConvert.SerializeObject(new Message2(), new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.All
            });

            var envelope = new Envelope()
            {
                Data        = Encoding.UTF8.GetBytes(json),
                MessageType = null,
                ContentType = null
            };

            serialization.Deserialize(envelope)
            .ShouldBeOfType <Message2>();
        }
Beispiel #22
0
        private async Task <ServiceCapabilities> compile(HandlerGraph handlers, SerializationGraph serialization, IChannelGraph channels, ITransport[] transports, UriAliasLookup lookups, JasperRuntime runtime)
        {
            var validTransports = transports.Select(x => x.Protocol).ToArray();

            var capabilities = new ServiceCapabilities
            {
                ServiceName   = runtime.ServiceName,
                Subscriptions = determineSubscriptions(handlers, serialization),
                Published     = determinePublishedMessages(serialization, runtime, validTransports)
            };

            // Hokey.
            foreach (var subscription in capabilities.Subscriptions)
            {
                subscription.ServiceName = runtime.ServiceName;
            }

            foreach (var message in capabilities.Published)
            {
                message.ServiceName = runtime.ServiceName;
            }

            await capabilities.ApplyLookups(lookups);

            // Now, do some validation
            var missingDestination = capabilities.Subscriptions
                                     .Where(x => x.Destination == null)
                                     .Select(s => $"Could not determine an incoming receiver for message '{s.MessageType}'");


            var invalidTransport = capabilities.Subscriptions
                                   .Where(x => x.Destination != null && !validTransports.Contains(x.Destination.Scheme))
                                   .Select(x => $"Unknown transport '{x.Destination.Scheme}' for subscription to message '{x.MessageType}'");

            var missingHandlers = capabilities.Subscriptions
                                  .Where(x => !handlers.CanHandle(x.DotNetType))
                                  .Select(x => $"No handler for message '{x.MessageType}' referenced in a subscription");

            capabilities.Errors = missingDestination.Concat(invalidTransport).Concat(missingHandlers).ToArray();


            return(capabilities);
        }
Beispiel #23
0
        public async Task <ServiceCapabilities> Compile(HandlerGraph handlers, SerializationGraph serialization, IChannelGraph channels, JasperRuntime runtime, ITransport[] transports, UriAliasLookup lookups)
        {
            if (runtime.ApplicationAssembly != null)
            {
                var publishedTypes = await TypeRepository.FindTypes(runtime.ApplicationAssembly,
                                                                    TypeClassification.Closed | TypeClassification.Closed, type => _publishFilters.Any(x => x(type)));

                foreach (var type in publishedTypes)
                {
                    Publish(type);
                }
            }



            var capabilities = await compile(handlers, serialization, channels, transports, lookups);

            return(capabilities);
        }
        public registering_and_discovering_custom_readers_and_writers()
        {
            withAllDefaults();

            theSerialization = Runtime.Get <BusMessageSerializationGraph>();
        }