summaryrefslogtreecommitdiff
path: root/qpid/dotnet/Qpid.Messaging
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/dotnet/Qpid.Messaging')
-rw-r--r--qpid/dotnet/Qpid.Messaging/AcknowledgeMode.cs42
-rw-r--r--qpid/dotnet/Qpid.Messaging/ChannelLimitReachedException.cs60
-rw-r--r--qpid/dotnet/Qpid.Messaging/DeliveryMode.cs28
-rw-r--r--qpid/dotnet/Qpid.Messaging/ExchangeClassConstants.cs29
-rw-r--r--qpid/dotnet/Qpid.Messaging/ExchangeNameDefaults.cs42
-rw-r--r--qpid/dotnet/Qpid.Messaging/IBytesMessage.cs63
-rw-r--r--qpid/dotnet/Qpid.Messaging/IChannel.cs280
-rw-r--r--qpid/dotnet/Qpid.Messaging/ICloseable.cs38
-rw-r--r--qpid/dotnet/Qpid.Messaging/IConnection.cs55
-rw-r--r--qpid/dotnet/Qpid.Messaging/IConnectionFactory.cs28
-rw-r--r--qpid/dotnet/Qpid.Messaging/IConnectionListener.cs59
-rw-r--r--qpid/dotnet/Qpid.Messaging/IFieldTable.cs42
-rw-r--r--qpid/dotnet/Qpid.Messaging/IHeaders.cs67
-rw-r--r--qpid/dotnet/Qpid.Messaging/IMessage.cs97
-rw-r--r--qpid/dotnet/Qpid.Messaging/IMessageConsumer.cs79
-rw-r--r--qpid/dotnet/Qpid.Messaging/IMessagePublisher.cs92
-rw-r--r--qpid/dotnet/Qpid.Messaging/ITextMessage.cs27
-rw-r--r--qpid/dotnet/Qpid.Messaging/MessageConsumerBuilder.cs113
-rw-r--r--qpid/dotnet/Qpid.Messaging/MessageNotReadableException.cs39
-rw-r--r--qpid/dotnet/Qpid.Messaging/MessageNotWritableException.cs38
-rw-r--r--qpid/dotnet/Qpid.Messaging/MessagePublisherBuilder.cs91
-rw-r--r--qpid/dotnet/Qpid.Messaging/Properties/AssemblyInfo.cs56
-rw-r--r--qpid/dotnet/Qpid.Messaging/Qpid.Messaging.csproj115
-rw-r--r--qpid/dotnet/Qpid.Messaging/QpidException.cs43
-rw-r--r--qpid/dotnet/Qpid.Messaging/ResourceAllocationException.cs39
-rw-r--r--qpid/dotnet/Qpid.Messaging/default.build45
26 files changed, 1707 insertions, 0 deletions
diff --git a/qpid/dotnet/Qpid.Messaging/AcknowledgeMode.cs b/qpid/dotnet/Qpid.Messaging/AcknowledgeMode.cs
new file mode 100644
index 0000000000..4896b64f68
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/AcknowledgeMode.cs
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public enum AcknowledgeMode
+ {
+ AutoAcknowledge,
+ ClientAcknowledge,
+ DupsOkAcknowledge,
+ SessionTransacted,
+
+ /// <summary>
+ /// Indicates that no client acknowledgements are required. Broker assumes that once it has
+ /// delivered a message packet successfully it is acknowledged.
+ /// </summary>
+ NoAcknowledge,
+
+ /// <summary>
+ /// Pre acknowledge means that an ack is sent per message but sent before user code has processed
+ /// the message (i.e. before the onMessage() call or the receive() method has returned).
+ /// </summary>
+ PreAcknowledge
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/ChannelLimitReachedException.cs b/qpid/dotnet/Qpid.Messaging/ChannelLimitReachedException.cs
new file mode 100644
index 0000000000..8b43422f5c
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/ChannelLimitReachedException.cs
@@ -0,0 +1,60 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
+using System;
+using System.Runtime.Serialization;
+
+namespace Apache.Qpid.Messaging
+{
+ [Serializable]
+ public class ChannelLimitReachedException : ResourceAllocationException
+ {
+ private long _limit;
+
+ public ChannelLimitReachedException(long limit)
+ : base("Unable to create session since maximum number of sessions per connection is " +
+ limit + ". Either close one or more sessions or increase the " +
+ "maximum number of sessions per connection (or contact your OpenAMQ administrator.")
+ {
+ _limit = limit;
+ }
+
+ protected ChannelLimitReachedException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ _limit = info.GetInt64("Limit");
+ }
+
+ public long Limit
+ {
+ get
+ {
+ return _limit;
+ }
+ }
+
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData(info, context);
+ info.AddValue("Limit", _limit);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/DeliveryMode.cs b/qpid/dotnet/Qpid.Messaging/DeliveryMode.cs
new file mode 100644
index 0000000000..3c4713ee2a
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/DeliveryMode.cs
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public enum DeliveryMode
+ {
+ NonPersistent,
+ Persistent
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/ExchangeClassConstants.cs b/qpid/dotnet/Qpid.Messaging/ExchangeClassConstants.cs
new file mode 100644
index 0000000000..984e8b0f17
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/ExchangeClassConstants.cs
@@ -0,0 +1,29 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public class ExchangeClassConstants
+ {
+ public readonly static string TOPIC = "topic";
+ public readonly static string DIRECT = "direct";
+ public readonly static string HEADERS = "headers";
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/ExchangeNameDefaults.cs b/qpid/dotnet/Qpid.Messaging/ExchangeNameDefaults.cs
new file mode 100644
index 0000000000..2689fb5e46
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/ExchangeNameDefaults.cs
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public class ExchangeNameDefaults
+ {
+ public readonly static string TOPIC = "amq.topic";
+ public readonly static string DIRECT = "amq.direct";
+ public readonly static string HEADERS = "amq.match";
+ public readonly static string FANOUT = "amq.fanout";
+
+ /// <summary> Defines the identifying type name of topic exchanges. </summary>
+ public readonly static string TOPIC_EXCHANGE_CLASS = "topic";
+
+ /// <summary> Defines the identifying type name of direct exchanges. </summary>
+ public readonly static string DIRECT_EXCHANGE_CLASS = "direct";
+
+ /// <summary> Defines the identifying type name of headers exchanges. </summary>
+ public readonly static string HEADERS_EXCHANGE_CLASS = "headers";
+
+ /// <summary> Defines the identifying type name of fanout exchanges. </summary>
+ public readonly static string FANOUT_EXCHANGE_CLASS = "fanout";
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IBytesMessage.cs b/qpid/dotnet/Qpid.Messaging/IBytesMessage.cs
new file mode 100644
index 0000000000..5be942423d
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IBytesMessage.cs
@@ -0,0 +1,63 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public interface IBytesMessage : IMessage
+ {
+ long BodyLength { get; }
+
+ bool ReadBoolean();
+ void WriteBoolean(bool value);
+
+ byte ReadByte();
+ int ReadBytes(byte[] array);
+ int ReadBytes(byte[] array, int length);
+ void WriteByte(byte value);
+ void WriteBytes(byte[] value);
+ void WriteBytes(byte[] value, int offset, int length);
+
+ char ReadChar();
+ void WriteChar(char value);
+
+ double ReadDouble();
+ void WriteDouble(double value);
+
+ float ReadFloat();
+ void WriteFloat(float value);
+
+ int ReadInt();
+ void WriteInt(int value);
+
+ long ReadLong();
+ void WriteLong(long value);
+
+ short ReadShort();
+ void WriteShort(short value);
+
+ short ReadSignedByte();
+ void WriteSignedByte(short value);
+
+ string ReadUTF();
+ void WriteUTF(string value);
+
+ void Reset();
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IChannel.cs b/qpid/dotnet/Qpid.Messaging/IChannel.cs
new file mode 100644
index 0000000000..1db8b5fbdb
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IChannel.cs
@@ -0,0 +1,280 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+using System;
+
+namespace Apache.Qpid.Messaging
+{
+ public delegate void MessageReceivedDelegate(IMessage msg);
+
+ /// <summary>
+ /// IChannel provides methods to access the commands in AMQP that operate at the channel level. This can be summarized as
+ /// the ability to declare queues and exchanges, bind queues to exchanges, create messages of various types, declare transaction
+ /// boundaries (commit and rollback), and to set up producers and consumers on the channel.
+ ///
+ /// <p/>You can create a channel by using the CreateChannel() method
+ /// of the connection object.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities
+ /// <tr><td> Declare queues.
+ /// <tr><td> Declare exchanges.
+ /// <tr><td> Bind queues to exchanges.
+ /// <tr><td> Create messages.
+ /// <tr><td> Set up message consumers on the channel.
+ /// <tr><td> Set up message producers on the channel.
+ /// <tr><td> Commit the current transaction.
+ /// <tr><td> Roll-back the current transaction.
+ /// <tr><td> Close the channel.
+ /// </table>
+ /// </summary>
+ public interface IChannel : IDisposable, ICloseable
+ {
+ /// <summary>
+ /// Acknowledge mode for messages received.
+ /// </summary>
+ AcknowledgeMode AcknowledgeMode { get; }
+
+ /// <summary>
+ /// True if the channel should use transactions.
+ /// </summary>
+ bool Transacted { get; }
+
+ /// <summary>
+ /// Prefetch value to be used as the default for
+ /// consumers created on this channel.
+ /// </summary>
+ int DefaultPrefetch { get; }
+
+ /// <summary>
+ /// Prefetch low value to be used as the default for
+ /// consumers created on this channel.
+ /// </summary>
+ int DefaultPrefetchLow { get; }
+
+ /// <summary>
+ /// Prefetch high value to be used as the default for
+ /// consumers created on this channel.
+ /// </summary>
+ int DefaultPrefetchHigh { get; }
+
+ /// <summary>
+ /// Declare a new exchange.
+ /// </summary>
+ /// <param name="exchangeName">Name of the exchange</param>
+ /// <param name="exchangeClass">Class of the exchange, from <see cref="ExchangeClassConstants"/></param>
+ void DeclareExchange(string exchangeName, string exchangeClass);
+
+ /// <summary>
+ /// Declare a new exchange using the default exchange class.
+ /// </summary>
+ /// <param name="exchangeName">Name of the exchange</param>
+ void DeleteExchange(string exchangeName);
+
+ /// <summary>
+ /// Declare a new queue with the specified set of arguments.
+ /// </summary>
+ /// <param name="queueName">Name of the queue</param>
+ /// <param name="isDurable">True if the queue should be durable</param>
+ /// <param name="isExclusive">True if the queue should be exclusive to this channel</param>
+ /// <param name="isAutoDelete">True if the queue should be deleted when the channel closes</param>
+ void DeclareQueue(string queueName, bool isDurable, bool isExclusive, bool isAutoDelete);
+
+
+ /// <summary>
+ /// Declare a new queue with the specified set of arguments.
+ /// </summary>
+ /// <param name="queueName">Name of the queue</param>
+ /// <param name="isDurable">True if the queue should be durable</param>
+ /// <param name="isExclusive">True if the queue should be exclusive to this channel</param>
+ /// <param name="isAutoDelete">True if the queue should be deleted when the channel closes</param>
+ /// <param name="args">Optional arguments to Queue.Declare</param>
+ void DeclareQueue(string queueName, bool isDurable, bool isExclusive, bool isAutoDelete, IFieldTable args);
+
+ /// <summary>
+ /// Delete a queue with the specifies arguments.
+ /// </summary>
+ /// <param name="queueName">Name of the queue to delete</param>
+ /// <param name="ifUnused">If true, the queue will not deleted if it has no consumers</param>
+ /// <param name="ifEmpty">If true, the queue will not deleted if it has no messages</param>
+ /// <param name="noWait">If true, the server will not respond to the method</param>
+ void DeleteQueue(string queueName, bool ifUnused, bool ifEmpty, bool noWait);
+
+ /// <summary>
+ /// Generate a new Unique name to use for a queue.
+ /// </summary>
+ /// <returns>A unique name to this channel</returns>
+ string GenerateUniqueName();
+
+ /// <summary>
+ /// Removes all messages from a queue.
+ /// </summary>
+ /// <param name="queueName">Name of the queue to delete</param>
+ /// <param name="noWait">If true, the server will not respond to the method</param>
+ void PurgeQueue(string queueName, bool noWait);
+
+ /// <summary>
+ /// Bind a queue to the specified exchange.
+ /// </summary>
+ /// <param name="queueName">Name of queue to bind</param>
+ /// <param name="exchangeName">Name of exchange to bind to</param>
+ /// <param name="routingKey">Routing key</param>
+ void Bind(string queueName, string exchangeName, string routingKey);
+
+ /// <summary>
+ /// Bind a queue to the specified exchange.
+ /// </summary>
+ /// <param name="queueName">Name of queue to bind</param>
+ /// <param name="exchangeName">Name of exchange to bind to</param>
+ /// <param name="routingKey">Routing key</param>
+ /// <param name="args">Table of arguments for the binding. Used to bind with a Headers Exchange</param>
+ void Bind(string queueName, string exchangeName, string routingKey, IFieldTable args);
+
+ /// <summary>
+ /// Create a new empty message with no body.
+ /// </summary>
+ /// <returns>The new message</returns>
+ IMessage CreateMessage();
+
+ /// <summary>
+ /// Create a new message of the specified MIME type.
+ /// </summary>
+ /// <param name="mimeType">The mime type to create</param>
+ /// <returns>The new message</returns>
+ IMessage CreateMessage(string mimeType);
+
+ /// <summary>
+ /// Creates a new message for bytes (application/octet-stream).
+ /// </summary>
+ /// <returns>The new message</returns>
+ IBytesMessage CreateBytesMessage();
+
+ /// <summary>
+ /// Creates a new text message (text/plain) with empty content.
+ /// </summary>
+ /// <returns>The new message</returns>
+ ITextMessage CreateTextMessage();
+
+ /// <summary>
+ /// Creates a new text message (text/plain) with a body.
+ /// </summary>
+ /// <param name="initialValue">Initial body of the message</param>
+ /// <returns>The new message</returns>
+ ITextMessage CreateTextMessage(string initialValue);
+
+ #region Consuming
+
+ /// <summary>
+ /// Creates a new Consumer using the builder pattern.
+ /// </summary>
+ /// <param name="queueName">Name of queue to receive messages from</param>
+ /// <returns>The builder object</returns>
+ MessageConsumerBuilder CreateConsumerBuilder(string queueName);
+
+ /// <summary>
+ /// Creates a new consumer.
+ /// </summary>
+ /// <param name="queueName">Name of queue to receive messages from</param>
+ /// <param name="prefetchLow">Low prefetch value</param>
+ /// <param name="prefetchHigh">High prefetch value</param>
+ /// <param name="noLocal">If true, messages sent on this channel will not be received by this consumer</param>
+ /// <param name="exclusive">If true, the consumer opens the queue in exclusive mode</param>
+ /// <returns>The new consumer</returns>
+ IMessageConsumer CreateConsumer(string queueName,
+ int prefetchLow,
+ int prefetchHigh,
+ bool noLocal,
+ bool exclusive);
+
+ /// <summary>
+ /// Creates a new consumer.
+ /// </summary>
+ /// <param name="queueName">Name of queue to receive messages from</param>
+ /// <param name="prefetchLow">Low prefetch value</param>
+ /// <param name="prefetchHigh">High prefetch value</param>
+ /// <param name="noLocal">If true, messages sent on this channel will not be received by this consumer</param>
+ /// <param name="exclusive">If true, the consumer opens the queue in exclusive mode</param>
+ /// <param name="browse">If true, the consumer only browses and does not consume</param>
+ /// <returns>The new consumer</returns>
+ IMessageConsumer CreateConsumer(string queueName,
+ int prefetchLow,
+ int prefetchHigh,
+ bool noLocal,
+ bool exclusive,
+ bool browse);
+
+ /// <summary>
+ /// Unsubscribe from a queue.
+ /// </summary>
+ /// <param name="subscriptionName">Subscription name</param>
+ void Unsubscribe(string subscriptionName);
+
+ #endregion
+
+ #region Publishing
+
+ /// <summary>
+ /// Create a new message publisher using the builder pattern.
+ /// </summary>
+ /// <returns>The builder object</returns>
+ MessagePublisherBuilder CreatePublisherBuilder();
+
+ /// <summary>
+ /// Create a new message publisher.
+ /// </summary>
+ /// <param name="exchangeName">Name of exchange to publish to</param>
+ /// <param name="routingKey">Routing key</param>
+ /// <param name="deliveryMode">Default delivery mode</param>
+ /// <param name="timeToLive">Default TTL time of messages</param>
+ /// <param name="immediate">If true, sent immediately</param>
+ /// <param name="mandatory">If true, the broker will return an error
+ /// (as a connection exception) if the message cannot be delivered</param>
+ /// <param name="priority">Default message priority</param>
+ /// <returns>The new message publisher</returns>
+ IMessagePublisher CreatePublisher(string exchangeName,
+ string routingKey,
+ DeliveryMode deliveryMode,
+ long timeToLive,
+ bool immediate,
+ bool mandatory,
+ int priority);
+
+ #endregion
+
+ #region Transactions
+
+ /// <summary>
+ /// Recover after transaction failure.
+ /// </summary>
+ void Recover();
+
+ /// <summary>
+ /// Commit the transaction.
+ /// </summary>
+ void Commit();
+
+ /// <summary>
+ /// Rollback the transaction.
+ /// </summary>
+ void Rollback();
+
+ #endregion
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/ICloseable.cs b/qpid/dotnet/Qpid.Messaging/ICloseable.cs
new file mode 100644
index 0000000000..658a5ed5a4
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/ICloseable.cs
@@ -0,0 +1,38 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+using System;
+
+namespace Apache.Qpid.Messaging
+{
+ /// <summary>An ICloseable is a resource that can be explicitly closed. Generally speaking a closed resource can no longer be used, and the
+ /// act of closing a resource is usually interpreted as a signal that the closed item can have its resource cleaned up and de-allocated.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Close (and clean-up) a resource.
+ /// </table>
+ /// </summary>
+ public interface ICloseable
+ {
+ /// <summary> Close the resource. </summary>
+ void Close();
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IConnection.cs b/qpid/dotnet/Qpid.Messaging/IConnection.cs
new file mode 100644
index 0000000000..f664137e02
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IConnection.cs
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+using System;
+
+namespace Apache.Qpid.Messaging
+{
+ public delegate void ExceptionListenerDelegate(Exception ex);
+
+ public interface IConnection : IDisposable, ICloseable
+ {
+ /// <summary>
+ /// The connection listener that has been registered with this connection.
+ /// </summary>
+ IConnectionListener ConnectionListener
+ {
+ get;
+ set;
+ }
+
+ ExceptionListenerDelegate ExceptionListener { get; set; }
+
+ string ClientID { get; set; }
+
+ /// <return>the maximum number of sessions supported by this Connection</return>
+ int MaximumChannelCount
+ {
+ get;
+ }
+
+ IChannel CreateChannel(bool transacted, AcknowledgeMode acknowledgeMode);
+ IChannel CreateChannel(bool transacted, AcknowledgeMode acknowledgeMode, int prefetch);
+ IChannel CreateChannel(bool transacted, AcknowledgeMode acknowledgeMode, int prefetchHigh, int prefetchLow);
+
+ void Start();
+ void Stop();
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IConnectionFactory.cs b/qpid/dotnet/Qpid.Messaging/IConnectionFactory.cs
new file mode 100644
index 0000000000..f141d509be
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IConnectionFactory.cs
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public interface IConnectionFactory
+ {
+ IConnection CreateConnection();
+ IConnection CreateConnection(string userId, string password);
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IConnectionListener.cs b/qpid/dotnet/Qpid.Messaging/IConnectionListener.cs
new file mode 100644
index 0000000000..02d9eb38da
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IConnectionListener.cs
@@ -0,0 +1,59 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public interface IConnectionListener
+ {
+ /// <summary>
+ /// Called when bytes have been transmitted to the server
+ /// </summary>
+ /// <param>count the number of bytes sent in total since the connection was opened</param>
+ void BytesSent(long count);
+
+ /// <summary>
+ /// Called when some bytes have been received on a connection
+ /// </summary>
+ /// <param>count the number of bytes received in total since the connection was opened</param>
+ void BytesReceived(long count);
+
+ /// <summary>
+ /// Called after the infrastructure has detected that failover is required but before attempting failover.
+ /// </summary>
+ /// <param>redirect true if the broker requested redirect. false if failover is occurring due to a connection error.</param>
+ /// <return>true to continue failing over, false to veto failover and raise a connection exception</return>
+ bool PreFailover(bool redirect);
+
+ /// <summary>
+ /// Called after connection has been made to another broker after failover has been started but before
+ /// any resubscription has been done.
+ /// <return> true to continue with resubscription, false to prevent automatic resubscription. This is useful in
+ /// cases where the application wants to handle resubscription. Note that in the latter case all sessions, producers
+ /// and consumers are invalidated.
+ /// </return
+ bool PreResubscribe();
+
+ /// <summary>
+ /// Called once failover has completed successfully. This is called irrespective of whether the client has
+ /// vetoed automatic resubscription.
+ /// </summary>
+ void FailoverComplete();
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IFieldTable.cs b/qpid/dotnet/Qpid.Messaging/IFieldTable.cs
new file mode 100644
index 0000000000..730ce399d4
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IFieldTable.cs
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+using System.Collections;
+
+namespace Apache.Qpid.Messaging
+{
+ public interface IFieldTable : IEnumerable
+ {
+ int Count { get; }
+
+ object this[string key] { get; set; }
+
+ /// <summary>
+ /// Adds all the items from another field table in this one.
+ /// Will overwrite any items in the current table with the same key.
+ /// </summary>
+ /// <param name="source">the source field table</param>
+ void AddAll(IFieldTable source);
+
+ bool Contains(string s);
+ void Clear();
+ void Remove(string key);
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IHeaders.cs b/qpid/dotnet/Qpid.Messaging/IHeaders.cs
new file mode 100644
index 0000000000..7fdf26ebda
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IHeaders.cs
@@ -0,0 +1,67 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ /// <summary>
+ /// IHeaders represents the header fields of an AMQ message and provides methods to access those fields. There are accessor methods to
+ /// get and set each header field for each supported header field data type.
+ ///
+ /// <para/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th>Responsibilities</th></tr>
+ /// <tr><td>Provide accessors for all supported header field types.</td></tr>
+ /// <tr><td>Check if a set of headers contains a named property.</td></tr>
+ /// </table>
+ ///
+ /// </summary>
+ public interface IHeaders
+ {
+ bool Contains(string name);
+
+ object this[string name] { get; set; }
+
+ bool GetBoolean(string name);
+ void SetBoolean(string name, bool value);
+
+ byte GetByte(string name);
+ void SetByte(string name, byte value);
+
+ //sbyte GetSByte(string name);
+ //void SetSByte(string name, sbyte value);
+
+ short GetShort(string name);
+ void SetShort(string name, short value);
+
+ int GetInt(string name);
+ void SetInt(string name, int value);
+
+ long GetLong(string name);
+ void SetLong(string name, long value);
+
+ float GetFloat(string name);
+ void SetFloat(string name, float value);
+
+ double GetDouble(string name);
+ void SetDouble(string name, double value);
+
+ string GetString(string name);
+ void SetString(string name, string value);
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IMessage.cs b/qpid/dotnet/Qpid.Messaging/IMessage.cs
new file mode 100644
index 0000000000..20ae5ee130
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IMessage.cs
@@ -0,0 +1,97 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public interface IMessage
+ {
+ /// <summary>
+ /// The MIME Content Type
+ /// </summary>
+ string ContentType { get; set;}
+ /// <summary>
+ /// The MIME Content Encoding
+ /// </summary>
+ string ContentEncoding { get; set; }
+ /// <summary>
+ /// The application correlation identifier
+ /// </summary>
+ string CorrelationId { get; set; }
+ /// <summary>
+ /// The application correlation identifier, as an array of bytes
+ /// </summary>
+ byte[] CorrelationIdAsBytes { get; set; }
+ /// <summary>
+ /// Non-persistent (1) or persistent (2)
+ /// </summary>
+ DeliveryMode DeliveryMode { get; set; }
+ /// <summary>
+ /// Message expiration specification
+ /// </summary>
+ long Expiration { get; set; }
+ /// <summary>
+ /// The application message identifier
+ /// </summary>
+ string MessageId { get; set; }
+ /// <summary>
+ /// The message priority, 0 to 9
+ /// </summary>
+ byte Priority { get; set; }
+ /// <summary>
+ /// True if the message has been redelivered
+ /// </summary>
+ bool Redelivered { get; set; }
+ /// <summary>
+ /// Exchange name of the reply-to address
+ /// </summary>
+ string ReplyToExchangeName { get; set; }
+ /// <summary>
+ /// Routing key of the reply-to address
+ /// </summary>
+ string ReplyToRoutingKey { get; set; }
+ /// <summary>
+ /// The message timestamp
+ /// </summary>
+ long Timestamp { get; set; }
+ /// <summary>
+ /// The message type name
+ /// </summary>
+ string Type { get; set; }
+ /// <summary>
+ /// Message headers
+ /// </summary>
+ IHeaders Headers { get; }
+ /// <summary>
+ /// The creating user id
+ /// </summary>
+ string UserId { get; set; }
+ /// <summary>
+ /// The creating application id
+ /// </summary>
+ string AppId { get; set; }
+ /// <summary>
+ /// Intra-cluster routing identifier
+ /// </summary>
+ string ClusterId { get; set; }
+
+ void Acknowledge();
+ void ClearBody();
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IMessageConsumer.cs b/qpid/dotnet/Qpid.Messaging/IMessageConsumer.cs
new file mode 100644
index 0000000000..86b5405707
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IMessageConsumer.cs
@@ -0,0 +1,79 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+using System;
+
+namespace Apache.Qpid.Messaging
+{
+ /// <summary>
+ /// Describes an object that can be used to receive (consume)
+ /// messages from an AMQP queue.
+ /// </summary>
+ /// <remarks>
+ /// Consumers are created using either
+ /// <see cref="IChannel.CreateConsumer"/> or using
+ /// the builder pattern (preferred) with
+ /// <see cref="IChannel.CreateConsumerBuilder"/>.
+ ///
+ /// <para>
+ /// Consumers offer two different ways of receiving messages:
+ /// You can attach a delegate to the <see cref="OnMessage"/>
+ /// event and be notified when a message arrives, or you can
+ /// use the <see cref="Receive"/> and <see cref="ReceiveNoWait"/>
+ /// methods to control when you receive messages. Be aware that you can use
+ /// one or the other, but not both at the same time.
+ /// </para>
+ /// <para>
+ /// Regardless of which method you choose, the prefetch settings
+ /// specified when creating the channel will still control when messages
+ /// are actually received from the AMQP broker. Any messages that arrive
+ /// between the prefetch window will be queued by the channel
+ /// until they can be delivered to the consumer (either though the event
+ /// or until the consumer actively calls <see cref="Receive"/>).
+ /// </para>
+ /// </remarks>
+ public interface IMessageConsumer : IDisposable, ICloseable
+ {
+ /// <summary>
+ /// Fired when a message is received from the broker by the consumer
+ /// </summary>
+ MessageReceivedDelegate OnMessage { get; set; }
+
+ /// <summary>
+ /// Wait infinitely for a message to be received from the broker
+ /// </summary>
+ /// <returns>The message received</returns>
+ IMessage Receive();
+
+ /// <summary>
+ /// Wait the specified time until a message is receive from the broker
+ /// </summary>
+ /// <param name="delay">Maximum number of milliseconds to wait for a message</param>
+ /// <returns>The message received, or null if the timeout expires</returns>
+ IMessage Receive(long delay);
+
+ /// <summary>
+ /// Return a message if one is already available in the channel.
+ /// Does not wait for one to be received from the broker.
+ /// </summary>
+ /// <returns>The message, if it was available, otherwise null</returns>
+ IMessage ReceiveNoWait();
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/IMessagePublisher.cs b/qpid/dotnet/Qpid.Messaging/IMessagePublisher.cs
new file mode 100644
index 0000000000..d895a9749b
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/IMessagePublisher.cs
@@ -0,0 +1,92 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+using System;
+
+namespace Apache.Qpid.Messaging
+{
+ /// <summary>
+ /// Defines an object capable of publishing messages
+ /// to an AMQP broker.
+ /// </summary>
+ /// <remarks>
+ /// A publisher can be created using either
+ /// <see cref="IChannel.CreatePublisher"/> or
+ /// using the builder pattern (preferred) with
+ /// <see cref="IChannel.CreatePublisherBuilder"/>
+ /// </remarks>
+ public interface IMessagePublisher : IDisposable, ICloseable
+ {
+ /// <summary>
+ /// Default delivery mode to use with this publisher
+ /// </summary>
+ DeliveryMode DeliveryMode { get; set; }
+ /// <summary>
+ /// Name of exchange messages are published to
+ /// </summary>
+ string ExchangeName { get; }
+ /// <summary>
+ /// Routing key used when publishing messages
+ /// </summary>
+ string RoutingKey { get; }
+ /// <summary>
+ /// If true, a message ID will not be generated by the publisher
+ /// when sending the message
+ /// </summary>
+ bool DisableMessageID { get; set; }
+ /// <summary>
+ /// If true, no timestamp will be added to the message
+ /// when publishing it
+ /// </summary>
+ bool DisableMessageTimestamp { get; set; }
+ /// <summary>
+ /// Default priority used when publishing messages
+ /// </summary>
+ int Priority { get; set; }
+ /// <summary>
+ /// Default time to live used when publishing messages
+ /// </summary>
+ long TimeToLive { get; set; }
+ /// <summary>
+ /// Set the default MIME type for messages produced by this producer.
+ /// This reduces the overhead of each message.
+ /// </summary>
+ string MimeType { get; set; }
+ /// <summary>
+ /// Set the default encoding for messages produced by this producer.
+ /// This reduces the overhead of each message.
+ /// </summary>
+ string Encoding { get; set; }
+
+ /// <summary>
+ /// Publish a message, using any default values configured
+ /// </summary>
+ /// <param name="msg">Message to publish</param>
+ void Send(IMessage msg);
+ /// <summary>
+ /// Publish a message with the specified options
+ /// </summary>
+ /// <param name="msg">Message to publish</param>
+ /// <param name="deliveryMode">Delivery mode to use</param>
+ /// <param name="priority">Priority of the message</param>
+ /// <param name="timeToLive">Time to live of the message</param>
+ void Send(IMessage msg, DeliveryMode deliveryMode, int priority, long timeToLive);
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/ITextMessage.cs b/qpid/dotnet/Qpid.Messaging/ITextMessage.cs
new file mode 100644
index 0000000000..902beb70f8
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/ITextMessage.cs
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public interface ITextMessage : IMessage
+ {
+ string Text { get; set; }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/MessageConsumerBuilder.cs b/qpid/dotnet/Qpid.Messaging/MessageConsumerBuilder.cs
new file mode 100644
index 0000000000..91a2371788
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/MessageConsumerBuilder.cs
@@ -0,0 +1,113 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ /// <summary>
+ /// MessageConsumerBuilder provides a builder with a fluent interface to assist with creating message consumers on a channel.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Create message consumers from consume parameters. <td> <see cref="IChannel">
+ /// </table>
+ /// </summary>
+ ///
+ /// <remarks>It may be better to replace the Create method with a DeclareBindAndCreate method, that declares and binds the consumers queue,
+ /// as well as creating the consumer. This is a common use case, so the method will generally be usefull. Need to consider situations where
+ /// the declare and bind is not to be done, for example when resubscribing to a durable subscription. There may be others too.</remarks>
+ public class MessageConsumerBuilder
+ {
+ private bool _noLocal = false;
+
+ private bool _exclusive = false;
+
+ private bool _browse = false;
+
+ //private bool _durable = false;
+ //private string _subscriptionName = null;
+
+ private IChannel _channel;
+
+ private readonly string _queueName;
+
+ private int _prefetchLow;
+
+ private int _prefetchHigh;
+
+ public MessageConsumerBuilder(IChannel channel, string queueName)
+ {
+ _channel = channel;
+ _queueName = queueName;
+ _prefetchHigh = _channel.DefaultPrefetchHigh;
+ _prefetchLow = _channel.DefaultPrefetchLow;
+ }
+
+ public MessageConsumerBuilder WithPrefetchLow(int prefetchLow)
+ {
+ _prefetchLow = prefetchLow;
+ return this;
+ }
+
+ public MessageConsumerBuilder WithPrefetchHigh(int prefetchHigh)
+ {
+ _prefetchHigh = prefetchHigh;
+ return this;
+ }
+
+ public MessageConsumerBuilder WithNoLocal(bool noLocal)
+ {
+ _noLocal = noLocal;
+ return this;
+ }
+
+ public MessageConsumerBuilder WithExclusive(bool exclusive)
+ {
+ _exclusive = exclusive;
+ return this;
+ }
+
+ public MessageConsumerBuilder WithBrowse(bool browse)
+ {
+ _browse = browse;
+ return this;
+ }
+
+ /*
+ public MessageConsumerBuilder WithDurable(bool durable)
+ {
+ _durable = durable;
+ return this;
+ }
+ */
+
+ /*
+ public MessageConsumerBuilder WithSubscriptionName(string subscriptionName)
+ {
+ _subscriptionName = subscriptionName;
+ return this;
+ }
+ */
+
+ public IMessageConsumer Create()
+ {
+ return _channel.CreateConsumer(_queueName, _prefetchLow, _prefetchHigh, _noLocal, _exclusive, _browse);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/MessageNotReadableException.cs b/qpid/dotnet/Qpid.Messaging/MessageNotReadableException.cs
new file mode 100644
index 0000000000..2afcffd531
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/MessageNotReadableException.cs
@@ -0,0 +1,39 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
+using System;
+using System.Runtime.Serialization;
+
+namespace Apache.Qpid.Messaging
+{
+ [Serializable]
+ public class MessageNotReadableException : QpidException
+ {
+ public MessageNotReadableException(string reason) : base(reason)
+ {
+ }
+
+ protected MessageNotReadableException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/MessageNotWritableException.cs b/qpid/dotnet/Qpid.Messaging/MessageNotWritableException.cs
new file mode 100644
index 0000000000..9b00f01948
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/MessageNotWritableException.cs
@@ -0,0 +1,38 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+using System;
+using System.Runtime.Serialization;
+
+namespace Apache.Qpid.Messaging
+{
+ [Serializable]
+ public class MessageNotWriteableException : QpidException
+ {
+ public MessageNotWriteableException(string reason) : base(reason)
+ {
+ }
+
+ protected MessageNotWriteableException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/MessagePublisherBuilder.cs b/qpid/dotnet/Qpid.Messaging/MessagePublisherBuilder.cs
new file mode 100644
index 0000000000..79c7575d0a
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/MessagePublisherBuilder.cs
@@ -0,0 +1,91 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+namespace Apache.Qpid.Messaging
+{
+ public class MessagePublisherBuilder
+ {
+ /// <summary>
+ /// Default value for immediate flag is false, i.e. a consumer does not need to be attached to a queue
+ /// </summary>
+ const bool DEFAULT_IMMEDIATE = false;
+
+ /// <summary>
+ /// Default value for mandatory flag is true, i.e. server will not silently drop messages where no queue is
+ /// connected to the exchange for the message
+ /// </summary>
+ const bool DEFAULT_MANDATORY = true;
+
+ IChannel _channel;
+ string _exchangeName = null;
+ string _routingKey = null;
+ DeliveryMode _deliveryMode = DeliveryMode.Persistent;
+ long _timeToLive;
+ bool _immediate = DEFAULT_IMMEDIATE;
+ bool _mandatory = DEFAULT_MANDATORY;
+ int _priority = 0;
+
+ public MessagePublisherBuilder(IChannel channel)
+ {
+ _channel = channel;
+ }
+
+ public MessagePublisherBuilder WithRoutingKey(string routingKey)
+ {
+ _routingKey = routingKey;
+ return this;
+ }
+
+ public MessagePublisherBuilder WithExchangeName(string exchangeName)
+ {
+ _exchangeName = exchangeName;
+ return this;
+ }
+
+ public MessagePublisherBuilder WithDeliveryMode(DeliveryMode deliveryMode)
+ {
+ _deliveryMode = deliveryMode;
+ return this;
+ }
+
+ public MessagePublisherBuilder WithTimeToLive(long timeToLive)
+ {
+ _timeToLive = timeToLive;
+ return this;
+ }
+
+ public MessagePublisherBuilder WithImmediate(bool immediate)
+ {
+ _immediate = immediate;
+ return this;
+ }
+
+ public MessagePublisherBuilder WithMandatory(bool mandatory)
+ {
+ _mandatory = mandatory;
+ return this;
+ }
+
+ public IMessagePublisher Create()
+ {
+ return _channel.CreatePublisher(_exchangeName, _routingKey, _deliveryMode, _timeToLive, _immediate, _mandatory, _priority);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/Properties/AssemblyInfo.cs b/qpid/dotnet/Qpid.Messaging/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..d9dff07f3f
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/Properties/AssemblyInfo.cs
@@ -0,0 +1,56 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Apache.Qpid.Messaging")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache.Qpid.Messaging")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("e74f1805-b355-42e0-ba70-afc7c8570f03")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("0.5.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+
+[assembly: CLSCompliant(true)]
diff --git a/qpid/dotnet/Qpid.Messaging/Qpid.Messaging.csproj b/qpid/dotnet/Qpid.Messaging/Qpid.Messaging.csproj
new file mode 100644
index 0000000000..37b80d1515
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/Qpid.Messaging.csproj
@@ -0,0 +1,115 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+
+-->
+
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{6688F826-C58E-4C1B-AA1F-22AFAB4B7D07}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Qpid.Messaging</RootNamespace>
+ <AssemblyName>Apache.Qpid.Messaging</AssemblyName>
+ <SignAssembly>true</SignAssembly>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>2.0</OldToolsVersion>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <PublishUrl>http://localhost/Apache.Qpid.Messaging/</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Web</InstallFrom>
+ <UpdateEnabled>true</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>true</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\bin\net-2.0\debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>..\bin\net-2.0\release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="**\*.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/qpid/dotnet/Qpid.Messaging/QpidException.cs b/qpid/dotnet/Qpid.Messaging/QpidException.cs
new file mode 100644
index 0000000000..3e39f2293d
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/QpidException.cs
@@ -0,0 +1,43 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+using System;
+using System.Runtime.Serialization;
+
+namespace Apache.Qpid.Messaging
+{
+ [Serializable]
+ public class QpidException : Exception
+ {
+ public QpidException(string reason) : base(reason)
+ {
+ }
+
+ public QpidException(string reason, Exception e)
+ : base(reason, e)
+ {
+ }
+
+ protected QpidException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/ResourceAllocationException.cs b/qpid/dotnet/Qpid.Messaging/ResourceAllocationException.cs
new file mode 100644
index 0000000000..954dcdd94c
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/ResourceAllocationException.cs
@@ -0,0 +1,39 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
+using System;
+using System.Runtime.Serialization;
+
+namespace Apache.Qpid.Messaging
+{
+ [Serializable]
+ public class ResourceAllocationException : QpidException
+ {
+ public ResourceAllocationException(string reason) : base(reason)
+ {
+ }
+
+ protected ResourceAllocationException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/default.build b/qpid/dotnet/Qpid.Messaging/default.build
new file mode 100644
index 0000000000..e351def886
--- /dev/null
+++ b/qpid/dotnet/Qpid.Messaging/default.build
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+
+-->
+
+<project name="Apache.Qpid.Messaging" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="library"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.dll">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ </references>
+ </csc>
+ </target>
+</project>
+