Example #1
0
        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();
            }
        }
Example #2
0
        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); });
        }
Example #3
0
        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(); });
        }
Example #4
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();
            });
        }
Example #5
0
        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);
            }
        }
Example #6
0
        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();
            }
        }
Example #7
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();
            }
        }
Example #8
0
        public BatchedSenderTests()
        {
            theSender = new BatchedSender(TransportConstants.RepliesUri, theProtocol, theCancellation.Token, TransportLogger.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);
        }
Example #9
0
        public ISendingAgent BuildSendingAgent(Uri uri, CancellationToken cancellation)
        {
            var batchedSender = new BatchedSender(uri, new HttpSenderProtocol(_settings, _httpSettings), cancellation, _logger);

            ISendingAgent agent;

            if (uri.IsDurable())
            {
                agent = _persistence.BuildSendingAgent(uri, batchedSender, cancellation);
            }
            else
            {
                agent = new LightweightSendingAgent(uri, batchedSender, _logger, _settings);
            }

            agent.DefaultReplyUri = LocalReplyUri;
            agent.Start();

            return(agent);
        }