Exemple #1
0
 public BatchedSender(Uri destination, ISenderProtocol protocol, CancellationToken cancellation, CompositeTransportLogger logger)
 {
     Destination   = destination;
     _protocol     = protocol;
     _cancellation = cancellation;
     _logger       = logger;
 }
Exemple #2
0
 public HttpTransport(BusSettings settings, JasperRuntime runtime, IPersistence persistence, CompositeTransportLogger logger)
 {
     _settings    = settings;
     _runtime     = runtime;
     _persistence = persistence;
     _logger      = logger;
 }
Exemple #3
0
 public TcpTransport(IPersistence persistence, CompositeTransportLogger logger, IWorkerQueue workerQueue, BusSettings settings)
 {
     _persistence = persistence;
     _logger      = logger;
     _workerQueue = workerQueue;
     _settings    = settings;
 }
        public MartenBackedListenerContext()
        {
            theStore = DocumentStore.For(_ =>
            {
                _.Connection(ConnectionSource.ConnectionString);
                _.PLV8Enabled = false;
                _.Storage.Add <PostgresqlEnvelopeStorage>();
            });

            theStore.Advanced.Clean.CompletelyRemoveAll();

            theStore.Schema.ApplyAllConfiguredChangesToDatabase();

            theWorkerQueue = Substitute.For <IWorkerQueue>();

            theSettings = new BusSettings();

            var tables = new EnvelopeTables(theSettings, new StoreOptions());

            var retries = new MartenRetries(theStore, tables, CompositeTransportLogger.Empty(), theSettings);


            theListener = new MartenBackedListener(
                Substitute.For <IListeningAgent>(),
                theWorkerQueue,
                theStore,
                CompositeTransportLogger.Empty(), theSettings, tables, retries);
        }
        public run_scheduled_job_specs()
        {
            var logger         = CompositeTransportLogger.Empty();
            var envelopeTables = new EnvelopeTables(theSettings, new StoreOptions());
            var retries        = new MartenRetries(theStore, envelopeTables, logger, theSettings);

            theScheduledJob = new RunScheduledJobs(theWorkerQueue, theStore, envelopeTables, logger, retries);
        }
        protected SendingAgent(Uri destination, ISender sender, CompositeTransportLogger logger, BusSettings settings, RetryAgent retries)
        {
            _sender     = sender;
            _logger     = logger;
            Destination = destination;

            _retries = retries;
        }
        public MartenBackedRetryAgent(IDocumentStore store, ISender sender, RetrySettings settings, EnvelopeTables marker, CompositeTransportLogger logger) : base(sender, settings)
        {
            _store  = store;
            _marker = marker;
            _logger = logger;

            _deleteIncoming = $"delete from {_marker.Incoming} where id = ANY(:idlist)";
        }
Exemple #8
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);
        }
 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;
 }
Exemple #10
0
 public MartenBackedSendingAgent(Uri destination, IDocumentStore store, ISender sender, CancellationToken cancellation, CompositeTransportLogger logger, BusSettings settings, EnvelopeTables marker, MartenRetries retries)
     : base(destination, sender, logger, settings, new MartenBackedRetryAgent(store, sender, settings.Retries, marker, logger))
 {
     _cancellation = cancellation;
     _logger       = logger;
     _store        = store;
     _settings     = settings;
     _marker       = marker;
     _retries      = retries;
 }
 public MartenBackedListener(IListeningAgent agent, IWorkerQueue queues, IDocumentStore store, CompositeTransportLogger logger, BusSettings settings, EnvelopeTables marker, MartenRetries retries)
 {
     _agent    = agent;
     _queues   = queues;
     _store    = store;
     _logger   = logger;
     _settings = settings;
     _marker   = marker;
     _retries  = retries;
 }
Exemple #12
0
        public async Task ping_sad_path_with_tcp()
        {
            var sender = new BatchedSender("tcp://localhost:2222".ToUri(), new SocketSenderProtocol(),
                                           CancellationToken.None, CompositeTransportLogger.Empty());

            await Jasper.Testing.Exception <InvalidOperationException> .ShouldBeThrownByAsync(async() =>
            {
                await sender.Ping();
            });
        }
Exemple #13
0
        public RunScheduledJobs(IWorkerQueue workers, IDocumentStore store, EnvelopeTables marker, CompositeTransportLogger logger, MartenRetries retries)
        {
            _workers = workers;
            _store   = store;
            _marker  = marker;
            _logger  = logger;
            _retries = retries;

            _findReadyToExecuteJobs = $"select body from {marker.Incoming} where status = '{TransportConstants.Scheduled}' and execution_time <= :time";
            _markOwnedIncomingSql   = $"update {marker.Incoming} set owner_id = :owner, status = '{TransportConstants.Incoming}' where id = ANY(:idlist)";
        }
Exemple #14
0
        public RecoverIncomingMessages(IWorkerQueue workers, BusSettings settings, EnvelopeTables marker,
                                       ISchedulingAgent schedulingAgent, CompositeTransportLogger logger)
        {
            _workers         = workers;
            _settings        = settings;
            _marker          = marker;
            _schedulingAgent = schedulingAgent;
            _logger          = logger;

            _findAtLargeEnvelopesSql = $"select body from {marker.Incoming} where owner_id = {TransportConstants.AnyNode} and status = '{TransportConstants.Incoming}' limit {settings.Retries.RecoveryBatchSize}";
        }
Exemple #15
0
        public RecoverOutgoingMessages(IChannelGraph channels, BusSettings settings, EnvelopeTables marker, ISchedulingAgent schedulingAgent, CompositeTransportLogger logger)
        {
            _channels        = channels;
            _settings        = settings;
            _marker          = marker;
            _schedulingAgent = schedulingAgent;
            _logger          = logger;

            _findUniqueDestinations   = $"select distinct destination from {_marker.Outgoing}";
            _findOutgoingEnvelopesSql = $"select body from {marker.Outgoing} where owner_id = {TransportConstants.AnyNode} and destination = :destination limit {settings.Retries.RecoveryBatchSize}";
            _deleteOutgoingSql        = $"delete from {marker.Outgoing} where owner_id = :owner and destination = :destination";
        }
        public async Task ping_happy_path_with_tcp()
        {
            using (var runtime = JasperRuntime.For(_ =>
            {
                _.Transports.LightweightListenerAt(2222);
            }))
            {
                var sender = new BatchedSender("tcp://localhost:2222".ToUri(), new SocketSenderProtocol(),
                                               CancellationToken.None, CompositeTransportLogger.Empty());

                await sender.Ping();
            }
        }
Exemple #17
0
        public MartenRetries(IDocumentStore store, EnvelopeTables tables, CompositeTransportLogger logger, BusSettings settings)
        {
            _store    = store;
            _tables   = tables;
            _logger   = logger;
            _settings = settings;

            _deleteIncoming         = new ActionBlock <Envelope[]>(deleteIncoming);
            _deleteIncomingBatching = new BatchingBlock <Envelope>(250.Milliseconds(), _deleteIncoming, settings.Cancellation);

            _deleteOutgoing         = new ActionBlock <Envelope[]>(deleteOutgoing);
            _deleteOutgoingBatching = new BatchingBlock <Envelope>(250.Milliseconds(), _deleteOutgoing, settings.Cancellation);

            _logErrorReport         = new ActionBlock <ErrorReport[]>(logErrorReports);
            _logErrorReportBatching = new BatchingBlock <ErrorReport>(250.Milliseconds(), _logErrorReport, settings.Cancellation);

            _scheduleIncoming         = new ActionBlock <Envelope[]>(scheduleIncoming);
            _scheduleIncomingBatching = new BatchingBlock <Envelope>(250.Milliseconds(), _scheduleIncoming, settings.Cancellation);
        }
Exemple #18
0
        public SchedulingAgent(IChannelGraph channels, IWorkerQueue workers, IDocumentStore store, BusSettings settings, CompositeTransportLogger logger, StoreOptions storeOptions, MartenRetries retries)
        {
            _channels     = channels;
            _workers      = workers;
            _store        = store;
            _settings     = settings;
            _logger       = logger;
            _storeOptions = storeOptions;

            _worker = new ActionBlock <IMessagingAction>(processAction, new ExecutionDataflowBlockOptions
            {
                MaxDegreeOfParallelism = 1
            });

            var marker = new EnvelopeTables(_settings, _storeOptions);

            _scheduledJobs    = new RunScheduledJobs(_workers, _store, marker, logger, retries);
            _incomingMessages = new RecoverIncomingMessages(_workers, _settings, marker, this, _logger);
            _outgoingMessages = new RecoverOutgoingMessages(_channels, _settings, marker, this, _logger);

            _nodeReassignment = new ReassignFromDormantNodes(marker, settings);
        }
        public MartenCallbackTests()
        {
            theRuntime = JasperRuntime.For(_ =>
            {
                _.MartenConnectionStringIs(ConnectionSource.ConnectionString);

                _.ConfigureMarten(x =>
                {
                    x.Storage.Add <PostgresqlEnvelopeStorage>();
                    x.PLV8Enabled = false;
                });
            });

            theStore = theRuntime.Get <IDocumentStore>();

            theStore.Advanced.Clean.CompletelyRemoveAll();
            theStore.Schema.ApplyAllConfiguredChangesToDatabase();

            theEnvelope        = ObjectMother.Envelope();
            theEnvelope.Status = TransportConstants.Incoming;

            var marker = new EnvelopeTables(new BusSettings(), new StoreOptions());

            using (var session = theStore.OpenSession())
            {
                session.StoreIncoming(marker, theEnvelope);
                session.SaveChanges();
            }


            var logger = CompositeTransportLogger.Empty();

            theRetries = new MartenRetries(theStore, marker, logger, new BusSettings());

            theCallback = new MartenCallback(theEnvelope, Substitute.For <IWorkerQueue>(), theStore, marker, theRetries, logger);
        }
Exemple #20
0
        public async Task ping_sad_path_with_http_protocol()
        {
            var sender = new BatchedSender("http://localhost:5005/messages".ToUri(), new HttpSenderProtocol(new BusSettings()), CancellationToken.None, CompositeTransportLogger.Empty());



            await Jasper.Testing.Exception <HttpRequestException> .ShouldBeThrownByAsync(async() =>
            {
                await sender.Ping();
            });
        }
Exemple #21
0
 public LightweightListener(IWorkerQueue workerQueue, CompositeTransportLogger logger, IListeningAgent agent)
 {
     _workerQueue = workerQueue;
     _logger      = logger;
     _agent       = agent;
 }
Exemple #22
0
 public TcpTransport(IPersistence persistence, CompositeTransportLogger logger, BusSettings settings)
 {
     _persistence = persistence;
     _logger      = logger;
     _settings    = settings;
 }
Exemple #23
0
 public NulloPersistence(CompositeTransportLogger logger, BusSettings settings, IWorkerQueue workers)
 {
     _logger   = logger;
     _settings = settings;
     _workers  = workers;
 }
Exemple #24
0
 public NulloPersistence(CompositeTransportLogger logger, BusSettings settings)
 {
     _logger        = logger;
     _settings      = settings;
     _scheduledJobs = new InMemoryScheduledJobProcessor();
 }
 public LightweightSendingAgent(Uri destination, ISender sender, CompositeTransportLogger logger, BusSettings settings)
     : base(destination, sender, logger, settings, new LightweightRetryAgent(sender, settings.Retries))
 {
 }
Exemple #26
0
        public async Task ping_happy_path_with_http_protocol()
        {
            var sender = new BatchedSender("http://localhost:5005/messages".ToUri(), new HttpSenderProtocol(new BusSettings()), CancellationToken.None, CompositeTransportLogger.Empty());


            using (var runtime = JasperRuntime.For(_ =>
            {
                _.Transports.Http.EnableListening(true);
                _.Http.UseUrls("http://localhost:5005").UseKestrel();
            }))
            {
                await sender.Ping();
            }
        }
Exemple #27
0
        public BatchedSenderTests()
        {
            theSender = new BatchedSender(TransportConstants.RepliesUri, theProtocol, theCancellation.Token, CompositeTransportLogger.Empty());
            theSender.Start(theSenderCallback);

            theBatch = new OutgoingMessageBatch(theSender.Destination, new Envelope[]
            {
                Envelope.ForPing(),
                Envelope.ForPing(),
                Envelope.ForPing(),
                Envelope.ForPing(),
                Envelope.ForPing(),
                Envelope.ForPing()
            });

            theBatch.Messages.Each(x => x.Destination = theBatch.Destination);
        }