|
| 1 | +// This source code is dual-licensed under the Apache License, version |
| 2 | +// 2.0, and the Mozilla Public License, version 1.1. |
| 3 | +// |
| 4 | +// The APL v2.0: |
| 5 | +// |
| 6 | +//--------------------------------------------------------------------------- |
| 7 | +// Copyright (c) 2007-2016 Pivotal Software, Inc. |
| 8 | +// |
| 9 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | +// you may not use this file except in compliance with the License. |
| 11 | +// You may obtain a copy of the License at |
| 12 | +// |
| 13 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | +// |
| 15 | +// Unless required by applicable law or agreed to in writing, software |
| 16 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | +// See the License for the specific language governing permissions and |
| 19 | +// limitations under the License. |
| 20 | +//--------------------------------------------------------------------------- |
| 21 | +// |
| 22 | +// The MPL v1.1: |
| 23 | +// |
| 24 | +//--------------------------------------------------------------------------- |
| 25 | +// The contents of this file are subject to the Mozilla Public License |
| 26 | +// Version 1.1 (the "License"); you may not use this file except in |
| 27 | +// compliance with the License. You may obtain a copy of the License |
| 28 | +// at http://www.mozilla.org/MPL/ |
| 29 | +// |
| 30 | +// Software distributed under the License is distributed on an "AS IS" |
| 31 | +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See |
| 32 | +// the License for the specific language governing rights and |
| 33 | +// limitations under the License. |
| 34 | +// |
| 35 | +// The Original Code is RabbitMQ. |
| 36 | +// |
| 37 | +// The Initial Developer of the Original Code is Pivotal Software, Inc. |
| 38 | +// Copyright (c) 2007-2016 Pivotal Software, Inc. All rights reserved. |
| 39 | +//--------------------------------------------------------------------------- |
| 40 | + |
| 41 | +using NUnit.Framework; |
| 42 | + |
| 43 | +using System; |
| 44 | +using System.Text; |
| 45 | +using System.Linq; |
| 46 | +using System.Threading; |
| 47 | + |
| 48 | +using RabbitMQ.Client; |
| 49 | + |
| 50 | +namespace RabbitMQ.Client.Unit { |
| 51 | + [TestFixture] |
| 52 | + public class TestConcurrentAccessWithSharedConnection : IntegrationFixture { |
| 53 | + |
| 54 | + [Test] |
| 55 | + public void TestConcurrentChannelOpenWithPublishing() |
| 56 | + { |
| 57 | + var n = 32; |
| 58 | + var latch = new CountdownEvent(n); |
| 59 | + foreach (var i in Enumerable.Range(0, n)) |
| 60 | + { |
| 61 | + var t = new Thread(() => { |
| 62 | + // publishing on a shared channel is not supported |
| 63 | + // and would missing the point of this test anyway |
| 64 | + var ch = Conn.CreateModel(); |
| 65 | + ch.ConfirmSelect(); |
| 66 | + foreach (var j in Enumerable.Range(0, 10000)) |
| 67 | + { |
| 68 | + var body = Encoding.ASCII.GetBytes(string.Empty); |
| 69 | + ch.BasicPublish(exchange: "", routingKey: "_______", basicProperties: ch.CreateBasicProperties(), body: body); |
| 70 | + } |
| 71 | + ch.WaitForConfirms(TimeSpan.FromSeconds(40)); |
| 72 | + latch.Signal(); |
| 73 | + }); |
| 74 | + t.Start(); |
| 75 | + } |
| 76 | + |
| 77 | + Assert.IsTrue(latch.Wait(TimeSpan.FromSeconds(90))); |
| 78 | + } |
| 79 | + } |
| 80 | +} |
0 commit comments