public MartenBackedListenerContext() { theStore = DocumentStore.For(_ => { _.Connection(Servers.PostgresConnectionString); _.PLV8Enabled = false; }); theSettings = new AdvancedSettings(null); EnvelopeStorageAdmin.RebuildSchemaObjects(); var persistence = new PostgresqlEnvelopePersistence( new PostgresqlSettings { ConnectionString = Servers.PostgresConnectionString }, theSettings); thePipeline = Substitute.For <IHandlerPipeline>(); theWorkerQueue = new DurableWorkerQueue(new LocalQueueSettings("temp"), thePipeline, theSettings, persistence, TransportLogger.Empty()); var agent = Substitute.For <IListener>(); theWorkerQueue.StartListening(agent); }
public SqlServerCallbackTests() { // SAMPLE: SqlServer-RebuildMessageStorage theRuntime = JasperRuntime.For(_ => { _.Settings.PersistMessagesWithSqlServer(Servers.SqlServerConnectionString); }); theRuntime.RebuildMessageStorage(); // ENDSAMPLE theEnvelope = ObjectMother.Envelope(); theEnvelope.Status = TransportConstants.Incoming; thePersistor = theRuntime.Get <SqlServerEnvelopePersistor>(); thePersistor.StoreIncoming(theEnvelope).Wait(3.Seconds()); var logger = TransportLogger.Empty(); theRetries = new EnvelopeRetries(thePersistor, logger, new JasperOptions()); theCallback = new DurableCallback(theEnvelope, Substitute.For <IWorkerQueue>(), thePersistor, theRetries, logger); }
public async Task ping_sad_path_with_tcp() { var sender = new BatchedSender("tcp://localhost:3322".ToUri(), new SocketSenderProtocol(), CancellationToken.None, TransportLogger.Empty()); await Should.ThrowAsync <InvalidOperationException>(async() => { await sender.Ping(CancellationToken.None); }); }
public MartenBackedListenerContext() { theStore = DocumentStore.For(_ => { _.Connection(Servers.PostgresConnectionString); _.PLV8Enabled = false; _.Storage.Add <PostgresqlEnvelopeStorage>(); }); theStore.Advanced.Clean.CompletelyRemoveAll(); theStore.Schema.ApplyAllConfiguredChangesToDatabase(); theWorkerQueue = Substitute.For <IWorkerQueue>(); theSettings = new MessagingSettings(); var tables = new EnvelopeTables(theSettings, new StoreOptions()); var retries = new EnvelopeRetries(new MartenEnvelopePersistor(theStore, tables), TransportLogger.Empty(), theSettings); theListener = new DurableListener( Substitute.For <IListeningAgent>(), theWorkerQueue, TransportLogger.Empty(), theSettings, retries, new MartenEnvelopePersistor(theStore, tables)); }
public async Task ping_happy_path_with_http_protocol() { var sender = new BatchedSender("http://localhost:5005/messages".ToUri(), new HttpSenderProtocol(new MessagingSettings()), CancellationToken.None, TransportLogger.Empty()); var runtime = await JasperRuntime.ForAsync <JasperRegistry>(_ => { _.Transports.Http.EnableListening(true); _.Hosting.UseUrls("http://localhost:5005"); _.Hosting.UseKestrel(); _.Services.AddLogging(); _.Hosting.Configure(app => { app.UseJasper(); app.Run(c => c.Response.WriteAsync("Hello")); }); }); try { await sender.Ping(); } finally { await runtime.Shutdown(); } }
public run_scheduled_job_specs() { var logger = TransportLogger.Empty(); var envelopeTables = new EnvelopeTables(theSettings, new StoreOptions()); var retries = new EnvelopeRetries(new MartenEnvelopePersistor(theStore, envelopeTables), logger, theSettings); theScheduledJob = new RunScheduledJobs(theWorkerQueue, theStore, envelopeTables, logger, retries); }
public async Task ping_sad_path_with_http_protocol() { var sender = new BatchedSender("http://localhost:5005/messages".ToUri(), new HttpSenderProtocol(new MessagingSettings()), CancellationToken.None, TransportLogger.Empty()); await Exception <HttpRequestException> .ShouldBeThrownByAsync(async() => { await sender.Ping(); }); }
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, TransportLogger.Empty()); sender.Start(new StubSenderCallback()); await sender.Ping(); } }
public async Task ping_happy_path_with_tcp() { using (var runtime = JasperHost.For(_ => { _.Endpoints.ListenAtPort(2222); })) { var sender = new BatchedSender("tcp://localhost:2222".ToUri(), new SocketSenderProtocol(), CancellationToken.None, TransportLogger.Empty()); sender.RegisterCallback(new StubSenderCallback()); await sender.Ping(CancellationToken.None); } }
public BatchedSenderTests() { theSender = new BatchedSender(TransportConstants.RepliesUri, theProtocol, theCancellation.Token, TransportLogger.Empty()); theSender.Start(theSenderCallback); theBatch = new OutgoingMessageBatch(theSender.Destination, new[] { Envelope.ForPing(TransportConstants.LoopbackUri), Envelope.ForPing(TransportConstants.LoopbackUri), Envelope.ForPing(TransportConstants.LoopbackUri), Envelope.ForPing(TransportConstants.LoopbackUri), Envelope.ForPing(TransportConstants.LoopbackUri), Envelope.ForPing(TransportConstants.LoopbackUri) }); theBatch.Messages.Each(x => x.Destination = theBatch.Destination); }
public override void SetUp() { _latched = false; _unlatched = false; _pingFails = false; theSettings = new AdvancedSettings(null); _endpoint = Substitute.For <Endpoint>(); theRetryAgent = new LightweightSendingAgent(TransportLogger.Empty(), MessageLogger.Empty(), this, theSettings, _endpoint); for (var i = 0; i < batches.Length; i++) { batches[i] = batchForEnvelopes(15); } _enqueued.Clear(); }
public async Task receive_when_it_is_latched() { var stream = new MemoryStream(); var agent = new SocketListener(TransportLogger.Empty(), IPAddress.Any, 5500, CancellationToken.None); agent.Status = ListeningStatus.TooBusy; var callback = Substitute.For <IListeningWorkerQueue>(); await agent.HandleStream(callback, stream); stream.Position = 0; var bytes = stream.ReadAllBytes(); bytes.ShouldBe(WireProtocol.ProcessingFailureBuffer); callback.DidNotReceive().Received(); }
public MartenCallbackTests() { theRuntime = JasperRuntime.For(_ => { _.MartenConnectionStringIs(Servers.PostgresConnectionString); _.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 MessagingSettings(), new StoreOptions()); using (var session = theStore.OpenSession()) { session.StoreIncoming(marker, theEnvelope); session.SaveChanges(); } var logger = TransportLogger.Empty(); theRetries = new EnvelopeRetries(new MartenEnvelopePersistor(theStore, marker), logger, new MessagingSettings()); var persistor = new MartenEnvelopePersistor(theStore, marker); theCallback = new DurableCallback(theEnvelope, Substitute.For <IWorkerQueue>(), persistor, theRetries, logger); }
public ListeningAgent(IListeningWorkerQueue callback, IPAddress ipaddr, int port, string protocol, CancellationToken cancellationToken) { Port = port; _callback = callback; _cancellationToken = cancellationToken; _listener = new TcpListener(new IPEndPoint(ipaddr, port)); _listener.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _socketHandling = new ActionBlock <Socket>(async s => { using (var stream = new NetworkStream(s, true)) { await WireProtocol.Receive(TransportLogger.Empty(), stream, _callback, _uri); } }, new ExecutionDataflowBlockOptions { CancellationToken = _cancellationToken }); _uri = $"{protocol}://{ipaddr}:{port}/".ToUri(); }
public SqlServerBackedListenerContext() { new SqlServerEnvelopeStorageAdmin(new SqlServerSettings { ConnectionString = Servers.SqlServerConnectionString }).RecreateAll(); theWorkerQueue = Substitute.For <IWorkerQueue>(); theSettings = new JasperOptions(); mssqlSettings = new SqlServerSettings { ConnectionString = Servers.SqlServerConnectionString }; ThePersistence = new SqlServerEnvelopePersistence(mssqlSettings, new JasperOptions()); theListener = new DurableListener( Substitute.For <IListeningAgent>(), theWorkerQueue, TransportLogger.Empty(), theSettings, ThePersistence); }
public SqlServerBackedListenerContext() { new SchemaLoader(ConnectionSource.ConnectionString).RecreateAll(); theWorkerQueue = Substitute.For <IWorkerQueue>(); theSettings = new MessagingSettings(); mssqlSettings = new SqlServerSettings { ConnectionString = ConnectionSource.ConnectionString }; thePersistor = new SqlServerEnvelopePersistor(mssqlSettings); retries = new EnvelopeRetries(thePersistor, TransportLogger.Empty(), theSettings); theListener = new DurableListener( Substitute.For <IListeningAgent>(), theWorkerQueue, TransportLogger.Empty(), theSettings, retries, thePersistor); }
public MartenBackedListenerContext() { theStore = DocumentStore.For(_ => { _.Connection(Servers.PostgresConnectionString); _.PLV8Enabled = false; }); theWorkerQueue = Substitute.For <IWorkerQueue>(); theOptions = new JasperOptions(); EnvelopeStorageAdmin.RebuildSchemaObjects(); theListener = new DurableListener( Substitute.For <IListeningAgent>(), theWorkerQueue, TransportLogger.Empty(), theOptions, new PostgresqlEnvelopePersistence(new PostgresqlSettings { ConnectionString = Servers.PostgresConnectionString }, theOptions)); }
public run_scheduled_job_specs() { var logger = TransportLogger.Empty(); theScheduledJob = new RunScheduledJobs(theWorkerQueue, mssqlSettings, logger, retries, theSettings); }
public SqlServerBackedListenerContext() { new SqlServerEnvelopeStorageAdmin(new SqlServerSettings { ConnectionString = Servers.SqlServerConnectionString }).RecreateAll(); theSettings = new AdvancedSettings(null); mssqlSettings = new SqlServerSettings { ConnectionString = Servers.SqlServerConnectionString }; ThePersistence = new SqlServerEnvelopePersistence(mssqlSettings, theSettings); thePipeline = Substitute.For <IHandlerPipeline>(); theWorkerQueue = new DurableWorkerQueue(new LocalQueueSettings("temp"), thePipeline, theSettings, ThePersistence, TransportLogger.Empty()); }
public void status_is_accepting_by_default() { new SocketListener(TransportLogger.Empty(), IPAddress.Any, 5500, CancellationToken.None) .Status.ShouldBe(ListeningStatus.Accepting); }