* Upgrade to RabbitMQ.Client 1.8.
svn path=/trunk/mcs/; revision=159465
+2010-06-23 Michael Barker <mike@middlesoft.co.uk>
+
+ * RabbitMQMessageQueue.cs: Modified to support RabbitMQ 1.8
+ * RabbitMQMessageEnumerator.cs: Modified to support RabbitMQ 1.8
+
2009-07-14 Michael Barker <mike@middlesoft.co.uk>
* RabbitMQMessageQueue.cs: Refactored, removed dead code and renamed methods.
get {
if (cn == null) {
ConnectionFactory cf = new ConnectionFactory ();
- cn = cf.CreateConnection (qRef.Host);
+ cf.Address = qRef.Host;
+ cn = cf.CreateConnection ();
}
if (model == null) {
public static void Delete (QueueReference qRef)
{
- ConnectionFactory cf = new ConnectionFactory ();
-
- using (IConnection cn = cf.CreateConnection (qRef.Host)) {
+ using (IConnection cn = CreateConnection (qRef)) {
using (IModel model = cn.CreateModel ()) {
model.QueueDelete (qRef.Queue, false, false, false);
}
if (msg.BodyStream == null)
throw new ArgumentException ("Message is not serialized properly");
- ConnectionFactory cf = new ConnectionFactory ();
-
try {
- using (IConnection cn = cf.CreateConnection (QRef.Host)) {
+ using (IConnection cn = CreateConnection (QRef)) {
SetDeliveryInfo (msg, GetVersion (cn), null);
using (IModel ch = cn.CreateModel ()) {
Send (ch, msg);
else if (host != QRef.Host)
throw new MonoMessagingException ("Transactions can not span multiple hosts");
- if (cn == null) {
- ConnectionFactory cf = new ConnectionFactory ();
- cn = cf.CreateConnection (host);
- }
+ if (cn == null)
+ cn = CreateConnection (QRef);
if (model == null) {
model = cn.CreateModel ();
public void Purge ()
{
- ConnectionFactory cf = new ConnectionFactory ();
-
- using (IConnection cn = cf.CreateConnection (QRef.Host)) {
+ using (IConnection cn = CreateConnection (QRef)) {
using (IModel model = cn.CreateModel ()) {
model.QueuePurge (QRef.Queue, false);
}
public IMessage Peek ()
{
- ConnectionFactory cf = new ConnectionFactory ();
-
- using (IConnection cn = cf.CreateConnection (QRef.Host)) {
+ using (IConnection cn = CreateConnection (QRef)) {
using (IModel ch = cn.CreateModel ()) {
return Receive (ch, -1, false);
}
private IMessage Run (RecieveDelegate r)
{
- ConnectionFactory cf = new ConnectionFactory ();
- using (IConnection cn = cf.CreateConnection (QRef.Host)) {
+ using (IConnection cn = CreateConnection (QRef)) {
using (IModel model = cn.CreateModel ()) {
return r (this, model);
}
else if (host != q.QRef.Host)
throw new MonoMessagingException ("Transactions can not span multiple hosts");
- if (cn == null) {
- ConnectionFactory cf = new ConnectionFactory ();
- cn = cf.CreateConnection (host);
- }
+ if (cn == null)
+ cn = CreateConnection (q.QRef);
if (model == null) {
model = cn.CreateModel ();
private RabbitMQMessageQueueTransaction GetTx ()
{
return (RabbitMQMessageQueueTransaction) provider.CreateMessageQueueTransaction ();
+ }
+
+ private static IConnection CreateConnection (QueueReference qRef)
+ {
+ ConnectionFactory cf = new ConnectionFactory ();
+ cf.Address = qRef.Host;
+ return cf.CreateConnection ();
}
}
}
+2010-06-23 Michael Barker <mike@middlesoft.co.uk>
+
+ * Updated to version 1.8 of the RabbitMQ libraries
+
2009-12-23 Jo Shields <directhex@apebox.org>
* docs/specs/Makefile: Use compiled Mono, not system Mono (fixes
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
public void EmitPrelude() {
EmitLine("// Autogenerated code. Do not edit.");
EmitLine("");
+ EmitLine("// This source code is dual-licensed under the Apache License, version");
+ EmitLine("// 2.0, and the Mozilla Public License, version 1.1.");
+ EmitLine("//");
+ EmitLine("// The APL v2.0:");
+ EmitLine("//");
+ EmitLine("//---------------------------------------------------------------------------");
+ EmitLine("// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial");
+ EmitLine("// Technologies LLC., and Rabbit Technologies Ltd.");
+ EmitLine("//");
+ EmitLine("// Licensed under the Apache License, Version 2.0 (the \"License\");");
+ EmitLine("// you may not use this file except in compliance with the License.");
+ EmitLine("// You may obtain a copy of the License at");
+ EmitLine("//");
+ EmitLine("// http://www.apache.org/licenses/LICENSE-2.0");
+ EmitLine("//");
+ EmitLine("// Unless required by applicable law or agreed to in writing, software");
+ EmitLine("// distributed under the License is distributed on an \"AS IS\" BASIS,");
+ EmitLine("// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
+ EmitLine("// See the License for the specific language governing permissions and");
+ EmitLine("// limitations under the License.");
+ EmitLine("//---------------------------------------------------------------------------");
+ EmitLine("//");
+ EmitLine("// The MPL v1.1:");
+ EmitLine("//");
+ EmitLine("//---------------------------------------------------------------------------");
+ EmitLine("// The contents of this file are subject to the Mozilla Public License");
+ EmitLine("// Version 1.1 (the \"License\"); you may not use this file except in");
+ EmitLine("// compliance with the License. You may obtain a copy of the License at");
+ EmitLine("// http://www.rabbitmq.com/mpl.html");
+ EmitLine("//");
+ EmitLine("// Software distributed under the License is distributed on an \"AS IS\"");
+ EmitLine("// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the");
+ EmitLine("// License for the specific language governing rights and limitations");
+ EmitLine("// under the License.");
+ EmitLine("//");
+ EmitLine("// The Original Code is The RabbitMQ .NET Client.");
+ EmitLine("//");
+ EmitLine("// The Initial Developers of the Original Code are LShift Ltd,");
+ EmitLine("// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.");
+ EmitLine("//");
+ EmitLine("// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,");
+ EmitLine("// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd");
+ EmitLine("// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial");
+ EmitLine("// Technologies LLC, and Rabbit Technologies Ltd.");
+ EmitLine("//");
+ EmitLine("// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift");
+ EmitLine("// Ltd. Portions created by Cohesive Financial Technologies LLC are");
+ EmitLine("// Copyright (C) 2007-2010 Cohesive Financial Technologies");
+ EmitLine("// LLC. Portions created by Rabbit Technologies Ltd are Copyright");
+ EmitLine("// (C) 2007-2010 Rabbit Technologies Ltd.");
+ EmitLine("//");
+ EmitLine("// All Rights Reserved.");
+ EmitLine("//");
+ EmitLine("// Contributor(s): ______________________________________.");
+ EmitLine("//");
+ EmitLine("//---------------------------------------------------------------------------");
+ EmitLine("");
EmitLine("using RabbitMQ.Client;");
EmitLine("using RabbitMQ.Client.Exceptions;");
EmitLine("");
EmitLine(" public "+maybeOverride+"void Clear"+MangleClass(f.Name)+"() { m_"+MangleMethod(f.Name)+"_present = false; }");
}
}
+
+ EmitLine("");
+ foreach (AmqpField f in c.m_Fields)
+ {
+ if (!IsBoolean(f))
+ EmitLine(" public " + maybeOverride + "bool Is" + MangleClass(f.Name) + "Present() { return m_" + MangleMethod(f.Name) + "_present; }");
+ }
+
EmitLine("");
EmitLine(" public "+MangleClass(c.Name)+"Properties() {}");
EmitLine(" public override int ProtocolClassId { get { return "+c.Index+"; } }");
./AssemblyInfo.cs
../../../../build/common/Consts.cs
-./messagepatterns/SimpleRpcServer.cs
-./messagepatterns/SimpleRpcClient.cs
-./messagepatterns/Subscription.cs
-./exceptions/AlreadyClosedException.cs
+./events/EventingBasicConsumer.cs
+./events/BasicDeliverEventHandler.cs
+./events/CallbackExceptionEventHandler.cs
+./events/BasicReturnEventHandler.cs
+./events/ModelShutdownEventHandler.cs
+./events/ConsumerEventHandler.cs
+./events/CallbackExceptionEventArgs.cs
+./events/BasicReturnEventArgs.cs
+./events/ConsumerEventArgs.cs
+./events/BasicDeliverEventArgs.cs
+./events/ConnectionShutdownEventHandler.cs
+./events/ConsumerShutdownEventHandler.cs
+./exceptions/ChannelAllocationException.cs
+./exceptions/UnexpectedMethodException.cs
./exceptions/PacketNotRecognizedException.cs
-./exceptions/UnsupportedMethodFieldException.cs
+./exceptions/PossibleAuthenticationFailureException.cs
./exceptions/WireFormattingException.cs
-./exceptions/BrokerUnreachableException.cs
+./exceptions/UnsupportedMethodFieldException.cs
./exceptions/ProtocolVersionMismatchException.cs
-./exceptions/ChannelAllocationException.cs
+./exceptions/AlreadyClosedException.cs
+./exceptions/BrokerUnreachableException.cs
./exceptions/UnsupportedMethodException.cs
./exceptions/OperationInterruptedException.cs
-./exceptions/UnexpectedMethodException.cs
-./content/PrimitiveParser.cs
-./content/MapMessageBuilder.cs
-./content/IMessageBuilder.cs
-./content/IBytesMessageBuilder.cs
-./content/BytesMessageBuilder.cs
-./content/IMessageReader.cs
-./content/BytesMessageReader.cs
-./content/BasicMessageReader.cs
-./content/IStreamMessageBuilder.cs
-./content/IBytesMessageReader.cs
-./content/BytesWireFormatting.cs
-./content/StreamWireFormatting.cs
-./content/StreamMessageBuilder.cs
-./content/StreamMessageReader.cs
-./content/IStreamMessageReader.cs
-./content/BasicMessageBuilder.cs
-./content/MapMessageReader.cs
-./content/IMapMessageReader.cs
-./content/IMapMessageBuilder.cs
-./content/MapWireFormatting.cs
-./impl/SyntaxError.cs
-./impl/MainSession.cs
-./impl/ConnectionStartDetails.cs
-./impl/RpcContinuationQueue.cs
-./impl/MethodArgumentReader.cs
-./impl/ShutdownContinuation.cs
-./impl/ProtocolException.cs
-./impl/ChannelErrorException.cs
-./impl/BodyTooLongException.cs
-./impl/CommandAssembler.cs
-./impl/SimpleBlockingRpcContinuation.cs
-./impl/ConnectionBase.cs
-./impl/FileProperties.cs
-./impl/MethodArgumentWriter.cs
-./impl/ModelBase.cs
-./impl/StreamProperties.cs
-./impl/v0_8qpid/Connection.cs
-./impl/v0_8qpid/ProtocolBase.cs
+./messagepatterns/SimpleRpcServer.cs
+./messagepatterns/Subscription.cs
+./messagepatterns/SimpleRpcClient.cs
./impl/SessionBase.cs
-./impl/IFrameHandler.cs
-./impl/SessionManager.cs
-./impl/Command.cs
-./impl/UnknownClassOrMethodException.cs
-./impl/v0_8/Connection.cs
-./impl/v0_8/ProtocolBase.cs
./impl/UnexpectedFrameException.cs
+./impl/ContentHeaderPropertyReader.cs
+./impl/ConnectionStartDetails.cs
+./impl/SessionManager.cs
./impl/AbstractProtocolBase.cs
-./impl/SocketFrameHandler_0_9.cs
-./impl/WireFormatting.cs
-./impl/RedirectException.cs
-./impl/ISession.cs
+./impl/MalformedFrameException.cs
+./impl/ModelBase.cs
+./impl/RpcContinuationQueue.cs
+./impl/ConnectionBase.cs
./impl/Session.cs
+./impl/ContentHeaderBase.cs
+./impl/WireFormatting.cs
+./impl/MethodArgumentReader.cs
+./impl/SimpleBlockingRpcContinuation.cs
./impl/QuiescingSession.cs
+./impl/ContentHeaderPropertyWriter.cs
+./impl/ChannelErrorException.cs
+./impl/SoftProtocolException.cs
./impl/v0_9/Connection.cs
./impl/v0_9/ProtocolBase.cs
-./impl/BasicProperties.cs
-./impl/Frame.cs
-./impl/SoftProtocolException.cs
-./impl/MalformedFrameException.cs
+./impl/MethodArgumentWriter.cs
+./impl/ShutdownContinuation.cs
+./impl/SyntaxError.cs
./impl/HardProtocolException.cs
+./impl/v0_8/Connection.cs
+./impl/v0_8/ProtocolBase.cs
+./impl/UnknownClassOrMethodException.cs
+./impl/MainSession.cs
+./impl/FileProperties.cs
+./impl/BasicProperties.cs
+./impl/ISession.cs
+./impl/Command.cs
+./impl/v0_8qpid/Connection.cs
+./impl/v0_8qpid/ProtocolBase.cs
./impl/IRpcContinuation.cs
-./impl/ContentHeaderBase.cs
-./impl/ContentHeaderPropertyWriter.cs
+./impl/RedirectException.cs
+./impl/SocketFrameHandler_0_9.cs
+./impl/ProtocolException.cs
+./impl/Frame.cs
./impl/MethodBase.cs
-./impl/ContentHeaderPropertyReader.cs
-./events/CallbackExceptionEventArgs.cs
-./events/ConsumerEventHandler.cs
-./events/BasicDeliverEventHandler.cs
-./events/BasicReturnEventHandler.cs
-./events/ConsumerEventArgs.cs
-./events/BasicReturnEventArgs.cs
-./events/ModelShutdownEventHandler.cs
-./events/ConnectionShutdownEventHandler.cs
-./events/EventingBasicConsumer.cs
-./events/ConsumerShutdownEventHandler.cs
-./events/BasicDeliverEventArgs.cs
-./events/CallbackExceptionEventHandler.cs
-./api/Protocols.cs
-./api/PublicationAddress.cs
-./api/ShutdownReportEntry.cs
+./impl/IFrameHandler.cs
+./impl/CommandAssembler.cs
+./impl/StreamProperties.cs
+./content/BasicMessageReader.cs
+./content/BytesWireFormatting.cs
+./content/IMessageBuilder.cs
+./content/StreamMessageBuilder.cs
+./content/IMessageReader.cs
+./content/IMapMessageReader.cs
+./content/IBytesMessageBuilder.cs
+./content/BasicMessageBuilder.cs
+./content/StreamMessageReader.cs
+./content/MapMessageReader.cs
+./content/StreamWireFormatting.cs
+./content/IMapMessageBuilder.cs
+./content/PrimitiveParser.cs
+./content/MapMessageBuilder.cs
+./content/MapWireFormatting.cs
+./content/IBytesMessageReader.cs
+./content/IStreamMessageReader.cs
+./content/IStreamMessageBuilder.cs
+./content/BytesMessageBuilder.cs
+./content/BytesMessageReader.cs
+./api/SslHelper.cs
+./api/IConnection.cs
+./api/IModel.cs
+./api/AmqpTimestamp.cs
./api/IFileProperties.cs
+./api/PublicationAddress.cs
./api/QueueingBasicConsumer.cs
-./api/AmqpTimestamp.cs
-./api/IMethod.cs
-./api/ConnectionParameters.cs
+./api/AmqpVersion.cs
+./api/IProtocol.cs
+./api/IBasicConsumer.cs
+./api/ExchangeType.cs
./api/AmqpTcpEndpoint.cs
+./api/IBasicProperties.cs
./api/IContentHeader.cs
+./api/IMethod.cs
+./api/ShutdownReportEntry.cs
+./api/ShutdownEventArgs.cs
+./api/IStreamProperties.cs
+./api/Protocols.cs
+./api/ShutdownInitiator.cs
./api/DefaultBasicConsumer.cs
-./api/ExchangeType.cs
-./api/IProtocol.cs
+./api/SslOption.cs
./api/BinaryTableValue.cs
-./api/AmqpVersion.cs
-./api/IBasicConsumer.cs
-./api/IConnection.cs
-./api/ShutdownInitiator.cs
-./api/IModel.cs
./api/ConnectionFactory.cs
-./api/IStreamProperties.cs
-./api/IBasicProperties.cs
-./api/ShutdownEventArgs.cs
../util/DebugUtil.cs
../util/NetworkBinaryReader.cs
../util/NetworkBinaryWriter.cs
../util/Either.cs
../util/SharedQueue.cs
../util/XmlUtil.cs
+../util/IntAllocator.cs
../../docs/specs/autogenerated-api-0-9.cs
../../docs/specs/autogenerated-api-0-8.cs
../../docs/specs/autogenerated-api-qpid-0-8.cs
+++ /dev/null
-// This source code is dual-licensed under the Apache License, version
-// 2.0, and the Mozilla Public License, version 1.1.
-//
-// The APL v2.0:
-//
-//---------------------------------------------------------------------------
-// Copyright (C) 2007, 2008 LShift Ltd., Cohesive Financial
-// Technologies LLC., and Rabbit Technologies Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//---------------------------------------------------------------------------
-//
-// The MPL v1.1:
-//
-//---------------------------------------------------------------------------
-// The contents of this file are subject to the Mozilla Public License
-// Version 1.1 (the "License"); you may not use this file except in
-// compliance with the License. You may obtain a copy of the License at
-// http://www.rabbitmq.com/mpl.html
-//
-// Software distributed under the License is distributed on an "AS IS"
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-// License for the specific language governing rights and limitations
-// under the License.
-//
-// The Original Code is The RabbitMQ .NET Client.
-//
-// The Initial Developers of the Original Code are LShift Ltd.,
-// Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.
-//
-// Portions created by LShift Ltd., Cohesive Financial Technologies
-// LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007, 2008
-// LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit
-// Technologies Ltd.;
-//
-// All Rights Reserved.
-//
-// Contributor(s): ______________________________________.
-//
-//---------------------------------------------------------------------------
-namespace RabbitMQ.Client
-{
-
- ///<summary>Used within ConnectionParameters to control
- ///suppression of Access.Request calls.</summary>
- public enum AccessRequestConfig
- {
-
- ///<summary>Uses the default for the protocol variant
- ///selected.</summary>
- UseDefault,
-
- ///<summary>Overrides the protocol's default, causing
- ///Access.Request methods to be sent to the peer when
- ///IModel.AccessRequest is called.</summary>
- Enable,
-
- ///<summary>Overrides the protocol's default, preventing
- ///Access.Request methods from being sent to the
- ///peer.</summary>
- Suppress
- };
-}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
///<summary>Represents a TCP-addressable AMQP peer, including the
///protocol variant to use, and a host name and port
///number.</summary>
+ ///<para>
+ /// Some of the constructors take, as a convenience, a System.Uri
+ /// instance representing an AMQP server address. The use of Uri
+ /// here is not standardised - Uri is simply a convenient
+ /// container for internet-address-like components. In particular,
+ /// the Uri "Scheme" property is ignored: only the "Host" and
+ /// "Port" properties are extracted.
+ ///</para>
public class AmqpTcpEndpoint
{
+ ///<summary>Indicates that the default port for the protocol should be used</summary>
+ public const int UseDefaultPort = -1;
+
private IProtocol m_protocol;
///<summary>Retrieve or set the IProtocol of this AmqpTcpEndpoint.</summary>
public IProtocol Protocol
///port number for the IProtocol to be used.</summary>
public int Port
{
- get { return (m_port == -1) ? m_protocol.DefaultPort : m_port; }
+ get { return (m_port == UseDefaultPort) ? m_protocol.DefaultPort : m_port; }
set { m_port = value; }
}
+
+ private SslOption m_ssl;
+ ///<summary>Retrieve the SSL options for this AmqpTcpEndpoint.
+ ///If not set, null is returned</summary>
+ public SslOption Ssl
+ {
+ get { return m_ssl; }
+ set { m_ssl = value; }
+ }
+
+ ///<summary>Construct an AmqpTcpEndpoint with the given
+ ///IProtocol, hostname, port number and ssl option. If the port
+ ///number is -1, the default port number for the IProtocol
+ ///will be used.</summary>
+ public AmqpTcpEndpoint(IProtocol protocol, string hostName, int portOrMinusOne, SslOption ssl)
+ {
+ m_protocol = protocol;
+ m_hostName = hostName;
+ m_port = portOrMinusOne;
+ m_ssl = ssl;
+ }
+
///<summary>Construct an AmqpTcpEndpoint with the given
///IProtocol, hostname, and port number. If the port number is
///-1, the default port number for the IProtocol will be
///used.</summary>
- public AmqpTcpEndpoint(IProtocol protocolVariant, string hostname, int portOrMinusOne)
+ public AmqpTcpEndpoint(IProtocol protocol, string hostName, int portOrMinusOne) :
+ this(protocol, hostName, portOrMinusOne, new SslOption())
+ {
+ }
+
+ ///<summary>Construct an AmqpTcpEndpoint with the given
+ ///IProtocol and hostname, using the default port for the
+ ///IProtocol.</summary>
+ public AmqpTcpEndpoint(IProtocol protocol, string hostName) :
+ this(protocol, hostName, -1)
+ {
+ }
+
+ ///<summary>Construct an AmqpTcpEndpoint with the given
+ ///IProtocol, "localhost" as the hostname, and using the
+ ///default port for the IProtocol.</summary>
+ public AmqpTcpEndpoint(IProtocol protocol) :
+ this(protocol, "localhost", -1)
+ {
+ }
+
+ ///<summary>Construct an AmqpTcpEndpoint with the given
+ ///hostname and port number, using the IProtocol from
+ ///Protocols.FromEnvironment(). If the port number is
+ ///-1, the default port number for the IProtocol will be
+ ///used.</summary>
+ public AmqpTcpEndpoint(string hostName, int portOrMinusOne) :
+ this(Protocols.FromEnvironment(), hostName, portOrMinusOne)
+ {
+ }
+
+ ///<summary>Construct an AmqpTcpEndpoint with the given
+ ///hostname, using the IProtocol from
+ ///Protocols.FromEnvironment(), and the default port number of
+ ///that IProtocol.</summary>
+ public AmqpTcpEndpoint(string hostName) :
+ this(Protocols.FromEnvironment(), hostName)
+ {
+ }
+
+ ///<summary>Construct an AmqpTcpEndpoint with a hostname of
+ ///"localhost", using the IProtocol from
+ ///Protocols.FromEnvironment(), and the default port number of
+ ///that IProtocol.</summary>
+ public AmqpTcpEndpoint() :
+ this(Protocols.FromEnvironment())
+ {
+ }
+
+ ///<summary>Construct an AmqpTcpEndpoint with the given
+ ///IProtocol, Uri and ssl options.</summary>
+ ///<remarks>
+ /// Please see the class overview documentation for
+ /// information about the Uri format in use.
+ ///</remarks>
+ public AmqpTcpEndpoint(IProtocol protocol, Uri uri, SslOption ssl) :
+ this(protocol, uri.Host, uri.Port, ssl)
+ {
+ }
+
+ ///<summary>Construct an AmqpTcpEndpoint with the given
+ ///IProtocol and Uri.</summary>
+ ///<remarks>
+ /// Please see the class overview documentation for
+ /// information about the Uri format in use.
+ ///</remarks>
+ public AmqpTcpEndpoint(IProtocol protocol, Uri uri) :
+ this(protocol, uri.Host, uri.Port)
+ {
+ }
+
+ ///<summary>Construct an AmqpTcpEndpoint with the given
+ ///Uri, using the IProtocol from
+ ///Protocols.FromEnvironment().</summary>
+ ///<remarks>
+ /// Please see the class overview documentation for
+ /// information about the Uri format in use.
+ ///</remarks>
+ public AmqpTcpEndpoint(Uri uri) :
+ this(Protocols.FromEnvironment(), uri)
{
- m_protocol = protocolVariant;
- m_hostName = hostname;
- m_port = portOrMinusOne;
}
///<summary>Returns a URI-like string of the form
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
///<example><code>
/// ConnectionFactory factory = new ConnectionFactory();
/// //
- /// // The next three lines are optional:
- /// factory.Parameters.UserName = ConnectionParameters.DefaultUser;
- /// factory.Parameters.Password = ConnectionParameters.DefaultPass;
- /// factory.Parameters.VirtualHost = ConnectionParameters.DefaultVHost;
+ /// // The next six lines are optional:
+ /// factory.UserName = ConnectionFactory.DefaultUser;
+ /// factory.Password = ConnectionFactory.DefaultPass;
+ /// factory.VirtualHost = ConnectionFactory.DefaultVHost;
+ /// factory.Protocol = Protocols.FromEnvironment();
+ /// factory.HostName = hostName;
+ /// factory.PortNumber = AmqpTcpEndpoint.UseDefaultPort;
/// //
- /// IProtocol protocol = Protocols.DefaultProtocol;
- /// IConnection conn = factory.CreateConnection(protocol, hostName, portNumber);
+ /// IConnection conn = factory.CreateConnection();
/// //
/// IModel ch = conn.CreateModel();
/// //
/// // ... use ch's IModel methods ...
/// //
- /// ch.Close(200, "Closing the channel");
- /// conn.Close(200, "Closing the connection");
+ /// ch.Close(Constants.ReplySuccess, "Closing the channel");
+ /// conn.Close(Constants.ReplySuccess, "Closing the connection");
///</code></example>
///<para>
/// Please see also the API overview and tutorial in the User Guide.
///</remarks>
public class ConnectionFactory
{
- private ConnectionParameters m_parameters = new ConnectionParameters();
- ///<summary>Retrieve the parameters this factory uses to
- ///construct IConnection instances.</summary>
- public ConnectionParameters Parameters
- {
- get
- {
- return m_parameters;
- }
+ /// <summary>Default user name (value: "guest")</summary>
+ public const string DefaultUser = "guest"; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
+
+ /// <summary>Default password (value: "guest")</summary>
+ public const string DefaultPass = "guest"; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
+
+ /// <summary>Default virtual host (value: "/")</summary>
+ public const string DefaultVHost = "/"; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
+
+ /// <summary> Default value for the desired maximum channel
+ /// number, with zero meaning unlimited (value: 0)</summary>
+ public const ushort DefaultChannelMax = 0; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
+
+ /// <summary>Default value for the desired maximum frame size,
+ /// with zero meaning unlimited (value: 0)</summary>
+ public const uint DefaultFrameMax = 0; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
+
+ /// <summary>Default value for desired heartbeat interval, in
+ /// seconds, with zero meaning none (value: 0)</summary>
+ public const ushort DefaultHeartbeat = 0; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
+
+ /// <summary>Username to use when authenticating to the server</summary>
+ public string UserName = DefaultUser;
+
+ /// <summary>Password to use when authenticating to the server</summary>
+ public string Password = DefaultPass;
+
+ /// <summary>Virtual host to access during this connection</summary>
+ public string VirtualHost = DefaultVHost;
+
+ /// <summary>Maximum channel number to ask for</summary>
+ public ushort RequestedChannelMax = DefaultChannelMax;
+
+ /// <summary>Frame-max parameter to ask for (in bytes)</summary>
+ public uint RequestedFrameMax = DefaultFrameMax;
+
+ /// <summary>Heartbeat setting to request (in seconds)</summary>
+ public ushort RequestedHeartbeat = DefaultHeartbeat;
+
+ /// <summary>Dictionary of client properties to be sent to the
+ /// server</summary>
+ public IDictionary ClientProperties = ConnectionBase.DefaultClientProperties();
+
+ ///<summary>Ssl options setting</summary>
+ public SslOption Ssl = new SslOption();
+
+ ///<summary>The host to connect to</summary>
+ public String HostName = "localhost";
+
+ ///<summary>The port to connect on. AmqpTcpEndpoint.UseDefaultPort indicates the
+ /// default for the protocol should be used.</summary>
+ public int Port = AmqpTcpEndpoint.UseDefaultPort;
+
+ ///<summary>The AMQP protocol to be used</summary>
+ public IProtocol Protocol = Protocols.FromEnvironment();
+
+ public AmqpTcpEndpoint Endpoint
+ {
+ get
+ {
+ return new AmqpTcpEndpoint(Protocol, HostName, Port);
+ }
+ set
+ {
+ Protocol = value.Protocol;
+ Port = value.Port;
+ HostName = value.HostName;
+ }
}
- ///<summary>Constructs a ConnectionFactory with default values
- ///for Parameters.</summary>
- public ConnectionFactory()
+ public String Address
{
+ get
+ {
+ String result = HostName;
+ if(Port != AmqpTcpEndpoint.UseDefaultPort)
+ {
+ result += (":" + Port);
+ }
+ return result;
+ }
+ set
+ {
+ Endpoint = AmqpTcpEndpoint.Parse(Protocol, value);
+ }
}
+ ///<summary>Construct a fresh instance, with all fields set to
+ ///their respective defaults.</summary>
+ public ConnectionFactory() { }
+
protected virtual IConnection FollowRedirectChain
(int maxRedirects,
IDictionary connectionAttempts,
// and fully open a successful connection,
// in which case we're done, and the
// connection should be returned.
- return p.CreateConnection(m_parameters, insist, fh);
+ return p.CreateConnection(this, insist, fh);
} catch (RedirectException re) {
if (insist) {
// We've been redirected, but we insisted that
///endpoint in the list provided. Up to a maximum of
///maxRedirects broker-originated redirects are permitted for
///each endpoint tried.</summary>
- public virtual IConnection CreateConnection(int maxRedirects,
- params AmqpTcpEndpoint[] endpoints)
+ public virtual IConnection CreateConnection(int maxRedirects)
{
IDictionary connectionAttempts = new Hashtable();
IDictionary connectionErrors = new Hashtable();
IConnection conn = CreateConnection(maxRedirects,
connectionAttempts,
connectionErrors,
- endpoints);
+ new AmqpTcpEndpoint[]{Endpoint});
if (conn != null) {
return conn;
}
throw new BrokerUnreachableException(connectionAttempts, connectionErrors);
}
- ///<summary>Create a connection to the first available
- ///endpoint in the list provided. No broker-originated
- ///redirects are permitted.</summary>
- public virtual IConnection CreateConnection(params AmqpTcpEndpoint[] endpoints)
- {
- return CreateConnection(0, endpoints);
- }
-
- ///<summary>Create a connection to the endpoint specified.</summary>
- ///<exception cref="ArgumentException"/>
- public IConnection CreateConnection(IProtocol version,
- string hostName,
- int portNumber)
- {
- return CreateConnection(new AmqpTcpEndpoint[] {
- new AmqpTcpEndpoint(version, hostName, portNumber)
- });
- }
-
- ///<summary>Create a connection to the endpoint specified. The
- ///port used is the default for the protocol.</summary>
- ///<exception cref="ArgumentException"/>
- public IConnection CreateConnection(IProtocol version, string hostName)
+ ///<summary>Create a connection to the specified endpoint
+ ///No broker-originated redirects are permitted.</summary>
+ public virtual IConnection CreateConnection()
{
- return CreateConnection(version, hostName, -1);
- }
-
- ///<summary>Create a connection to the endpoint specified.</summary>
- ///<remarks>
- /// Please see the class overview documentation for
- /// information about the Uri format in use.
- ///</remarks>
- ///<exception cref="ArgumentException"/>
- public IConnection CreateConnection(IProtocol version, Uri uri)
- {
- return CreateConnection(version, uri.Host, uri.Port);
- }
-
- ///<summary>Create a connection to the endpoint specified,
- ///with the IProtocol from
- ///Protocols.FromEnvironment().</summary>
- ///<remarks>
- /// Please see the class overview documentation for
- /// information about the Uri format in use.
- ///</remarks>
- public IConnection CreateConnection(Uri uri)
- {
- return CreateConnection(Protocols.FromEnvironment(), uri.Host, uri.Port);
- }
-
- ///<summary>Create a connection to the host (and optional
- ///port) specified, with the IProtocol from
- ///Protocols.FromEnvironment(). The format of the address
- ///string is the same as that accepted by
- ///AmqpTcpEndpoint.Parse().</summary>
- public IConnection CreateConnection(string address) {
- return CreateConnection(AmqpTcpEndpoint.Parse(Protocols.FromEnvironment(), address));
+ return CreateConnection(0);
}
}
}
+++ /dev/null
-// This source code is dual-licensed under the Apache License, version
-// 2.0, and the Mozilla Public License, version 1.1.
-//
-// The APL v2.0:
-//
-//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
-// Technologies LLC., and Rabbit Technologies Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//---------------------------------------------------------------------------
-//
-// The MPL v1.1:
-//
-//---------------------------------------------------------------------------
-// The contents of this file are subject to the Mozilla Public License
-// Version 1.1 (the "License"); you may not use this file except in
-// compliance with the License. You may obtain a copy of the License at
-// http://www.rabbitmq.com/mpl.html
-//
-// Software distributed under the License is distributed on an "AS IS"
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-// License for the specific language governing rights and limitations
-// under the License.
-//
-// The Original Code is The RabbitMQ .NET Client.
-//
-// The Initial Developers of the Original Code are LShift Ltd,
-// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
-//
-// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
-// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
-// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
-// Technologies LLC, and Rabbit Technologies Ltd.
-//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
-// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
-// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
-//
-// All Rights Reserved.
-//
-// Contributor(s): ______________________________________.
-//
-//---------------------------------------------------------------------------
-using System;
-
-namespace RabbitMQ.Client
-{
- ///<summary>Supplies values to ConnectionFactory for use in
- ///constructing IConnection instances.</summary>
- public class ConnectionParameters : ICloneable
- {
- /// <summary>Default user name (value: "guest")</summary>
- public const string DefaultUser = "guest"; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
-
- /// <summary>Default password (value: "guest")</summary>
- public const string DefaultPass = "guest"; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
-
- /// <summary>Default virtual host (value: "/")</summary>
- public const string DefaultVHost = "/"; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
-
- /// <summary> Default value for the desired maximum channel
- /// number, with zero meaning unlimited (value: 0)</summary>
- public const ushort DefaultChannelMax = 0; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
-
- /// <summary>Default value for the desired maximum frame size,
- /// with zero meaning unlimited (value: 0)</summary>
- public const uint DefaultFrameMax = 0; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
-
- /// <summary>Default value for desired heartbeat interval, in
- /// seconds, with zero meaning none (value: 3)</summary>
- public const ushort DefaultHeartbeat = 3; // PLEASE KEEP THIS MATCHING THE DOC ABOVE
-
- private string m_userName = DefaultUser;
- private string m_password = DefaultPass;
- private string m_virtualHost = DefaultVHost;
- private ushort m_requestedChannelMax = DefaultChannelMax;
- private uint m_requestedFrameMax = DefaultFrameMax;
- private ushort m_requestedHeartbeat = DefaultHeartbeat;
-
- ///<summary>Construct a fresh instance, with all fields set to
- ///their respective defaults.</summary>
- public ConnectionParameters() { }
-
- /// <summary>Username to use when authenticating to the server</summary>
- public string UserName
- {
- get { return m_userName; }
- set { m_userName = value; }
- }
-
- /// <summary>Password to use when authenticating to the server</summary>
- public string Password
- {
- get { return m_password; }
- set { m_password = value; }
- }
-
- /// <summary>Virtual host to access during this connection</summary>
- public string VirtualHost
- {
- get { return m_virtualHost; }
- set { m_virtualHost = value; }
- }
-
- /// <summary>Maximum channel number to ask for</summary>
- public ushort RequestedChannelMax
- {
- get { return m_requestedChannelMax; }
- set { m_requestedChannelMax = value; }
- }
-
- /// <summary>Frame-max parameter to ask for (in bytes)</summary>
- public uint RequestedFrameMax
- {
- get { return m_requestedFrameMax; }
- set { m_requestedFrameMax = value; }
- }
-
- /// <summary>Heartbeat setting to request (in seconds)</summary>
- public ushort RequestedHeartbeat
- {
- get { return m_requestedHeartbeat; }
- set { m_requestedHeartbeat = value; }
- }
-
- ///<summary>Implement ICloneable.Clone by delegating to our type-safe variant.</summary>
- object ICloneable.Clone()
- {
- return ((ConnectionParameters)this).Clone();
- }
-
- ///<summary>Returns a fresh ConnectionParameters with the same values as this.</summary>
- public ConnectionParameters Clone()
- {
- ConnectionParameters n = this.MemberwiseClone() as ConnectionParameters;
- return n;
- }
- }
-}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
///<summary> Clear the ClusterId property. </summary>
void ClearClusterId();
+ ///<summary> Returns true iff the ContentType property is present. </summary>
+ bool IsContentTypePresent();
+
+ ///<summary> Returns true iff the ContentEncoding property is present. </summary>
+ bool IsContentEncodingPresent();
+
+ ///<summary> Returns true iff the Headers property is present. </summary>
+ bool IsHeadersPresent();
+
+ ///<summary> Returns true iff the DeliveryMode property is present. </summary>
+ bool IsDeliveryModePresent();
+
+ ///<summary> Returns true iff the Priority property is present. </summary>
+ bool IsPriorityPresent();
+
+ ///<summary> Returns true iff the CorrelationId property is present. </summary>
+ bool IsCorrelationIdPresent();
+
+ ///<summary> Returns true iff the ReplyTo property is present. </summary>
+ bool IsReplyToPresent();
+
+ ///<summary> Returns true iff the Expiration property is present. </summary>
+ bool IsExpirationPresent();
+
+ ///<summary> Returns true iff the MessageId property is present. </summary>
+ bool IsMessageIdPresent();
+
+ ///<summary> Returns true iff the Timestamp property is present. </summary>
+ bool IsTimestampPresent();
+
+ ///<summary> Returns true iff the Type property is present. </summary>
+ bool IsTypePresent();
+
+ ///<summary> Returns true iff the UserId property is present. </summary>
+ bool IsUserIdPresent();
+
+ ///<summary> Returns true iff the AppId property is present. </summary>
+ bool IsAppIdPresent();
+
+ ///<summary> Returns true iff the ClusterId property is present. </summary>
+ bool IsClusterIdPresent();
+
///<summary>Convenience property; parses ReplyTo property
///using PublicationAddress.Parse, and serializes it using
///PublicationAddress.ToString. Returns null if ReplyTo property
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
///communicate with its peer.</summary>
IProtocol Protocol { get; }
- ///<summary>The connection parameters used during construction
- ///of this connection.</summary>
- ConnectionParameters Parameters { get; }
-
///<summary>The maximum channel number this connection
///supports (0 if unlimited). Usable channel numbers
///range from 1 to this number, inclusive.</summary>
///(0 for disabled), in seconds.</summary>
ushort Heartbeat { get; }
+ ///<summary>A copy of the client properties that has been sent to the
+ ///server.</summary>
+ IDictionary ClientProperties { get; }
+
+ ///<summary>A dictionary of the server properties sent by the server
+ ///while establishing the connection. This typically includes
+ ///the product name and version of the server.</summary>
+ IDictionary ServerProperties { get; }
+
///<summary>Returns the known hosts that came back from the
///broker in the connection.open-ok method at connection
///startup time. Null until the connection is completely open
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// Contributor(s): ______________________________________.
//
//---------------------------------------------------------------------------
+using System;
+
namespace RabbitMQ.Client
{
///<summary>A decoded AMQP content header frame.</summary>
- public interface IContentHeader
+ public interface IContentHeader : ICloneable
{
///<summary>Retrieve the AMQP class ID of this content header.</summary>
int ProtocolClassId { get; }
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
///<summary> Clear the ClusterId property. </summary>
void ClearClusterId();
+
+ ///<summary> Returns true iff the ContentType property is present. </summary>
+ bool IsContentTypePresent();
+
+ ///<summary> Returns true iff the ContentEncoding property is present. </summary>
+ bool IsContentEncodingPresent();
+
+ ///<summary> Returns true iff the Headers property is present. </summary>
+ bool IsHeadersPresent();
+
+ ///<summary> Returns true iff the Priority property is present. </summary>
+ bool IsPriorityPresent();
+
+ ///<summary> Returns true iff the ReplyTo property is present. </summary>
+ bool IsReplyToPresent();
+
+ ///<summary> Returns true iff the MessageId property is present. </summary>
+ bool IsMessageIdPresent();
+
+ ///<summary> Returns true iff the Filename property is present. </summary>
+ bool IsFilenamePresent();
+
+ ///<summary> Returns true iff the Timestamp property is present. </summary>
+ bool IsTimestampPresent();
+
+ ///<summary> Returns true iff the ClusterId property is present. </summary>
+ bool IsClusterIdPresent();
}
}
\ No newline at end of file
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
///<summary>Construct a connection from a given set of
///parameters and a frame handler. The "insist" parameter is
///passed on to the AMQP connection.open method.</summary>
- IConnection CreateConnection(ConnectionParameters parameters,
+ IConnection CreateConnection(ConnectionFactory factory,
bool insist,
IFrameHandler frameHandler);
///<summary>Construct a protocol model atop a given session.</summary>
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
///<summary> Clear the Timestamp property. </summary>
void ClearTimestamp();
+
+ ///<summary> Returns true iff the ContentType property is present. </summary>
+ bool IsContentTypePresent();
+
+ ///<summary> Returns true iff the ContentEncoding property is present. </summary>
+ bool IsContentEncodingPresent();
+
+ ///<summary> Returns true iff the Headers property is present. </summary>
+ bool IsHeadersPresent();
+
+ ///<summary> Returns true iff the Priority property is present. </summary>
+ bool IsPriorityPresent();
+
+ ///<summary> Returns true iff the Timestamp property is present. </summary>
+ bool IsTimestampPresent();
}
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
/// When the consumer is closed, through BasicCancel or through
/// the shutdown of the underlying IModel or IConnection, the
/// SharedQueue's Close() method is called, which causes any
- /// threads blocked on the queue's Enqueue() or Dequeue()
- /// operations to throw EndOfStreamException (see the comment for
+ /// Enqueue() operations, and Dequeue() operations when the queue
+ /// is empty, to throw EndOfStreamException (see the comment for
/// SharedQueue.Close()).
///</para>
///<para>
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
--- /dev/null
+// This source code is dual-licensed under the Apache License, version
+// 2.0, and the Mozilla Public License, version 1.1.
+//
+// The APL v2.0:
+//
+//---------------------------------------------------------------------------
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
+// Technologies LLC., and Rabbit Technologies Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//---------------------------------------------------------------------------
+//
+// The MPL v1.1:
+//
+//---------------------------------------------------------------------------
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.rabbitmq.com/mpl.html
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is The RabbitMQ .NET Client.
+//
+// The Initial Developers of the Original Code are LShift Ltd,
+// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
+//
+// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+// Technologies LLC, and Rabbit Technologies Ltd.
+//
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
+// Ltd. Portions created by Cohesive Financial Technologies LLC are
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
+// LLC. Portions created by Rabbit Technologies Ltd are Copyright
+// (C) 2007-2010 Rabbit Technologies Ltd.
+//
+// All Rights Reserved.
+//
+// Contributor(s): ______________________________________.
+//
+//---------------------------------------------------------------------------
+using System;
+using System.Collections;
+using System.IO;
+using System.Net.Security;
+using System.Security.Authentication;
+using System.Security.Cryptography.X509Certificates;
+using RabbitMQ.Client.Impl;
+
+namespace RabbitMQ.Client
+{
+
+ ///<summary>Represents an SslHelper which does the actual heavy lifting
+ ///to set up an SSL connection, using the config options in an SslOption
+ ///to make things cleaner</summary>
+ public class SslHelper
+ {
+
+ private SslOption m_sslOption;
+
+ private X509Certificate CertificateSelectionCallback(object sender,
+ string targetHost,
+ X509CertificateCollection localCertificates,
+ X509Certificate remoteCertificate,
+ string[] acceptableIssuers)
+ {
+ if (acceptableIssuers != null && acceptableIssuers.Length > 0 &&
+ localCertificates != null && localCertificates.Count > 0)
+ {
+ foreach (X509Certificate certificate in localCertificates)
+ {
+ if (Array.IndexOf(acceptableIssuers, certificate.Issuer) != -1)
+ return certificate;
+ }
+ }
+ if (localCertificates != null && localCertificates.Count > 0)
+ return localCertificates[0];
+
+ return null;
+ }
+
+ private bool CertificateValidationCallback(object sender,
+ X509Certificate certificate,
+ X509Chain chain,
+ SslPolicyErrors sslPolicyErrors)
+ {
+ return (sslPolicyErrors & ~m_sslOption.AcceptablePolicyErrors) == SslPolicyErrors.None;
+ }
+
+ ///<summary>Upgrade a Tcp stream to an Ssl stream using the SSL options
+ ///provided</summary>
+ public static Stream TcpUpgrade(Stream tcpStream, SslOption sslOption)
+ {
+ SslHelper helper = new SslHelper(sslOption);
+ SslStream sslStream = new SslStream(tcpStream, false,
+ new RemoteCertificateValidationCallback(helper.CertificateValidationCallback),
+ new LocalCertificateSelectionCallback(helper.CertificateSelectionCallback));
+
+ sslStream.AuthenticateAsClient(sslOption.ServerName,
+ sslOption.Certs,
+ sslOption.Version,
+ false);
+
+ return sslStream;
+ }
+
+ private SslHelper(SslOption sslOption)
+ {
+ m_sslOption = sslOption;
+ }
+
+ }
+}
--- /dev/null
+// This source code is dual-licensed under the Apache License, version
+// 2.0, and the Mozilla Public License, version 1.1.
+//
+// The APL v2.0:
+//
+//---------------------------------------------------------------------------
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
+// Technologies LLC., and Rabbit Technologies Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//---------------------------------------------------------------------------
+//
+// The MPL v1.1:
+//
+//---------------------------------------------------------------------------
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.rabbitmq.com/mpl.html
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is The RabbitMQ .NET Client.
+//
+// The Initial Developers of the Original Code are LShift Ltd,
+// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
+//
+// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+// Technologies LLC, and Rabbit Technologies Ltd.
+//
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
+// Ltd. Portions created by Cohesive Financial Technologies LLC are
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
+// LLC. Portions created by Rabbit Technologies Ltd are Copyright
+// (C) 2007-2010 Rabbit Technologies Ltd.
+//
+// All Rights Reserved.
+//
+// Contributor(s): ______________________________________.
+//
+//---------------------------------------------------------------------------
+using System;
+using System.Collections;
+using System.Net.Security;
+using System.Security.Authentication;
+using System.Security.Cryptography.X509Certificates;
+using RabbitMQ.Client.Impl;
+
+namespace RabbitMQ.Client
+{
+ ///<summary>Represents a configurable SSL option, used
+ ///in setting up an SSL connection.</summary>
+ public class SslOption
+ {
+
+ private bool m_enabled;
+
+ ///<summary>Flag specifying if Ssl should indeed be
+ ///used</summary>
+ public bool Enabled
+ {
+ get { return m_enabled; }
+ set { m_enabled = value; }
+ }
+
+
+ private SslProtocols m_version = SslProtocols.Ssl3;
+
+ ///<summary>Retrieve or set the Ssl protocol version
+ ///</summary>
+ public SslProtocols Version
+ {
+ get { return m_version; }
+ set { m_version = value; }
+ }
+
+ private string m_certPath;
+
+ ///<summary>Retrieve or set the path to client certificate.
+ ///</summary>
+ public string CertPath
+ {
+ get { return m_certPath; }
+ set { m_certPath = value; }
+ }
+
+ private string m_certPass;
+
+ ///<summary>Retrieve or set the path to client certificate.
+ ///</summary>
+ public string CertPassphrase
+ {
+ get { return m_certPass; }
+ set { m_certPass = value; }
+ }
+
+
+ ///<summary>Convenience read-only property to retrieve an X509CertificateCollection
+ ///containing the client certificate</summary>
+ public X509CertificateCollection Certs
+ {
+ get {
+ if(m_certPath == "") {
+ return null;
+ } else {
+ X509CertificateCollection c = new X509CertificateCollection();
+ c.Add(new X509Certificate2(m_certPath, m_certPass));
+ return c;
+ }
+ }
+ }
+
+ private string m_serverName;
+
+ ///<summary>Retrieve or set server's Canonical Name. This MUST match the CN
+ ///on the Certificate else the SSL connection will fail</summary>
+ public string ServerName
+ {
+ get { return m_serverName; }
+ set { m_serverName = value; }
+ }
+
+ private SslPolicyErrors m_acceptablePolicyErrors = SslPolicyErrors.None;
+
+ ///<summary>Retrieve or set the set of ssl policy errors that
+ ///are deemed acceptable</summary>
+ public SslPolicyErrors AcceptablePolicyErrors
+ {
+ get { return m_acceptablePolicyErrors; }
+ set { m_acceptablePolicyErrors = value; }
+ }
+
+
+ ///<summary>Construct an SslOption specifying both the server cannonical name
+ ///and the client's certificate path.
+ ///</summary>
+ public SslOption(string serverName, string certPath, bool enabled)
+ {
+ m_serverName= serverName;
+ m_certPath = certPath;
+ m_enabled = enabled;
+ }
+
+ ///<summary>Construct an SslOption with just the server cannonical name.
+ ///The Certificate path is set to an empty string
+ ///</summary>
+ public SslOption(string serverName): this(serverName, "", false)
+ {
+ }
+
+ ///<summary>Construct an SslOption with no parameters set</summary>
+ public SslOption(): this("", "", false)
+ {
+ }
+
+ }
+}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
///each endpoint.</summary>
public IDictionary ConnectionErrors { get { return m_connectionErrors; } }
+ ///<summary>same as ConnectionErrors property</summary>
+ public override IDictionary Data { get { return m_connectionErrors; } }
+
///<summary>Construct a BrokerUnreachableException. Expects
///maps as per the description of the ConnectionAttempts and
///ConnectionErrors properties.</summary>
StringBuilder sb = new StringBuilder(base.Message);
sb.Append("\nEndpoints attempted:\n");
foreach (DictionaryEntry entry in m_connectionAttempts) {
- sb.Append(" endpoint=");
- sb.Append(entry.Key);
- sb.Append(", attempts=");
- sb.Append(entry.Value);
- sb.Append(", outcome=");
- Exception e = m_connectionErrors[entry.Key] as Exception;
- if (e == null) {
- sb.Append("(null)");
- } else {
- sb.Append(e.Message);
- }
- sb.Append("\n");
+ sb.Append("------------------------------------------------\n");
+ sb.Append("endpoint=").Append(entry.Key);
+ sb.Append(", attempts=").Append(entry.Value).Append("\n");
+ sb.Append(m_connectionErrors[entry.Key] as Exception);
}
+ sb.Append("\n================================================\n");
sb.Append("Stack trace:\n");
sb.Append(base.StackTrace);
return sb.ToString();
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
--- /dev/null
+// This source code is dual-licensed under the Apache License, version\r
+// 2.0, and the Mozilla Public License, version 1.1.\r
+//\r
+// The APL v2.0:\r
+//\r
+//---------------------------------------------------------------------------\r
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial\r
+// Technologies LLC., and Rabbit Technologies Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//---------------------------------------------------------------------------\r
+//\r
+// The MPL v1.1:\r
+//\r
+//---------------------------------------------------------------------------\r
+// The contents of this file are subject to the Mozilla Public License\r
+// Version 1.1 (the "License"); you may not use this file except in\r
+// compliance with the License. You may obtain a copy of the License at\r
+// http://www.rabbitmq.com/mpl.html\r
+//\r
+// Software distributed under the License is distributed on an "AS IS"\r
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\r
+// License for the specific language governing rights and limitations\r
+// under the License.\r
+//\r
+// The Original Code is The RabbitMQ .NET Client.\r
+//\r
+// The Initial Developers of the Original Code are LShift Ltd,\r
+// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.\r
+//\r
+// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,\r
+// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd\r
+// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial\r
+// Technologies LLC, and Rabbit Technologies Ltd.\r
+//\r
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift\r
+// Ltd. Portions created by Cohesive Financial Technologies LLC are\r
+// Copyright (C) 2007-2010 Cohesive Financial Technologies\r
+// LLC. Portions created by Rabbit Technologies Ltd are Copyright\r
+// (C) 2007-2010 Rabbit Technologies Ltd.\r
+//\r
+// All Rights Reserved.\r
+//\r
+// Contributor(s): ______________________________________.\r
+//\r
+//---------------------------------------------------------------------------\r
+using System;\r
+\r
+namespace RabbitMQ.Client.Exceptions\r
+{\r
+ /// <summary> Thrown when the likely cause is an \r
+ /// authentication failure. </summary>\r
+ public class PossibleAuthenticationFailureException : Exception\r
+ {\r
+ public PossibleAuthenticationFailureException(String msg, Exception inner) \r
+ : base(msg, inner)\r
+ {\r
+ }\r
+ }\r
+}\r
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
public abstract int DefaultPort { get; }
public abstract IFrameHandler CreateFrameHandler(AmqpTcpEndpoint endpoint);
- public abstract IConnection CreateConnection(ConnectionParameters parameters,
+ public abstract IConnection CreateConnection(ConnectionFactory factory,
bool insist,
IFrameHandler frameHandler);
public abstract IModel CreateModel(ISession session);
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
using System;
using System.Collections;
-namespace RabbitMQ.Client.Impl {
- public abstract class BasicProperties: ContentHeaderBase, IBasicProperties {
- public abstract string ContentType { get; set; }
- public abstract string ContentEncoding { get; set; }
- public abstract IDictionary Headers { get; set; }
- public abstract byte DeliveryMode { get; set; }
- public abstract byte Priority { get; set; }
- public abstract string CorrelationId { get; set; }
- public abstract string ReplyTo { get; set; }
- public abstract string Expiration { get; set; }
- public abstract string MessageId { get; set; }
- public abstract AmqpTimestamp Timestamp { get; set; }
- public abstract string Type { get; set; }
- public abstract string UserId { get; set; }
- public abstract string AppId { get; set; }
- public abstract string ClusterId { get; set; }
+namespace RabbitMQ.Client.Impl
+{
+ public abstract class BasicProperties: ContentHeaderBase, IBasicProperties
+ {
+ public abstract string ContentType { get; set; }
+ public abstract string ContentEncoding { get; set; }
+ public abstract IDictionary Headers { get; set; }
+ public abstract byte DeliveryMode { get; set; }
+ public abstract byte Priority { get; set; }
+ public abstract string CorrelationId { get; set; }
+ public abstract string ReplyTo { get; set; }
+ public abstract string Expiration { get; set; }
+ public abstract string MessageId { get; set; }
+ public abstract AmqpTimestamp Timestamp { get; set; }
+ public abstract string Type { get; set; }
+ public abstract string UserId { get; set; }
+ public abstract string AppId { get; set; }
+ public abstract string ClusterId { get; set; }
- public abstract void ClearContentType();
- public abstract void ClearContentEncoding();
- public abstract void ClearHeaders();
- public abstract void ClearDeliveryMode();
- public abstract void ClearPriority();
- public abstract void ClearCorrelationId();
- public abstract void ClearReplyTo();
- public abstract void ClearExpiration();
- public abstract void ClearMessageId();
- public abstract void ClearTimestamp();
- public abstract void ClearType();
- public abstract void ClearUserId();
- public abstract void ClearAppId();
- public abstract void ClearClusterId();
+ public abstract void ClearContentType();
+ public abstract void ClearContentEncoding();
+ public abstract void ClearHeaders();
+ public abstract void ClearDeliveryMode();
+ public abstract void ClearPriority();
+ public abstract void ClearCorrelationId();
+ public abstract void ClearReplyTo();
+ public abstract void ClearExpiration();
+ public abstract void ClearMessageId();
+ public abstract void ClearTimestamp();
+ public abstract void ClearType();
+ public abstract void ClearUserId();
+ public abstract void ClearAppId();
+ public abstract void ClearClusterId();
- public PublicationAddress ReplyToAddress {
- get {
+ public abstract bool IsContentTypePresent();
+ public abstract bool IsContentEncodingPresent();
+ public abstract bool IsHeadersPresent();
+ public abstract bool IsDeliveryModePresent();
+ public abstract bool IsPriorityPresent();
+ public abstract bool IsCorrelationIdPresent();
+ public abstract bool IsReplyToPresent();
+ public abstract bool IsExpirationPresent();
+ public abstract bool IsMessageIdPresent();
+ public abstract bool IsTimestampPresent();
+ public abstract bool IsTypePresent();
+ public abstract bool IsUserIdPresent();
+ public abstract bool IsAppIdPresent();
+ public abstract bool IsClusterIdPresent();
+
+ public PublicationAddress ReplyToAddress
+ {
+ get
+ {
return PublicationAddress.Parse(ReplyTo);
}
- set {
+ set
+ {
ReplyTo = value.ToString();
}
}
- public void SetPersistent(bool persistent) {
- if (persistent) {
- DeliveryMode = 2;
- } else {
- DeliveryMode = 1;
- }
- }
+ public void SetPersistent(bool persistent)
+ {
+ if (persistent)
+ DeliveryMode = 2;
+ else
+ DeliveryMode = 1;
+ }
+
+ public override object Clone()
+ {
+ BasicProperties clone = MemberwiseClone() as BasicProperties;
+ if (IsHeadersPresent())
+ {
+ clone.Headers = new Hashtable();
+ foreach (DictionaryEntry entry in Headers)
+ clone.Headers[entry.Key] = entry.Value;
+ }
+
+ return clone;
+ }
}
}
+++ /dev/null
-// This source code is dual-licensed under the Apache License, version
-// 2.0, and the Mozilla Public License, version 1.1.
-//
-// The APL v2.0:
-//
-//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
-// Technologies LLC., and Rabbit Technologies Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//---------------------------------------------------------------------------
-//
-// The MPL v1.1:
-//
-//---------------------------------------------------------------------------
-// The contents of this file are subject to the Mozilla Public License
-// Version 1.1 (the "License"); you may not use this file except in
-// compliance with the License. You may obtain a copy of the License at
-// http://www.rabbitmq.com/mpl.html
-//
-// Software distributed under the License is distributed on an "AS IS"
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-// License for the specific language governing rights and limitations
-// under the License.
-//
-// The Original Code is The RabbitMQ .NET Client.
-//
-// The Initial Developers of the Original Code are LShift Ltd,
-// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
-//
-// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
-// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
-// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
-// Technologies LLC, and Rabbit Technologies Ltd.
-//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
-// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
-// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
-//
-// All Rights Reserved.
-//
-// Contributor(s): ______________________________________.
-//
-//---------------------------------------------------------------------------
-using System;
-
-// We use spec version 0-9 for common constants such as frame types,
-// error codes, and the frame end byte, since they don't vary *within
-// the versions we support*. Obviously we may need to revisit this if
-// that ever changes.
-using CommonFraming = RabbitMQ.Client.Framing.v0_9;
-
-namespace RabbitMQ.Client.Impl {
- /// <summary>
- /// Thrown when the connection receives a body that exceeds the permissible maximum.
- /// FIXME: document the permissible maximum, and how to query and configure it
- /// </summary>
- public class BodyTooLongException: SoftProtocolException {
- private readonly ulong m_requestedLength;
-
- public BodyTooLongException(int channelNumber, ulong requestedLength)
- : base(channelNumber,
- string.Format("The body of a message ({0} bytes) was too long.",
- requestedLength))
- {
- m_requestedLength = requestedLength;
- }
-
- public ulong RequestedLength { get { return m_requestedLength; } }
-
- public override ushort ReplyCode { get { return CommonFraming.Constants.ContentTooLarge; } }
- }
-}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
}
NetworkBinaryReader reader = f.GetReader();
m_command.m_header = m_protocol.DecodeContentHeaderFrom(reader);
- m_remainingBodyBytes = m_command.m_header.ReadFrom(f.Channel, reader);
+ m_remainingBodyBytes = m_command.m_header.ReadFrom(reader);
UpdateContentBodyState();
return CompletedCommand();
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
//---------------------------------------------------------------------------
using System;
using System.IO;
+using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Collections;
///(milliseconds)</summary>
public static int ConnectionCloseTimeout = 10000;
- public ConnectionParameters m_parameters;
+ public ConnectionFactory m_factory;
public IFrameHandler m_frameHandler;
public uint m_frameMax = 0;
public ushort m_heartbeat = 0;
+ public IDictionary m_clientProperties;
+ public IDictionary m_serverProperties;
public AmqpTcpEndpoint[] m_knownHosts = null;
public MainSession m_session0;
public ModelBase m_model0;
- public readonly SessionManager m_sessionManager;
+ public SessionManager m_sessionManager;
public volatile bool m_running = true;
public IList m_shutdownReport = ArrayList.Synchronized(new ArrayList());
- public ConnectionBase(ConnectionParameters parameters,
+ public ConnectionBase(ConnectionFactory factory,
bool insist,
IFrameHandler frameHandler)
{
- m_parameters = parameters;
+ m_factory = factory;
m_frameHandler = frameHandler;
- m_sessionManager = new SessionManager(this);
+ m_sessionManager = new SessionManager(this, 0);
m_session0 = new MainSession(this);
m_session0.Handler = new MainSession.SessionCloseDelegate(NotifyReceivedCloseOk);
m_model0 = (ModelBase)Protocol.CreateModel(m_session0);
StartMainLoop();
Open(insist);
StartHeartbeatLoops();
+ AppDomain.CurrentDomain.DomainUnload += HandleDomainUnload;
}
public event ConnectionShutdownEventHandler ConnectionShutdown
m_heartbeatWrite.Set();
}
- public ConnectionParameters Parameters
- {
- get
- {
- return m_parameters;
- }
- }
-
public ushort ChannelMax
{
get
{
return m_sessionManager.ChannelMax;
}
- set
- {
- m_sessionManager.ChannelMax = value;
- }
}
public uint FrameMax
}
}
+ public IDictionary ClientProperties
+ {
+ get
+ {
+ return new Hashtable(m_clientProperties);
+ }
+ set
+ {
+ m_clientProperties = value;
+ }
+ }
+
+ public IDictionary ServerProperties
+ {
+ get
+ {
+ return m_serverProperties;
+ }
+ set
+ {
+ m_serverProperties = value;
+ }
+ }
+
public AmqpTcpEndpoint[] KnownHosts
{
get { return m_knownHosts; }
///<summary>API-side invocation of connection close.</summary>
public void Close()
{
- Close(200, "Goodbye", Timeout.Infinite);
+ Close(CommonFraming.Constants.ReplySuccess, "Goodbye", Timeout.Infinite);
}
///<summary>API-side invocation of connection close.</summary>
///<summary>API-side invocation of connection close with timeout.</summary>
public void Close(int timeout)
{
- Close(200, "Goodbye", timeout);
+ Close(CommonFraming.Constants.ReplySuccess, "Goodbye", timeout);
}
///<summary>API-side invocation of connection close with timeout.</summary>
///<summary>API-side invocation of connection abort with timeout.</summary>
public void Abort(int timeout)
{
- Abort(200, "Connection close forced", timeout);
+ Abort(CommonFraming.Constants.ReplySuccess, "Connection close forced", timeout);
}
///<summary>API-side invocation of connection abort with timeout.</summary>
public void StartMainLoop()
{
- Thread mainloopThread = new Thread(new ThreadStart(MainLoop));
- mainloopThread.Name = "AMQP Connection " + Endpoint.ToString();
- mainloopThread.Start();
+ Thread mainLoopThread = new Thread(new ThreadStart(MainLoop));
+ mainLoopThread.Name = "AMQP Connection " + Endpoint.ToString();
+ mainLoopThread.Start();
}
public void StartHeartbeatLoops()
{
shutdownCleanly = HardProtocolExceptionHandler(hpe);
}
+ catch (SocketException se)
+ {
+ // Possibly due to handshake timeout
+ HandleMainLoopException(new ShutdownEventArgs(ShutdownInitiator.Library,
+ 0,
+ "Socket exception",
+ se));
+ }
catch (Exception ex)
{
HandleMainLoopException(new ShutdownEventArgs(ShutdownInitiator.Library,
// counter.
return;
}
-
+
if (frame.Channel == 0) {
// In theory, we could get non-connection.close-ok
// frames here while we're quiescing (m_closeReason !=
m_model0.SetCloseReason(m_closeReason);
m_model0.FinishClose();
}
-
+
+ /// <remarks>
+ /// We need to close the socket, otherwise attempting to unload the domain
+ /// could cause a CannotUnloadAppDomainException
+ /// </remarks>
+ public void HandleDomainUnload(object sender, EventArgs ea)
+ {
+ Abort(CommonFraming.Constants.InternalError, "Domain Unload");
+ }
+
public bool HardProtocolExceptionHandler(HardProtocolException hpe)
{
if (SetCloseReason(hpe.ShutdownReason))
}
}
}
+ AppDomain.CurrentDomain.DomainUnload -= HandleDomainUnload;
}
public void OnCallbackException(CallbackExceptionEventArgs args)
}
}
- public IDictionary BuildClientPropertiesTable()
+ public static IDictionary DefaultClientProperties()
{
- string version = this.GetType().Assembly.GetName().Version.ToString();
+ System.Reflection.Assembly assembly =
+ System.Reflection.Assembly.GetAssembly(typeof(ConnectionBase));
+ string version = assembly.GetName().Version.ToString();
//TODO: Get the rest of this data from the Assembly Attributes
Hashtable table = new Hashtable();
table["product"] = Encoding.UTF8.GetBytes("RabbitMQ");
ConnectionStartDetails connectionStart = (ConnectionStartDetails)
connectionStartCell.Value;
+ ServerProperties = connectionStart.m_serverProperties;
+
AmqpVersion serverVersion = new AmqpVersion(connectionStart.m_versionMajor,
connectionStart.m_versionMinor);
if (!serverVersion.Equals(Protocol.Version))
serverVersion.Minor);
}
+ m_clientProperties = new Hashtable(m_factory.ClientProperties);
+
// FIXME: check that PLAIN is supported.
// FIXME: parse out locales properly!
- ConnectionTuneDetails connectionTune =
- m_model0.ConnectionStartOk(BuildClientPropertiesTable(),
+ ConnectionTuneDetails connectionTune = default(ConnectionTuneDetails);
+ try
+ {
+ connectionTune =
+ m_model0.ConnectionStartOk(m_clientProperties,
"PLAIN",
- Encoding.UTF8.GetBytes("\0" + m_parameters.UserName +
- "\0" + m_parameters.Password),
+ Encoding.UTF8.GetBytes(
+ "\0" + m_factory.UserName +
+ "\0" + m_factory.Password),
"en_US");
+ }
+ catch (OperationInterruptedException e)
+ {
+ throw new PossibleAuthenticationFailureException(
+ "Possibly caused by authentication failure", e);
+ }
- ushort channelMax = (ushort) NegotiatedMaxValue(m_parameters.RequestedChannelMax,
+ ushort channelMax = (ushort) NegotiatedMaxValue(m_factory.RequestedChannelMax,
connectionTune.m_channelMax);
- ChannelMax = channelMax;
+ m_sessionManager = new SessionManager(this, channelMax);
- uint frameMax = NegotiatedMaxValue(m_parameters.RequestedFrameMax,
+ uint frameMax = NegotiatedMaxValue(m_factory.RequestedFrameMax,
connectionTune.m_frameMax);
FrameMax = frameMax;
- ushort heartbeat = (ushort) NegotiatedMaxValue(m_parameters.RequestedHeartbeat,
+ ushort heartbeat = (ushort) NegotiatedMaxValue(m_factory.RequestedHeartbeat,
connectionTune.m_heartbeat);
Heartbeat = heartbeat;
frameMax,
heartbeat);
- string knownHosts = m_model0.ConnectionOpen(m_parameters.VirtualHost,
+ string knownHosts = m_model0.ConnectionOpen(m_factory.VirtualHost,
"", // FIXME: make configurable?
insist);
KnownHosts = AmqpTcpEndpoint.ParseMultiple(Protocol, knownHosts);
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
{
public abstract class ContentHeaderBase : IContentHeader
{
- public static uint MaximumPermittedReceivableBodySize = 32 * 1048576; // FIXME: configurable
-
public abstract int ProtocolClassId { get; }
public abstract string ProtocolClassName { get; }
public abstract void ReadPropertiesFrom(ContentHeaderPropertyReader reader);
public abstract void WritePropertiesTo(ContentHeaderPropertyWriter writer);
public abstract void AppendPropertyDebugStringTo(System.Text.StringBuilder sb);
- ///<summary>Fill this instance from the given byte buffer
- ///stream. Throws BodyTooLongException, which is the reason
- ///for the channelNumber parameter.</summary>
- ///<remarks>
- ///<para>
- /// It might be better to do the body length check in our
- /// caller, currently CommandAssembler, which would avoid
- /// passing in the otherwise unrequired channelNumber
- /// parameter.
- ///</para>
- ///</remarks>
- public ulong ReadFrom(int channelNumber, NetworkBinaryReader reader)
+ ///<summary>Fill this instance from the given byte buffer stream.
+ ///</summary>
+ public ulong ReadFrom(NetworkBinaryReader reader)
{
reader.ReadUInt16(); // weight - not currently used
ulong bodySize = reader.ReadUInt64();
- if (bodySize > MaximumPermittedReceivableBodySize)
- {
- throw new BodyTooLongException(channelNumber, bodySize);
- }
ReadPropertiesFrom(new ContentHeaderPropertyReader(reader));
return bodySize;
}
writer.Write((ulong)bodySize);
WritePropertiesTo(new ContentHeaderPropertyWriter(writer));
}
+
+ public virtual object Clone()
+ {
+ throw new NotImplementedException();
+ }
}
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
public abstract void ClearFilename();
public abstract void ClearTimestamp();
public abstract void ClearClusterId();
+
+ public abstract bool IsContentTypePresent();
+ public abstract bool IsContentEncodingPresent();
+ public abstract bool IsHeadersPresent();
+ public abstract bool IsPriorityPresent();
+ public abstract bool IsReplyToPresent();
+ public abstract bool IsMessageIdPresent();
+ public abstract bool IsFilenamePresent();
+ public abstract bool IsTimestampPresent();
+ public abstract bool IsClusterIdPresent();
+
+ public override object Clone()
+ {
+ FileProperties clone = MemberwiseClone() as FileProperties;
+ if (IsHeadersPresent())
+ {
+ clone.Headers = new Hashtable();
+ foreach (DictionaryEntry entry in Headers)
+ clone.Headers[entry.Key] = entry.Value;
+ }
+
+ return clone;
+ }
}
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
//---------------------------------------------------------------------------
using System;
using System.IO;
+using System.Net.Sockets;
using RabbitMQ.Util;
using RabbitMQ.Client.Exceptions;
int type;
int channel;
- type = reader.ReadByte();
+ try
+ {
+ type = reader.ReadByte();
+ }
+ catch (IOException ioe)
+ {
+ // If it's a WSAETIMEDOUT SocketException, unwrap it.
+ // This might happen when the limit of half-open connections is
+ // reached.
+ if (ioe.InnerException == null ||
+ !(ioe.InnerException is SocketException) ||
+ ((SocketException)ioe.InnerException).SocketErrorCode != SocketError.TimedOut)
+ throw ioe;
+ throw ioe.InnerException;
+ }
if (type == 'A')
{
public void WriteTo(NetworkBinaryWriter writer)
{
FinishWriting();
- writer.Write((byte)m_type);
- writer.Write((ushort)m_channel);
- writer.Write((uint)m_payload.Length);
- writer.Write((byte[])m_payload);
- writer.Write((byte)CommonFraming.Constants.FrameEnd);
+ writer.Write((byte) m_type);
+ writer.Write((ushort) m_channel);
+ writer.Write((uint) m_payload.Length);
+ writer.Write((byte[]) m_payload);
+ writer.Write((byte) CommonFraming.Constants.FrameEnd);
}
public NetworkBinaryReader GetReader()
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
using System;
using System.IO;
using System.Collections;
+using System.Diagnostics;
using System.Threading;
using RabbitMQ.Client;
// we support*. Obviously we may need to revisit this if that ever
// changes.
using CommonFraming = RabbitMQ.Client.Framing.v0_9;
-using System.Diagnostics;
namespace RabbitMQ.Client.Impl
{
public void Close()
{
- Close(200, "Goodbye");
+ Close(CommonFraming.Constants.ReplySuccess, "Goodbye");
}
public void Close(ushort replyCode, string replyText)
public void Abort()
{
- Abort(200, "Goodbye");
+ Abort(CommonFraming.Constants.ReplySuccess, "Goodbye");
}
public void Abort(ushort replyCode, string replyText)
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
using RabbitMQ.Client.Exceptions;
using RabbitMQ.Util;
+// We use spec version 0-9 for common constants such as frame types,
+// error codes, and the frame end byte, since they don't vary *within
+// the versions we support*. Obviously we may need to revisit this if
+// that ever changes.
+using CommonFraming = RabbitMQ.Client.Framing.v0_9;
+
namespace RabbitMQ.Client.Impl
{
public class SessionManager
{
private readonly Hashtable m_sessionMap = new Hashtable();
private readonly ConnectionBase m_connection;
- private ushort m_channelMax = 0;
+ private readonly IntAllocator Ints;
+ public readonly ushort ChannelMax;
private bool m_autoClose = false;
- public SessionManager(ConnectionBase connection)
+ public SessionManager(ConnectionBase connection, ushort channelMax)
{
m_connection = connection;
- }
-
- public ushort ChannelMax
- {
- get
- {
- return m_channelMax;
- }
- set
- {
- m_channelMax = value;
- }
+ ChannelMax = (channelMax == 0) ? ushort.MaxValue : channelMax;
+ Ints = new IntAllocator(1, ChannelMax);
}
public bool AutoClose
{
lock (m_sessionMap)
{
- int channelNumber = Allocate();
+ int channelNumber = Ints.Allocate();
if (channelNumber == -1)
{
throw new ChannelAllocationException();
}
- return Create(channelNumber);
+ return CreateInternal(channelNumber);
}
}
public ISession Create(int channelNumber)
{
- ISession session;
lock (m_sessionMap)
{
- if (m_sessionMap.ContainsKey(channelNumber))
+ if (!Ints.Reserve(channelNumber))
{
throw new ChannelAllocationException(channelNumber);
}
- session = new Session(m_connection, channelNumber);
+ return CreateInternal(channelNumber);
+ }
+ }
+
+ public ISession CreateInternal(int channelNumber)
+ {
+ lock(m_sessionMap)
+ {
+ ISession session = new Session(m_connection, channelNumber);
session.SessionShutdown += new SessionShutdownEventHandler(HandleSessionShutdown);
- //Console.WriteLine("SessionManager adding session "+session);
m_sessionMap[channelNumber] = session;
+ return session;
}
- return session;
}
///<summary>Replace an active session slot with a new ISession
}
}
- ///<summary>Find an unused channel number. Must be called
- ///while holding m_sessionMap lock!</summary>
- ///<remarks>
- /// Returns -1 if no unused channel numbers are available.
- ///</remarks>
- public int Allocate()
- {
- ushort maxChannels = (m_channelMax == 0) ? ushort.MaxValue : m_channelMax;
- for (int candidate = 1; candidate <= maxChannels; candidate++)
- {
- if (!m_sessionMap.ContainsKey(candidate))
- {
- return candidate;
- }
- }
- return -1;
- }
-
public void HandleSessionShutdown(ISession session, ShutdownEventArgs reason)
{
//Console.WriteLine("SessionManager removing session "+session);
lock (m_sessionMap)
{
m_sessionMap.Remove(session.ChannelNumber);
+ Ints.Free(session.ChannelNumber);
CheckAutoClose();
}
}
///when we decide to close the connection.</summary>
public void AutoCloseConnection()
{
- m_connection.Abort(200, "AutoClose", ShutdownInitiator.Library, Timeout.Infinite);
+ m_connection.Abort(CommonFraming.Constants.ReplySuccess, "AutoClose", ShutdownInitiator.Library, Timeout.Infinite);
}
}
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
m_socket.NoDelay = true;
Stream netstream = m_socket.GetStream();
- m_reader = new NetworkBinaryReader(netstream);
- m_writer = new NetworkBinaryWriter(netstream);
+ if (endpoint.Ssl.Enabled) {
+ try {
+ netstream = SslHelper.TcpUpgrade(netstream, endpoint.Ssl);
+ } catch (Exception) {
+ Close();
+ throw;
+ }
+ }
+ m_reader = new NetworkBinaryReader(new BufferedStream(netstream));
+ m_writer = new NetworkBinaryWriter(new BufferedStream(netstream));
}
public AmqpTcpEndpoint Endpoint
m_writer.Write((byte)1);
m_writer.Write((byte)m_endpoint.Protocol.MajorVersion);
m_writer.Write((byte)m_endpoint.Protocol.MinorVersion);
+ m_writer.Flush();
}
}
{
lock (m_reader)
{
- return Frame.ReadFrom(m_reader);
+ return Frame.ReadFrom(m_reader);
}
}
lock (m_writer)
{
frame.WriteTo(m_writer);
+ m_writer.Flush();
//Console.WriteLine("OUTBOUND:");
//DebugUtil.DumpProperties(frame, Console.Out, 2);
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
public abstract void ClearHeaders();
public abstract void ClearPriority();
public abstract void ClearTimestamp();
+
+ public abstract bool IsContentTypePresent();
+ public abstract bool IsContentEncodingPresent();
+ public abstract bool IsHeadersPresent();
+ public abstract bool IsPriorityPresent();
+ public abstract bool IsTimestampPresent();
+
+ public override object Clone()
+ {
+ StreamProperties clone = MemberwiseClone() as StreamProperties;
+ if (IsHeadersPresent())
+ {
+ clone.Headers = new Hashtable();
+ foreach (DictionaryEntry entry in Headers)
+ clone.Headers[entry.Key] = entry.Value;
+ }
+
+ return clone;
+ }
}
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
///<remarks>
/// Supports the AMQP 0-8/0-9 standard entry types S, I, D, T
/// and F, as well as the QPid-0-8 specific b, d, f, l, s, t,
- /// x and V types.
+ /// x and V types and the AMQP 0-9-1 A type.
///</remarks>
public static IDictionary ReadTable(NetworkBinaryReader reader)
{
while ((backingStream.Position - startPosition) < tableLength)
{
string key = ReadShortstr(reader);
- object value = null;
+ object value = ReadFieldValue(reader);
+
+ if (!table.ContainsKey(key))
+ {
+ table[key] = value;
+ }
+ }
- byte discriminator = reader.ReadByte();
- switch ((char)discriminator)
+ return table;
+ }
+
+ public static IList ReadArray(NetworkBinaryReader reader)
+ {
+ IList array = new ArrayList();
+ long arrayLength = reader.ReadUInt32();
+ Stream backingStream = reader.BaseStream;
+ long startPosition = backingStream.Position;
+ while ((backingStream.Position - startPosition) < arrayLength)
+ {
+ object value = ReadFieldValue(reader);
+ array.Add(value);
+ }
+ return array;
+ }
+
+ public static object ReadFieldValue(NetworkBinaryReader reader)
+ {
+ object value = null;
+ byte discriminator = reader.ReadByte();
+ switch ((char)discriminator)
{
case 'S':
value = ReadLongstr(reader);
value = ReadTable(reader);
break;
+ case 'A':
+ value = ReadArray(reader);
+ break;
case 'b':
value = ReadOctet(reader);
break;
throw new SyntaxError("Unrecognised type in table: " +
(char) discriminator);
}
-
- if (!table.ContainsKey(key))
- {
- table[key] = value;
- }
- }
-
- return table;
+ return value;
}
-
+
public static AmqpTimestamp ReadTimestamp(NetworkBinaryReader reader)
{
ulong stamp = ReadLonglong(reader);
///<para>
/// Supports the AMQP 0-8/0-9 standard entry types S, I, D, T
/// and F, as well as the QPid-0-8 specific b, d, f, l, s, t
- /// x and V types.
+ /// x and V types and the AMQP 0-9-1 A type.
///</para>
///</remarks>
public static void WriteTable(NetworkBinaryWriter writer, IDictionary val)
{
WriteShortstr(writer, (string)entry.Key);
object value = entry.Value;
-
- if (value == null)
- {
- WriteOctet(writer, (byte)'V');
- }
- else if (value is string)
- {
- WriteOctet(writer, (byte)'S');
- WriteLongstr(writer, Encoding.UTF8.GetBytes((string)value));
- }
- else if (value is byte[])
- {
- WriteOctet(writer, (byte)'S');
- WriteLongstr(writer, (byte[])value);
- }
- else if (value is int)
- {
- WriteOctet(writer, (byte)'I');
- writer.Write((int)value);
- }
- else if (value is decimal)
- {
- WriteOctet(writer, (byte)'D');
- WriteDecimal(writer, (decimal)value);
- }
- else if (value is AmqpTimestamp)
- {
- WriteOctet(writer, (byte)'T');
- WriteTimestamp(writer, (AmqpTimestamp)value);
- }
- else if (value is IDictionary)
- {
- WriteOctet(writer, (byte)'F');
- WriteTable(writer, (IDictionary)value);
- }
- else if (value is byte)
- {
- WriteOctet(writer, (byte)'b');
- WriteOctet(writer, (byte)value);
- }
- else if (value is double)
- {
- WriteOctet(writer, (byte)'d');
- writer.Write((double)value);
- }
- else if (value is float)
- {
- WriteOctet(writer, (byte)'f');
- writer.Write((float)value);
- }
- else if (value is long)
- {
- WriteOctet(writer, (byte)'l');
- writer.Write((long)value);
- }
- else if (value is short)
- {
- WriteOctet(writer, (byte)'s');
- writer.Write((short)value);
- }
- else if (value is bool)
- {
- WriteOctet(writer, (byte)'t');
- WriteOctet(writer, (byte)(((bool)value) ? 1 : 0));
- }
- else if (value is BinaryTableValue)
- {
- WriteOctet(writer, (byte)'x');
- WriteLongstr(writer, ((BinaryTableValue)value).Bytes);
- }
- else
- {
- throw new WireFormattingException("Value cannot appear as table value",
- value);
- }
+ WriteFieldValue(writer, value);
}
// Now, backpatch the table length.
}
}
+ public static void WriteArray(NetworkBinaryWriter writer, IList val)
+ {
+ if (val == null)
+ {
+ writer.Write((uint)0);
+ }
+ else
+ {
+ Stream backingStream = writer.BaseStream;
+ long patchPosition = backingStream.Position;
+ writer.Write((uint)0); // length of table - will be backpatched
+ foreach (object entry in val)
+ {
+ WriteFieldValue(writer, entry);
+ }
+ long savedPosition = backingStream.Position;
+ long tableLength = savedPosition - patchPosition - 4; // offset for length word
+ backingStream.Seek(patchPosition, SeekOrigin.Begin);
+ writer.Write((uint)tableLength);
+ backingStream.Seek(savedPosition, SeekOrigin.Begin);
+ }
+ }
+
+ public static void WriteFieldValue(NetworkBinaryWriter writer, object value)
+ {
+ if (value == null)
+ {
+ WriteOctet(writer, (byte)'V');
+ }
+ else if (value is string)
+ {
+ WriteOctet(writer, (byte)'S');
+ WriteLongstr(writer, Encoding.UTF8.GetBytes((string)value));
+ }
+ else if (value is byte[])
+ {
+ WriteOctet(writer, (byte)'S');
+ WriteLongstr(writer, (byte[])value);
+ }
+ else if (value is int)
+ {
+ WriteOctet(writer, (byte)'I');
+ writer.Write((int)value);
+ }
+ else if (value is decimal)
+ {
+ WriteOctet(writer, (byte)'D');
+ WriteDecimal(writer, (decimal)value);
+ }
+ else if (value is AmqpTimestamp)
+ {
+ WriteOctet(writer, (byte)'T');
+ WriteTimestamp(writer, (AmqpTimestamp)value);
+ }
+ else if (value is IDictionary)
+ {
+ WriteOctet(writer, (byte)'F');
+ WriteTable(writer, (IDictionary)value);
+ }
+ else if (value is IList)
+ {
+ WriteOctet(writer, (byte)'A');
+ WriteArray(writer, (IList)value);
+ }
+ else if (value is byte)
+ {
+ WriteOctet(writer, (byte)'b');
+ WriteOctet(writer, (byte)value);
+ }
+ else if (value is double)
+ {
+ WriteOctet(writer, (byte)'d');
+ writer.Write((double)value);
+ }
+ else if (value is float)
+ {
+ WriteOctet(writer, (byte)'f');
+ writer.Write((float)value);
+ }
+ else if (value is long)
+ {
+ WriteOctet(writer, (byte)'l');
+ writer.Write((long)value);
+ }
+ else if (value is short)
+ {
+ WriteOctet(writer, (byte)'s');
+ writer.Write((short)value);
+ }
+ else if (value is bool)
+ {
+ WriteOctet(writer, (byte)'t');
+ WriteOctet(writer, (byte)(((bool)value) ? 1 : 0));
+ }
+ else if (value is BinaryTableValue)
+ {
+ WriteOctet(writer, (byte)'x');
+ WriteLongstr(writer, ((BinaryTableValue)value).Bytes);
+ }
+ else
+ {
+ throw new WireFormattingException("Value cannot appear as table value",
+ value);
+ }
+ }
+
public static void WriteTimestamp(NetworkBinaryWriter writer, AmqpTimestamp val)
{
// 0-9 is afaict silent on the signedness of the timestamp.
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
namespace RabbitMQ.Client.Framing.Impl.v0_8 {
public class Connection: ConnectionBase {
- public Connection(ConnectionParameters parameters, bool insist, IFrameHandler frameHandler)
- : base(parameters, insist, frameHandler) {}
+ public Connection(ConnectionFactory factory, bool insist, IFrameHandler frameHandler)
+ : base(factory, insist, frameHandler) {}
}
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
return new Model(session);
}
- public override IConnection CreateConnection(ConnectionParameters parameters,
+ public override IConnection CreateConnection(ConnectionFactory factory,
bool insist,
IFrameHandler frameHandler)
{
- return new Connection(parameters, insist, frameHandler);
+ return new Connection(factory, insist, frameHandler);
}
public override void CreateConnectionClose(ushort reasonCode,
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
namespace RabbitMQ.Client.Framing.Impl.v0_8qpid {
public class Connection: ConnectionBase {
- public Connection(ConnectionParameters parameters, bool insist, IFrameHandler frameHandler)
- : base(parameters, insist, frameHandler) {}
+ public Connection(ConnectionFactory factory , bool insist, IFrameHandler frameHandler)
+ : base(factory, insist, frameHandler) {}
}
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
return new Model(session);
}
- public override IConnection CreateConnection(ConnectionParameters parameters,
+ public override IConnection CreateConnection(ConnectionFactory factory,
bool insist,
IFrameHandler frameHandler)
{
- return new Connection(parameters, insist, frameHandler);
+ return new Connection(factory, insist, frameHandler);
}
public override void CreateConnectionClose(ushort reasonCode,
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
namespace RabbitMQ.Client.Framing.Impl.v0_9 {
public class Connection: ConnectionBase {
- public Connection(ConnectionParameters parameters, bool insist, IFrameHandler frameHandler)
- : base(parameters, insist, frameHandler) {}
+ public Connection(ConnectionFactory factory, bool insist, IFrameHandler frameHandler)
+ : base(factory, insist, frameHandler) {}
}
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
return new Model(session);
}
- public override IConnection CreateConnection(ConnectionParameters parameters,
+ public override IConnection CreateConnection(ConnectionFactory factory,
bool insist,
IFrameHandler frameHandler)
{
- return new Connection(parameters, insist, frameHandler);
+ return new Connection(factory, insist, frameHandler);
}
public override void CreateConnectionClose(ushort reasonCode,
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
public IModel Model { get { return m_model; } }
protected string m_queueName;
- protected QueueingBasicConsumer m_consumer;
- protected string m_consumerTag;
protected bool m_noAck;
- protected bool m_shouldDelete;
+
+ protected readonly object m_consumerLock = new object();
+ protected volatile QueueingBasicConsumer m_consumer;
+ protected string m_consumerTag;
+ protected volatile bool m_shouldDelete;
///<summary>Retrieve the queue name we have subscribed to. May
///be a server-generated name, depending on how the
protected BasicDeliverEventArgs m_latestEvent;
///<summary>Returns the most recent value returned by Next(),
- ///or null when either no values have been retrieved yet, or
- ///the most recent value has already been Ack()ed. See also
- ///the documentation for Ack().</summary>
+ ///or null when either no values have been retrieved yet, the
+ ///end of the subscription has been reached, or the most
+ ///recent value has already been Ack()ed. See also the
+ ///documentation for Ack().</summary>
public BasicDeliverEventArgs LatestEvent { get { return m_latestEvent; } }
///<summary>Creates a new Subscription in "noAck" mode,
- ///consuming from a fresh, autodelete, anonymous queue. The
- ///name of the queue can be retrieved using the QueueName
- ///property of the Subscription. After creating the queue, the
- ///queue is bound to the named exchange, using Bind() with the
- ///given routingKey bind parameter.</summary>
+ ///consuming from a fresh, exclusive, autodelete, anonymous
+ ///queue. The name of the queue can be retrieved using the
+ ///QueueName property of the Subscription. After creating the
+ ///queue, the queue is bound to the named exchange, using
+ ///Bind() with the given routingKey bind parameter.</summary>
public Subscription(IModel model, string exchangeName,
string exchangeType, string routingKey)
: this(model)
}
///<summary>Creates a new Subscription in "noAck" mode,
- ///consuming from a fresh, autodelete, anonymous queue. The
- ///name of the queue can be retrieved using the QueueName
- ///property of the Subscription.</summary>
+ ///consuming from a fresh, exclusive, autodelete, anonymous
+ ///queue. The name of the queue can be retrieved using the
+ ///QueueName property of the Subscription.</summary>
public Subscription(IModel model)
: this(model, null) {}
///<summary>Creates a new Subscription in "noAck" mode,
///consuming from a named queue. If the queueName parameter is
- ///null or the empty-string, creates a fresh, autodelete,
- ///anonymous queue; otherwise, the queue is declared using
- ///IModel.QueueDeclare() before IModel.BasicConsume() is
- ///called. After declaring the queue and starting the
- ///consumer, the queue is bound to the named exchange, using
- ///Bind() with the given routingKey bind parameter.</summary>
+ ///null or the empty-string, creates a fresh, exclusive,
+ ///autodelete, anonymous queue; otherwise, the queue is
+ ///declared using IModel.QueueDeclare() before
+ ///IModel.BasicConsume() is called. After declaring the queue
+ ///and starting the consumer, the queue is bound to the named
+ ///exchange, using Bind() with the given routingKey bind
+ ///parameter.</summary>
public Subscription(IModel model, string queueName, string exchangeName,
string exchangeType, string routingKey)
: this(model, queueName)
///<summary>Creates a new Subscription in "noAck" mode,
///consuming from a named queue. If the queueName parameter is
- ///null or the empty-string, creates a fresh, autodelete,
- ///anonymous queue; otherwise, the queue is declared using
- ///IModel.QueueDeclare() before IModel.BasicConsume() is
- ///called.</summary>
+ ///null or the empty-string, creates a fresh, exclusive,
+ ///autodelete, anonymous queue; otherwise, the queue is
+ ///declared using IModel.QueueDeclare() before
+ ///IModel.BasicConsume() is called.</summary>
public Subscription(IModel model, string queueName)
: this(model, queueName, true) {}
///<summary>Creates a new Subscription, with full control over
///both "noAck" mode and the name of the queue (which, if null
- ///or the empty-string, will be a fresh autodelete queue, as
- ///for the other constructor overloads). After declaring the
- ///queue and starting the consumer, the queue is bound to the
- ///named exchange, using Bind() with the given routingKey bind
- ///parameter.</summary>
+ ///or the empty-string, will be a fresh, exclusive,
+ ///autodelete, anonymous queue, as for the other constructor
+ ///overloads). After declaring the queue and starting the
+ ///consumer, the queue is bound to the named exchange, using
+ ///Bind() with the given routingKey bind parameter.</summary>
public Subscription(IModel model, string queueName, bool noAck,
string exchangeName, string exchangeType, string routingKey)
: this(model, queueName, noAck)
///<summary>Creates a new Subscription, with full control over
///both "noAck" mode and the name of the queue (which, if null
- ///or the empty-string, will be a fresh autodelete queue, as
- ///for the other constructor overloads).</summary>
+ ///or the empty-string, will be a fresh, exclusive,
+ ///autodelete, anonymous queue, as for the other constructor
+ ///overloads).</summary>
public Subscription(IModel model, string queueName, bool noAck)
{
m_model = model;
}
///<summary>Closes this Subscription, cancelling the consumer
- ///record in the server. If an anonymous, autodelete queue
- ///(i.e., one with a server-generated name) was created during
- ///construction of the Subscription, this method also deletes
- ///the created queue (which is an optimisation: autodelete
- ///queues will be deleted when the IModel closes in any
- ///case).</summary>
+ ///record in the server. If an anonymous, exclusive,
+ ///autodelete queue (i.e., one with a server-generated name)
+ ///was created during construction of the Subscription, this
+ ///method also deletes the created queue (which is an
+ ///optimisation: autodelete queues will be deleted when the
+ ///IModel closes in any case).</summary>
public void Close()
{
try {
- if (m_consumer != null) {
- m_model.BasicCancel(m_consumerTag);
- }
- if (m_shouldDelete) {
- m_shouldDelete = false;
+ bool shouldCancelConsumer = false;
+ bool shouldDelete = false;
+
+ lock (m_consumerLock) {
+ if (m_consumer != null) {
+ shouldCancelConsumer = true;
+ m_consumer = null;
+ }
+
+ shouldDelete = m_shouldDelete;
// We set m_shouldDelete false before attempting
// the delete, because trying twice is worse than
// trying once and failing.
+ m_shouldDelete = false;
+ }
+
+ if (shouldCancelConsumer) {
+ m_model.BasicCancel(m_consumerTag);
+ m_consumerTag = null;
+ }
+
+ if (shouldDelete) {
m_model.QueueDelete(m_queueName, false, false, false);
}
} catch (OperationInterruptedException) {
// We don't mind, here.
}
- m_consumer = null;
- m_consumerTag = null;
}
///<summary>Causes the queue to which we have subscribed to be
public BasicDeliverEventArgs Next()
{
try {
- if (m_consumer == null) {
+ // Alias the pointer as otherwise it may change out
+ // from under us by the operation of Close() from
+ // another thread.
+ QueueingBasicConsumer consumer = m_consumer;
+ if (consumer == null) {
// Closed!
- throw new InvalidOperationException();
+ m_latestEvent = null;
+ } else {
+ m_latestEvent = (BasicDeliverEventArgs) consumer.Queue.Dequeue();
}
- m_latestEvent = (BasicDeliverEventArgs) m_consumer.Queue.Dequeue();
} catch (EndOfStreamException) {
m_latestEvent = null;
}
public bool Next(int millisecondsTimeout, out BasicDeliverEventArgs result)
{
try {
- if (m_consumer == null) {
+ // Alias the pointer as otherwise it may change out
+ // from under us by the operation of Close() from
+ // another thread.
+ QueueingBasicConsumer consumer = m_consumer;
+ if (consumer == null) {
// Closed!
- throw new InvalidOperationException();
- }
- object qValue;
- if (!m_consumer.Queue.Dequeue(millisecondsTimeout, out qValue)) {
- result = null;
- return false;
+ m_latestEvent = null;
+ } else {
+ object qValue;
+ if (!consumer.Queue.Dequeue(millisecondsTimeout, out qValue)) {
+ result = null;
+ return false;
+ }
+ m_latestEvent = (BasicDeliverEventArgs) qValue;
}
- m_latestEvent = (BasicDeliverEventArgs) qValue;
} catch (EndOfStreamException) {
m_latestEvent = null;
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
--- /dev/null
+// This source code is dual-licensed under the Apache License, version
+// 2.0, and the Mozilla Public License, version 1.1.
+//
+// The APL v2.0:
+//
+//---------------------------------------------------------------------------
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
+// Technologies LLC., and Rabbit Technologies Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.Apache.Org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//---------------------------------------------------------------------------
+//
+// The MPL v1.1:
+//
+//---------------------------------------------------------------------------
+// The contents of this file are subject to the Mozilla Public License
+// Version 1.1 (the "License"); you may not use this file except in
+// compliance with the License. You may obtain a copy of the License at
+// http://www.Rabbitmq.Com/mpl.Html
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+// License for the specific language governing rights and limitations
+// under the License.
+//
+// The Original Code is The RabbitMQ .NET Client.
+//
+// The Initial Developers of the Original Code are LShift Ltd,
+// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
+//
+// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+// Technologies LLC, and Rabbit Technologies Ltd.
+//
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
+// Ltd. Portions created by Cohesive Financial Technologies LLC are
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
+// LLC. Portions created by Rabbit Technologies Ltd are Copyright
+// (C) 2007-2010 Rabbit Technologies Ltd.
+//
+// All Rights Reserved.
+//
+// Contributor(s): ______________________________________.
+//
+//---------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace RabbitMQ.Util
+{
+
+
+ /**
+ * A class for allocating integer IDs in a given range.
+ */
+ public class IntAllocator{
+
+ private IntervalList Base;
+
+ private readonly int[] unsorted;
+ private int unsortedCount = 0;
+
+ /**
+ * A class representing a list of inclusive intervals
+ */
+ public class IntervalList{
+ public IntervalList(int start, int end){
+ this.Start = start;
+ this.End = end;
+ }
+
+ public int Start;
+ public int End;
+
+ // Invariant: If Next != Null then Next.Start > this.End + 1
+ public IntervalList Next;
+
+ // Destructively merge two IntervalLists.
+ // Invariant: None of the Intervals in the two lists may overlap
+ // intervals in this list.
+ public static IntervalList Merge(IntervalList x, IntervalList y)
+ {
+ if(x == null) return y;
+ if(y == null) return x;
+
+ if(x.End > y.Start) return Merge(y, x);
+
+ Debug.Assert(x.End != y.Start);
+
+ // We now have x, y non-null and x.End < y.Start.
+
+ if(y.Start == x.End + 1)
+ {
+ // The two intervals adjoin. Merge them into one and then
+ // merge the tails.
+ x.End = y.End;
+ x.Next = Merge(x.Next, y.Next);
+ return x;
+ }
+
+ // y belongs in the tail of x.
+
+ x.Next = Merge(y, x.Next);
+ return x;
+ }
+
+ public static IntervalList FromArray(int[] xs, int length)
+ {
+ Array.Sort(xs, 0, length);
+
+ IntervalList result = null;
+ IntervalList current = null;
+
+ int i = 0;
+ while(i < length){
+ int start = i;
+ while((i < length - 1) && (xs[i + 1] == xs[i] + 1))
+ i++;
+
+ IntervalList interval = new IntervalList(xs[start], xs[i]);
+
+ if(result == null)
+ {
+ result = interval;
+ current = interval;
+ }
+ else
+ {
+ current.Next = interval;
+ current = interval;
+ }
+ i++;
+ }
+ return result;
+ }
+ }
+
+ /**
+ * Creates an IntAllocator allocating integer IDs within the inclusive range [start, end]
+ */
+ public IntAllocator(int start, int end)
+ {
+ if(start > end) throw new ArgumentException("illegal range [" + start +", " + end + "]");
+
+ // Fairly arbitrary heuristic for a good size for the unsorted set.
+ unsorted = new int[Math.Max(32, (int)Math.Sqrt(end - start))];
+ Base = new IntervalList(start, end);
+ }
+
+ /**
+ * Allocate a fresh integer from the range, or return -1 if no more integers
+ * are available. This operation is guaranteed to run in O(1)
+ */
+ public int Allocate()
+ {
+ if(unsortedCount > 0){
+ return unsorted[--unsortedCount];
+ } else if (Base != null) {
+ int result = Base.Start++;
+ if(Base.Start == Base.End) Base = Base.Next;
+ return result;
+ } else {
+ return -1;
+ }
+ }
+
+ private void Flush()
+ {
+ if(unsortedCount > 0)
+ {
+ Base = IntervalList.Merge(Base, IntervalList.FromArray(unsorted, unsortedCount));
+ unsortedCount = 0;
+ }
+ }
+
+
+ /**
+ * Make the provided integer available for allocation again. This operation
+ * runs in amortized O(sqrt(range size)) time: About every sqrt(range size)
+ * operations will take O(range_size + number of intervals) to complete and
+ * the rest run in constant time.
+ *
+ * No error checking is performed, so if you double Free or Free an integer
+ * that was not originally Allocated the results are undefined. Sorry.
+ */
+ public void Free(int id)
+ {
+ if(unsortedCount >= unsorted.Length)
+ {
+ Flush();
+ }
+ unsorted[unsortedCount++] = id;
+ }
+
+ public bool Reserve(int id)
+ {
+ // We always flush before reserving because the only way to determine
+ // if an ID is in the unsorted array is through a linear scan. This leads
+ // us to the potentially expensive situation where there is a large unsorted
+ // array and we reserve several IDs, incurring the cost of the scan each time.
+ // Flushing makes sure the array is always empty and does no additional work if
+ // reserve is called twice.
+ Flush();
+
+ IntervalList current = Base;
+
+ while(current != null)
+ {
+ if(current.End < id)
+ {
+ current = current.Next;
+ continue;
+ }
+ else if(current.Start > id)
+ {
+ return false;
+ }
+ else if(current.End == id)
+ {
+ current.End--;
+ }
+ else if(current.Start == id)
+ {
+ current.Start++;
+ }
+ else
+ {
+ // The ID is in the middle of this interval.
+ // We need to split the interval into two.
+ IntervalList rest = new IntervalList(id + 1, current.End);
+ current.End = id - 1;
+ rest.Next = current.Next;
+ current.Next = rest;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ }
+}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//
namespace RabbitMQ.Util {
///<summary>A thread-safe shared queue implementation.</summary>
- public class SharedQueue: IDisposable {
+ public class SharedQueue : IEnumerable {
///<summary>The shared queue.</summary>
///<remarks>
///Subclasses must ensure appropriate locking discipline when
public SharedQueue() {
}
- ///<summary>Close the queue. Causes all waiting threads to be
- ///interrupted (with EndOfStreamException) and all further
- ///Enqueue() and Dequeue() operations to throw
- ///EndOfStreamException.</summary>
+ ///<summary>Close the queue. Causes all further Enqueue()
+ ///operations to throw EndOfStreamException, and all pending
+ ///or subsequent Dequeue() operations to throw an
+ ///EndOfStreamException once the queue is empty.</summary>
public void Close() {
lock (m_queue) {
m_isOpen = false;
}
}
- ///<summary>Implement IDisposable.Dispose. Delegates directly
- ///to Close().</summary>
- public void Dispose() {
- Close();
- }
-
///<summary>Call only when the lock on m_queue is held.</summary>
/// <exception cref="EndOfStreamException" />
private void EnsureIsOpen() {
///<remarks>
///Callers of Dequeue() will block if no items are available
///until some other thread calls Enqueue() or the queue is
- ///closed. If the queue is closed (by a call to Close()), this
- ///method will throw EndOfStreamException.
+ ///closed. In the latter case this method will throw
+ ///EndOfStreamException.
///</remarks>
public object Dequeue() {
lock (m_queue) {
- EnsureIsOpen();
while (m_queue.Count == 0) {
EnsureIsOpen();
Monitor.Wait(m_queue);
/// whereas Dequeue() will.
///</para>
///<para>
- /// If, at the time of call, the queue is in a closed state
- /// (by a call to Close()), this method will throw
- /// EndOfStreamException.
+ /// If at the time of call the queue is empty and in a
+ /// closed state (following a call to Close()), then this
+ /// method will throw EndOfStreamException.
///</para>
///</remarks>
public object DequeueNoWait(object defaultValue) {
lock (m_queue) {
- EnsureIsOpen();
if (m_queue.Count == 0) {
+ EnsureIsOpen();
return defaultValue;
} else {
return m_queue.Dequeue();
/// System.Threading.Monitor.Wait(object,int).
///</para>
///<para>
- /// If, at any time during the call, the queue is in or
+ /// If no items are present and the queue is in a closed
+ /// state, or if at any time while waiting the queue
/// transitions to a closed state (by a call to Close()), this
/// method will throw EndOfStreamException.
///</para>
DateTime startTime = DateTime.Now;
lock (m_queue) {
- EnsureIsOpen();
while (m_queue.Count == 0) {
+ EnsureIsOpen();
int elapsedTime = (int) ((DateTime.Now - startTime).TotalMilliseconds);
int remainingTime = millisecondsTimeout - elapsedTime;
if (remainingTime <= 0) {
}
Monitor.Wait(m_queue, remainingTime);
- EnsureIsOpen();
}
result = m_queue.Dequeue();
return true;
}
}
+
+ ///<summary>Implementation of the IEnumerable interface, for
+ ///permitting SharedQueue to be used in foreach
+ ///loops.</summary>
+ IEnumerator IEnumerable.GetEnumerator() {
+ return new SharedQueueEnumerator(this);
+ }
+
+ }
+
+ ///<summary>Implementation of the IEnumerator interface, for
+ ///permitting SharedQueue to be used in foreach loops.</summary>
+ public class SharedQueueEnumerator : IEnumerator {
+
+ protected SharedQueue m_queue;
+ protected object m_current;
+
+ ///<summary>Construct an enumerator for the given
+ ///SharedQueue.</summary>
+ public SharedQueueEnumerator(SharedQueue queue) {
+ m_queue = queue;
+ }
+
+ object IEnumerator.Current {
+ get {
+ if (m_current == null) {
+ throw new InvalidOperationException();
+ }
+ return m_current;
+ }
+ }
+
+ bool IEnumerator.MoveNext() {
+ try {
+ m_current = m_queue.Dequeue();
+ return true;
+ } catch (EndOfStreamException) {
+ m_current = null;
+ return false;
+ }
+ }
+
+ ///<summary>Reset()ting a SharedQueue doesn't make sense, so
+ ///this method always throws
+ ///InvalidOperationException.</summary>
+ void IEnumerator.Reset() {
+ throw new InvalidOperationException("SharedQueue.Reset() does not make sense");
+ }
+
}
+
}
// The APL v2.0:
//
//---------------------------------------------------------------------------
-// Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
+// Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial
// Technologies LLC., and Rabbit Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
// Technologies LLC, and Rabbit Technologies Ltd.
//
-// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+// Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
// Ltd. Portions created by Cohesive Financial Technologies LLC are
-// Copyright (C) 2007-2009 Cohesive Financial Technologies
+// Copyright (C) 2007-2010 Cohesive Financial Technologies
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
-// (C) 2007-2009 Rabbit Technologies Ltd.
+// (C) 2007-2010 Rabbit Technologies Ltd.
//
// All Rights Reserved.
//