public void can_start_two_instances_for_IIS_stop_and_start() { //This shows that the port doesn't have an exclusive lock, and that lmdb itself can have multiple instances var path = _testDirectory.CreateNewDirectoryForTest(); var store = new LmdbMessageStore(path); var queueConfiguration = new QueueConfiguration(); queueConfiguration.LogWith(new RecordingLogger()); queueConfiguration.AutomaticEndpoint(); queueConfiguration.StoreMessagesWith(store); var queue = queueConfiguration.BuildQueue(); var queue2 = queueConfiguration.BuildQueue(); using (queue) using (queue2) { queue.CreateQueue("test"); queue.Start(); queue2.CreateQueue("test"); queue2.Start(); using (queue.Receive("test").Subscribe(x => { })) using (queue2.Receive("test").Subscribe(x => { })) { } } }
public LightningQueue(int port, bool persistent, LightningQueueSettings settings) { Port = port; Persistent = persistent; var queueConfiguration = new QueueConfiguration() .ReceiveMessagesAt(new IPEndPoint(IPAddress.Any, port)) .ScheduleQueueWith(TaskPoolScheduler.Default); // TODO -- bring through whatever the Jasper logging abstraction ends up being here. //.LogWith(new FubuLoggingAdapter(_logger)); if (persistent) { queueConfiguration.StoreWithLmdb(settings.QueuePath + "." + port, new EnvironmentConfiguration { MaxDatabases = settings.MaxDatabases, MapSize = settings.MapSize }); } else { queueConfiguration.UseNoStorage(); } _queue = queueConfiguration.BuildQueue(); }
public static Queue NewQueue(string path = null, string queueName = "test", ILogger logger = null, IScheduler scheduler = null, IMessageStore store = null, bool secureTransport = false) { store ??= new LmdbMessageStore(path); var queueConfiguration = new QueueConfiguration(); queueConfiguration.LogWith(logger ?? new RecordingLogger()); queueConfiguration.AutomaticEndpoint(); queueConfiguration.ScheduleQueueWith(scheduler ?? TaskPoolScheduler.Default); queueConfiguration.StoreMessagesWith(store); if (secureTransport) { var certificate = CreateCertificate(); queueConfiguration.SecureTransportWith(async(_, receiving) => { var sslStream = new SslStream(receiving, false); try { await sslStream.AuthenticateAsServerAsync(certificate, false, checkCertificateRevocation: false, enabledSslProtocols: SslProtocols.Tls12); } catch (Exception ex) { Assert.True(false, "Error occurred from receiving encryption {ex}"); } return(sslStream); }, async(uri, sending) => { bool ValidateServerCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); //we only care that the transport is encrypted } var sslStream = new SslStream(sending, true, ValidateServerCertificate, null); try { await sslStream.AuthenticateAsClientAsync(uri.Host); } catch (Exception ex) { Assert.True(false, $"Authenticating as a client failed for {ex}"); } return(sslStream); }); } var queue = queueConfiguration.BuildQueue(); queue.CreateQueue(queueName); queue.Start(); return(queue); }
private Queue CreateQueue(int port, bool persist, int mapSize = 1024*1024*100, int maxDatabases = 5) { var queueConfiguration = new QueueConfiguration() .ReceiveMessagesAt(new IPEndPoint(IPAddress.Any, port)) .ScheduleQueueWith(TaskPoolScheduler.Default) .LogWith(new FubuLoggingAdapter(_logger)); if (persist) { queueConfiguration.StoreWithLmdb(QueuePath + "." + port, new EnvironmentConfiguration { MaxDatabases = maxDatabases, MapSize = mapSize }); } else { queueConfiguration.UseNoStorage(); } var queue = queueConfiguration.BuildQueue(); _queueManagers.Fill(port, queue); return queue; }
private Queue CreateQueue(int port, bool persist, int mapSize = 1024 *1024 *100, int maxDatabases = 5) { var queueConfiguration = new QueueConfiguration() .ReceiveMessagesAt(new IPEndPoint(IPAddress.Any, port)) .ScheduleQueueWith(TaskPoolScheduler.Default) .LogWith(new FubuLoggingAdapter(_logger)); if (persist) { queueConfiguration.StoreWithLmdb(QueuePath + "." + port, new EnvironmentConfiguration { MaxDatabases = maxDatabases, MapSize = mapSize }); } else { queueConfiguration.UseNoStorage(); } var queue = queueConfiguration.BuildQueue(); _queueManagers.Fill(port, queue); return(queue); }