Beispiel #1
0
        public MessagingRoot(MessagingSerializationGraph serialization,
                             JasperOptions options,
                             HandlerGraph handlers,
                             ISubscriberGraph subscribers,
                             IMessageLogger messageLogger,
                             IContainer container,
                             ITransportLogger transportLogger
                             )
        {
            Options          = options;
            Handlers         = handlers;
            _transportLogger = transportLogger;
            Subscribers      = subscribers;
            Transports       = container.QuickBuildAll <ITransport>().ToArray();


            Serialization = serialization;

            Logger = messageLogger;

            Pipeline = new HandlerPipeline(Serialization, handlers, Logger,
                                           container.QuickBuildAll <IMissingHandler>(),
                                           this);

            Workers = new WorkerQueue(Logger, Pipeline, options);

            Router = new MessageRouter(this, handlers);

            _persistence = new Lazy <IEnvelopePersistence>(() => container.GetInstance <IEnvelopePersistence>());
        }
Beispiel #2
0
        public MessagingRoot(MessagingSerializationGraph serialization,
                             JasperOptions settings,
                             HandlerGraph handlers,
                             IDurableMessagingFactory factory,
                             ISubscriberGraph subscribers,
                             IMessageLogger messageLogger,
                             IContainer container,
                             ITransportLogger transportLogger)
        {
            Settings         = settings;
            _handlers        = handlers;
            _transportLogger = transportLogger;
            Factory          = factory;
            Subscribers      = subscribers;
            Transports       = container.QuickBuildAll <ITransport>().ToArray();


            Serialization = serialization;

            Logger = messageLogger;

            Pipeline = new HandlerPipeline(Serialization, handlers, Logger,
                                           container.QuickBuildAll <IMissingHandler>(),
                                           this);

            Workers = new WorkerQueue(Logger, Pipeline, settings);

            Router = new MessageRouter(this, handlers);

            // TODO -- ZOMG this is horrible, and I admit it.
            if (Factory is NulloDurableMessagingFactory f)
            {
                f.ScheduledJobs = ScheduledJobs;
            }
        }
Beispiel #3
0
        public MessagingRoot(MessagingSerializationGraph serialization,
                             JasperOptions options,
                             IMessageLogger messageLogger,
                             IContainer container,
                             ITransportLogger transportLogger
                             )
        {
            Options         = options;
            Handlers        = options.HandlerGraph;
            TransportLogger = transportLogger;

            Settings      = options.Advanced;
            Serialization = serialization;

            MessageLogger = messageLogger;

            Pipeline = new HandlerPipeline(Serialization, Handlers, MessageLogger,
                                           container.QuickBuildAll <IMissingHandler>(),
                                           this);

            Runtime = new TransportRuntime(this);


            _persistence = new Lazy <IEnvelopePersistence>(() => container.GetInstance <IEnvelopePersistence>());

            Router = new EnvelopeRouter(this);

            _container = container;

            Cancellation = Settings.Cancellation;
        }
Beispiel #4
0
        public override void SetUp()
        {
            _envelopes.Clear();
            _nodeLockers.Clear();

            _workers        = new RecordingWorkerQueue();
            _schedulerAgent = new RecordingSchedulingAgent();

            _host = JasperHost.For(_ =>
            {
                _.Settings.PersistMessagesWithSqlServer(Servers.SqlServerConnectionString);

                _.Services.AddSingleton <IWorkerQueue>(_workers);
                _.Services.AddSingleton <IDurabilityAgent>(_schedulerAgent);


                _.Settings.Alter <JasperOptions>(x =>
                {
                    x.Retries.FirstNodeReassignmentExecution = 30.Minutes();
                    x.ScheduledJobs.FirstExecution           = 30.Minutes();
                    x.Retries.FirstNodeReassignmentExecution = 30.Minutes();
                    x.Retries.NodeReassignmentPollingTime    = 30.Minutes();
                });
            });

            _host.Get <IEnvelopePersistence>().Admin.ClearAllPersistedEnvelopes();

            _serializers = _host.Get <MessagingSerializationGraph>();

            _host.RebuildMessageStorage();

            _currentNodeId = _host.Get <JasperOptions>().UniqueNodeId;

            _owners["This Node"] = _currentNodeId;
        }
Beispiel #5
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;
 }
        public HandlerPipeline(MessagingSerializationGraph serializers, HandlerGraph graph, IMessageLogger logger,
                               IEnumerable <IMissingHandler> missingHandlers, IMessagingRoot root)
        {
            _serializer      = serializers;
            _graph           = graph;
            _root            = root;
            _missingHandlers = missingHandlers.ToArray();

            Logger = logger;
        }
Beispiel #7
0
        public HandlerPipeline(MessagingSerializationGraph serializers, HandlerGraph graph, IMessageLogger logger,
                               NoHandlerContinuation noHandlers, IMessagingRoot root)
        {
            _serializer   = serializers;
            _graph        = graph;
            _noHandlers   = noHandlers;
            _root         = root;
            _cancellation = root.Cancellation;

            Logger = logger;
        }
        public when_creating_a_service_bus_with_acknowledgement_required_envelope()
        {
            theEnvelope               = ObjectMother.Envelope();
            theEnvelope.Id            = Guid.NewGuid();
            theEnvelope.CorrelationId = Guid.NewGuid();
            theEnvelope.ReplyUri      = "tcp://server2:2000".ToUri();

            theEnvelope.AckRequested = true;

            theAcknowledgement = new AcknowledgementSender(null, MessagingSerializationGraph.Basic()).BuildAcknowledgement(theEnvelope);
        }
        public DurableLocalSendingAgent(Endpoint endpoint, IHandlerPipeline pipeline,
                                        AdvancedSettings settings, IEnvelopePersistence persistence, ITransportLogger logger,
                                        MessagingSerializationGraph serializers, IMessageLogger messageLogger) : base(endpoint, pipeline, settings, persistence, logger)
        {
            _settings      = settings;
            _persistence   = persistence;
            _logger        = logger;
            _serializers   = serializers;
            _messageLogger = messageLogger;
            Destination    = endpoint.Uri;

            Endpoint = endpoint;
            ReplyUri = TransportConstants.RepliesUri;
        }
Beispiel #10
0
        public MessagingRoot(ObjectPoolProvider pooling,
                             MessagingSettings settings,
                             HandlerGraph handlers,
                             Forwarders forwarders,
                             IDurableMessagingFactory factory,
                             IChannelGraph channels,
                             ISubscriptionsRepository subscriptions,
                             IMessageLogger messageLogger,
                             IEnumerable <ISerializerFactory> serializers,
                             IEnumerable <IMessageDeserializer> readers,
                             IEnumerable <IMessageSerializer> writers,
                             ITransport[] transports,
                             IEnumerable <IMissingHandler> missingHandlers,
                             IEnumerable <IUriLookup> lookups, ITransportLogger transportLogger)
        {
            Settings         = settings;
            _handlers        = handlers;
            _transportLogger = transportLogger;
            Replies          = new ReplyWatcher();
            Factory          = factory;
            Channels         = channels;
            Transports       = transports;



            Lookup = new UriAliasLookup(lookups);


            Serialization = new MessagingSerializationGraph(pooling, settings, handlers, forwarders, serializers,
                                                            readers, writers);

            Logger = messageLogger;

            Pipeline = new HandlerPipeline(Serialization, handlers, Replies, Logger, missingHandlers,
                                           this);

            Workers = new WorkerQueue(Logger, Pipeline, settings);

            Router = new MessageRouter(Serialization, channels, subscriptions, handlers, Logger, Lookup, settings);

            // TODO -- ZOMG this is horrible, and I admit it.
            if (Factory is NulloDurableMessagingFactory)
            {
                Factory.As <NulloDurableMessagingFactory>().ScheduledJobs = ScheduledJobs;
            }
        }
        public void can_try_to_deserialize_an_envelope_with_no_message_type_or_content_type()
        {
            var serialization = MessagingSerializationGraph.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>();
        }
        public override void SetUp()
        {
            _envelopes.Clear();
            _nodeLockers.Clear();

            _workers = new RecordingWorkerQueue();

            _host = JasperHost.CreateDefaultBuilder()
                    .UseJasper(_ =>
            {
                _.ServiceName = Guid.NewGuid().ToString();

                _.MartenConnectionStringIs(Servers.PostgresConnectionString);

                _.Services.AddSingleton <IWorkerQueue>(_workers);

                _.Include <MartenBackedPersistence>();

                _.Settings.Alter <JasperOptions>(x =>
                {
                    x.Retries.FirstNodeReassignmentExecution = 30.Minutes();
                    x.ScheduledJobs.FirstExecution           = 30.Minutes();
                    x.Retries.FirstNodeReassignmentExecution = 30.Minutes();
                    x.Retries.NodeReassignmentPollingTime    = 30.Minutes();
                });
            })
                    .StartJasper();


            _admin = _host.Get <IEnvelopePersistence>().Admin;
            _admin.RebuildSchemaObjects();

            _settings    = _host.Get <PostgresqlSettings>();
            _serializers = _host.Get <MessagingSerializationGraph>();

            theStore = _host.Get <IDocumentStore>();
            theStore.Advanced.Clean.DeleteAllDocuments();

            _currentNodeId = _host.Get <JasperOptions>().UniqueNodeId;

            _owners["This Node"] = _currentNodeId;
        }
Beispiel #13
0
        public MessagingRoot(
            MessagingSerializationGraph serialization,
            MessagingSettings settings,
            HandlerGraph handlers,
            IDurableMessagingFactory factory,
            IChannelGraph channels,
            ISubscriptionsRepository subscriptions,
            IMessageLogger messageLogger,
            Lamar.IContainer container,
            ITransportLogger transportLogger)
        {
            Settings         = settings;
            _handlers        = handlers;
            _transportLogger = transportLogger;
            Replies          = new ReplyWatcher();
            Factory          = factory;
            Channels         = channels;
            Transports       = container.QuickBuildAll <ITransport>().ToArray();



            Lookup = new UriAliasLookup(container.QuickBuildAll <IUriLookup>());


            Serialization = serialization;

            Logger = messageLogger;

            Pipeline = new HandlerPipeline(Serialization, handlers, Replies, Logger, container.QuickBuildAll <IMissingHandler>(),
                                           this);

            Workers = new WorkerQueue(Logger, Pipeline, settings);

            Router = new MessageRouter(Serialization, channels, subscriptions, handlers, Logger, Lookup, settings);

            // TODO -- ZOMG this is horrible, and I admit it.
            if (Factory is NulloDurableMessagingFactory f)
            {
                f.ScheduledJobs = ScheduledJobs;
            }
        }
        public override void SetUp()
        {
            _envelopes.Clear();
            _nodeLockers.Clear();

            _workers = new RecordingWorkerQueue();

            _host = Host.CreateDefaultBuilder()
                    .UseJasper(_ =>
            {
                _.ServiceName = Guid.NewGuid().ToString();

                _.Endpoints.As <TransportCollection>().Add(new StubTransport());

                _.Extensions.UseMarten(Servers.PostgresConnectionString);

                _.Services.AddSingleton <IWorkerQueue>(_workers);


                _.Advanced.FirstNodeReassignmentExecution = 30.Minutes();
                _.Advanced.ScheduledJobFirstExecution     = 30.Minutes();
                _.Advanced.FirstNodeReassignmentExecution = 30.Minutes();
                _.Advanced.NodeReassignmentPollingTime    = 30.Minutes();
            })
                    .Start();


            _admin = _host.Services.GetService <IEnvelopePersistence>().Admin;
            _admin.RebuildSchemaObjects();

            _settings    = _host.Services.GetService <PostgresqlSettings>();
            _serializers = _host.Services.GetService <MessagingSerializationGraph>();

            theStore = _host.Services.GetService <IDocumentStore>();
            theStore.Advanced.Clean.DeleteAllDocuments();

            _currentNodeId = _host.Services.GetService <AdvancedSettings>().UniqueNodeId;

            _owners["This Node"] = _currentNodeId;
        }
Beispiel #15
0
        public override void SetUp()
        {
            _envelopes.Clear();
            _nodeLockers.Clear();

            _workers        = new RecordingWorkerQueue();
            _schedulerAgent = new RecordingSchedulingAgent();

            _runtime = JasperRuntime.For(_ =>
            {
                _.MartenConnectionStringIs(Servers.PostgresConnectionString);
                _.Services.AddSingleton <ITransport, StubTransport>();

                _.Services.AddSingleton <IWorkerQueue>(_workers);
                _.Services.AddSingleton <ISchedulingAgent>(_schedulerAgent);

                _.Include <MartenBackedPersistence>();

                _.Settings.Alter <MessagingSettings>(x =>
                {
                    x.Retries.FirstNodeReassignmentExecution = 30.Minutes();
                    x.ScheduledJobs.FirstExecution           = 30.Minutes();
                    x.Retries.FirstNodeReassignmentExecution = 30.Minutes();
                    x.Retries.NodeReassignmentPollingTime    = 30.Minutes();
                });
            });

            _runtime.Get <MartenBackedDurableMessagingFactory>().ClearAllStoredMessages();

            _marker      = _runtime.Get <EnvelopeTables>();
            _serializers = _runtime.Get <MessagingSerializationGraph>();

            theStore = _runtime.Get <IDocumentStore>();
            theStore.Advanced.Clean.DeleteAllDocuments();

            _currentNodeId = _runtime.Get <MessagingSettings>().UniqueNodeId;

            _owners["This Node"] = _currentNodeId;
        }
Beispiel #16
0
        public override void SetUp()
        {
            _envelopes.Clear();
            _nodeLockers.Clear();

            _workers        = new RecordingWorkerQueue();
            _schedulerAgent = new RecordingSchedulingAgent();


            _host = Host.CreateDefaultBuilder()
                    .UseJasper(_ =>
            {
                _.Extensions.PersistMessagesWithSqlServer(Servers.SqlServerConnectionString);

                _.Endpoints.As <TransportCollection>().Add(new StubTransport());

                _.Services.AddSingleton <IWorkerQueue>(_workers);
                _.Services.AddSingleton <IDurabilityAgent>(_schedulerAgent);
                _.Advanced.FirstNodeReassignmentExecution = 30.Minutes();
                _.Advanced.ScheduledJobFirstExecution     = 30.Minutes();
                _.Advanced.FirstNodeReassignmentExecution = 30.Minutes();
                _.Advanced.NodeReassignmentPollingTime    = 30.Minutes();
            })
                    .Start();


            _host.Services.GetService <IEnvelopePersistence>().Admin.ClearAllPersistedEnvelopes();

            _serializers = _host.Services.GetService <MessagingSerializationGraph>();

            _host.RebuildMessageStorage();

            _currentNodeId = _host.Services.GetService <AdvancedSettings>().UniqueNodeId;

            _owners["This Node"] = _currentNodeId;
        }
Beispiel #17
0
        public override void SetUp()
        {
            _envelopes.Clear();
            _nodeLockers.Clear();

            _workers        = new RecordingWorkerQueue();
            _schedulerAgent = new RecordingSchedulingAgent();

            _runtime = JasperRuntime.For(_ =>
            {
                _.Settings.PersistMessagesWithSqlServer(Servers.SqlServerConnectionString);
                _.Services.AddSingleton <ITransport, StubTransport>();

                _.Services.AddSingleton <IWorkerQueue>(_workers);
                _.Services.AddSingleton <ISchedulingAgent>(_schedulerAgent);


                _.Settings.Alter <JasperOptions>(x =>
                {
                    x.Retries.FirstNodeReassignmentExecution = 30.Minutes();
                    x.ScheduledJobs.FirstExecution           = 30.Minutes();
                    x.Retries.FirstNodeReassignmentExecution = 30.Minutes();
                    x.Retries.NodeReassignmentPollingTime    = 30.Minutes();
                });
            });

            _runtime.Get <SqlServerBackedDurableMessagingFactory>().ClearAllStoredMessages();

            _serializers = _runtime.Get <MessagingSerializationGraph>();

            _runtime.RebuildMessageStorage();

            _currentNodeId = _runtime.Get <JasperOptions>().UniqueNodeId;

            _owners["This Node"] = _currentNodeId;
        }
Beispiel #18
0
 public AcknowledgementSender(IEnvelopeRouter router, MessagingSerializationGraph serialization)
 {
     _router        = router;
     _serialization = serialization;
 }
Beispiel #19
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 #20
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);
            }
        }