Compare commits

...
Author SHA1 Message Date
Atsushi Eno 41ca39c136 oops, forgot to apply the patch here in bug #457089 by Michael Barker.
svn path=/branches/messaging-2008/mcs/; revision=120980
2008-12-08 07:06:43 +00:00
Atsushi Eno 56f2a5eee8 Apply RabbitMQ support patch by Michael Barker, on bug #457089.
svn path=/branches/messaging-2008/mcs/; revision=120957
2008-12-07 09:55:03 +00:00
Atsushi Eno 571a0e148c 2008-10-27 Atsushi Enomoto <[email protected]>
Patch by Michael Barker:
	a patch that adds support for passing all of the Message
	properties via RabbitMQ (as per version 1.1 of System.Messaging).
	This includes Recoverable (supporting persistence) and Priority (which
	would support priority based delivery if RabbitMQ supported it) as
	well as state and argument checking.


svn path=/branches/messaging-2008/mcs/; revision=117134
2008-10-27 10:10:13 +00:00
Atsushi Eno 6abd64b916 add missing files (see bug #432471).
svn path=/branches/messaging-2008/mcs/; revision=116496
2008-10-20 08:06:16 +00:00
Atsushi Eno 7b8ca08adf import AMQP/Rabbit based implementation by Michael Barker (see r116493).
svn path=/branches/messaging-2008/mcs/; revision=116494
2008-10-20 07:49:40 +00:00
Atsushi Eno 7966931ae7 import RabbitMQ.Client (see bug #432471 and
http://lists.ximian.com/pipermail/mono-devel-list/2008-October/029498.html).


svn path=/branches/messaging-2008/mcs/; revision=116493
2008-10-20 07:31:10 +00:00
234 changed files with 68029 additions and 1623 deletions

No files matched your search

+3
View File
@@ -77,7 +77,10 @@ common_dirs := \
Novell.Directory.Ldap \
Mono.Security.Win32 \
System.DirectoryServices \
Mono.Messaging \
System.Messaging \
RabbitMQ.Client \
Mono.Messaging.RabbitMQ \
System.ServiceProcess \
System.Drawing.Design \
System.Design \
@@ -0,0 +1,71 @@
//
// AssemblyInfo.cs
//
// Author:
// Andreas Nahr ([email protected])
//
// (C) 2003 Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Resources;
using System.Security;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about the System.Messaging assembly
[assembly: AssemblyTitle ("Mono.Messaging.RabbitMQ.dll")]
[assembly: AssemblyDescription ("Mono.Messaging.RabbitMQ.dll")]
[assembly: AssemblyDefaultAlias ("Mono.Messaging.RabbitMQ.dll")]
[assembly: AssemblyCompany (Consts.MonoCompany)]
[assembly: AssemblyProduct (Consts.MonoProduct)]
[assembly: AssemblyCopyright (Consts.MonoCopyright)]
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: SatelliteContractVersion (Consts.FxVersion)]
[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: ComVisible (false)]
[assembly: CLSCompliant (true)]
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile("../msfinal.pub")]
#if NET_2_0
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
[assembly: Debuggable (DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility (WrapNonExceptionThrows = true)]
#elif NET_1_1
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyConfiguration ("")]
#elif NET_1_0
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyConfiguration ("")]
#endif
@@ -0,0 +1,3 @@
2008-09-29 Michael Barker <[email protected]>
* AssemblyInfo.cs: New
@@ -0,0 +1,13 @@
thisdir = class/Mono.Messaging.RabbitMQ
SUBDIRS =
include ../../build/rules.make
LIBRARY = Mono.Messaging.RabbitMQ.dll
LIB_MCS_FLAGS = /r:System.dll \
/r:System.Messaging.dll \
/r:Mono.Messaging.dll \
/r:RabbitMQ.Client
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169
include ../../build/library.make
@@ -0,0 +1,9 @@
./Assembly/AssemblyInfo.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
./Mono.Messaging.RabbitMQ/MessageFactory.cs
./Mono.Messaging.RabbitMQ/RabbitMQMessageEnumerator.cs
./Mono.Messaging.RabbitMQ/RabbitMQMessageQueue.cs
./Mono.Messaging.RabbitMQ/RabbitMQMessageQueueTransaction.cs
./Mono.Messaging.RabbitMQ/RabbitMQMessagingProvider.cs
@@ -0,0 +1,41 @@
2008-12-07 Michael Barker <[email protected]>
* RabbitMQMessageQueue.cs: Throw MessageUnavailableException when there are
no messages.
2008-11-23 Michael Barker <[email protected]>
* RabbitMQMessageQueue.cs: Added selector support for ReceiveBy{Id,CorrelationId}
and support for MessageQueueTransactionType, currently only None and Single
are supported. Added PeekBy{Id,CorrelationId} methods.
* MessageFactory.cs: Made read/write message methods non-static and requires
the MessagingProvider as a constructor parameter.
2008-11-02 Michael Barker <[email protected]>
* RabbitMQMessageQueueTransaction.cs: New, Handles transactional delivery
by maintaining the transaction context.
* RabbitMQMessageQueue.cs: Added support for transactions, purging, deleting
and refactored some of the methods to improve the code reuse.
* RabbitMQMessagingProvider.cs: Added methods for queue deletion and
creating transactions.
2008-10-26 Michael Barker <[email protected]>
* MessageFactory.cs: Support all properties defined in the 1.1 version of
System.Messaging, including Recoverable and Priority. Changed Timestamp
conversion methods to support .NET 1.1 compilation.
* RabbitMQMessageQueue.cs: Removed unnecessary constants.
2008-10-12 Michael Barker <[email protected]>
* RabbitMQMessageEnumerator.cs: New
* MessageFactory.cs: Utility class for creating MessageBase objects from
serialized data off the queue.
* RabbitMQMessageQueue.cs: Using MessageFactory methods to handle message
serialization.
2008-09-29 Michael Barker <[email protected]>
* RabbitMQMessageQueue.cs: New
* RabbitMQMessagingProvider.cs: New
@@ -0,0 +1,224 @@
//
// Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.IO;
using System.Text;
using Mono.Messaging;
using RabbitMQ.Client;
using RabbitMQ.Client.Content;
using RabbitMQ.Client.Events;
using RabbitMQ.Client.Exceptions;
using RabbitMQ.Client.MessagePatterns;
using RabbitMQ.Util;
namespace Mono.Messaging.RabbitMQ {
public class MessageFactory {
private static readonly string SENDER_VERSION_KEY = "SenderVersion";
private static readonly string SOURCE_MACHINE_KEY = "SourceMachine";
private static readonly string BODY_TYPE_KEY = "BodyType";
private static readonly string ACKNOWLEDGE_TYPE_KEY = "AcknowledgeType";
private static readonly string ADMINISTRATION_QUEUE_KEY = "AdministrationQueue";
private static readonly string APP_SPECIFIC_KEY = "AppSpecific";
private static readonly string AUTHENTICATION_PROVIDER_NAME_KEY = "AuthenticationProviderName";
private static readonly string AUTHENTICATION_PROVIDER_TYPE_KEY = "AuthenticationProviderType";
private static readonly string CONNECTOR_TYPE_KEY = "ConnectorType";
private static readonly string DESTINATION_SYMMETRIC_KEY_KEY = "DestinationSymmetricKey";
private static readonly string DIGITAL_SIGNATURE_KEY = "DigitalSignature";
private static readonly string ENCRYPTION_ALGORITHM_KEY = "EncryptionAlgorithm";
private static readonly string EXTENSION_KEY = "Extension";
private static readonly string HASH_ALGORITHM_KEY = "HashAlgorithm";
private static readonly string LABEL_KEY = "Label";
private static readonly string SENDER_CERTIFICATE_KEY = "SenderCertificate";
private static readonly string TIME_TO_BE_RECEIVED_KEY = "TimeToBeReceived";
private static readonly string TIME_TO_REACH_QUEUE_KEY = "TimeToReachQueue";
private static readonly string USE_AUTHENTICATION_KEY = "UseAuthentication";
private static readonly string USE_DEAD_LETTER_QUEUE_KEY = "UseDeadLetterQueue";
private static readonly string USE_ENCRYPTION_KEY = "UseEncryption";
private static readonly string TRANSACTION_ID_KEY = "TrandactionId";
private static readonly int PERSISTENT_DELIVERY_MODE = 2;
private readonly RabbitMQMessagingProvider provider;
public MessageFactory (RabbitMQMessagingProvider provider)
{
this.provider = provider;
}
public IMessageBuilder WriteMessage (IModel ch, IMessage msg)
{
BasicMessageBuilder mb = new BasicMessageBuilder (ch);
mb.Properties.MessageId = msg.Id;
if (msg.CorrelationId != null)
mb.Properties.CorrelationId = msg.CorrelationId;
// TODO: Change to DateTime.UtcNow??
mb.Properties.Timestamp = MessageFactory.DateTimeToAmqpTimestamp (DateTime.Now);
Hashtable headers = new Hashtable ();
headers[SENDER_VERSION_KEY] = msg.SenderVersion;
headers[SOURCE_MACHINE_KEY] = (string) System.Environment.MachineName;
headers[BODY_TYPE_KEY] = msg.BodyType;
headers[ACKNOWLEDGE_TYPE_KEY] = (int) msg.AcknowledgeType;
if (msg.AdministrationQueue != null)
headers[ADMINISTRATION_QUEUE_KEY] = msg.AdministrationQueue.QRef.ToString ();
headers[APP_SPECIFIC_KEY] = msg.AppSpecific;
headers[AUTHENTICATION_PROVIDER_NAME_KEY] = msg.AuthenticationProviderName;
headers[AUTHENTICATION_PROVIDER_TYPE_KEY] = (int) msg.AuthenticationProviderType;
headers[CONNECTOR_TYPE_KEY] = msg.ConnectorType.ToString ();
headers[DESTINATION_SYMMETRIC_KEY_KEY] = msg.DestinationSymmetricKey;
headers[DIGITAL_SIGNATURE_KEY] = msg.DigitalSignature;
headers[ENCRYPTION_ALGORITHM_KEY] = (int) msg.EncryptionAlgorithm;
headers[EXTENSION_KEY] = msg.Extension;
headers[HASH_ALGORITHM_KEY] = (int) msg.HashAlgorithm;
SetValue (headers, LABEL_KEY, msg.Label);
mb.Properties.Priority = (byte) (int) msg.Priority;
mb.Properties.SetPersistent (msg.Recoverable);
if (msg.ResponseQueue != null)
mb.Properties.ReplyTo = msg.ResponseQueue.QRef.ToString ();
headers[SENDER_CERTIFICATE_KEY] = msg.SenderCertificate;
headers[TIME_TO_BE_RECEIVED_KEY] = msg.TimeToBeReceived.Ticks;
headers[TIME_TO_REACH_QUEUE_KEY] = msg.TimeToReachQueue.Ticks;
SetValue (headers, TRANSACTION_ID_KEY, msg.TransactionId);
headers[USE_AUTHENTICATION_KEY] = msg.UseAuthentication;
headers[USE_DEAD_LETTER_QUEUE_KEY] = msg.UseDeadLetterQueue;
headers[USE_ENCRYPTION_KEY] = msg.UseEncryption;
mb.Properties.Headers = headers;
Stream s = msg.BodyStream;
s.Seek (0, SeekOrigin.Begin);
byte[] buf = new byte[s.Length];
msg.BodyStream.Read (buf, 0, buf.Length);
mb.BodyStream.Write (buf, 0, buf.Length);
return mb;
}
private static void SetValue (Hashtable headers, string name, object val)
{
if (val != null)
headers[name] = val;
}
public IMessage ReadMessage (QueueReference destination, BasicDeliverEventArgs result)
{
/*
if (destination == null)
throw new ArgumentException ("destination must not be null");
if (result == null)
throw new ArgumentException ("result must not be null");
*/
MessageBase msg = new MessageBase ();
Stream s = new MemoryStream ();
s.Write (result.Body, 0, result.Body.Length);
DateTime arrivedTime = DateTime.Now;
IDictionary headers = result.BasicProperties.Headers;
long senderVersion = (long) headers[SENDER_VERSION_KEY];
string sourceMachine = GetString (headers, SOURCE_MACHINE_KEY);
DateTime sentTime = AmqpTimestampToDateTime (result.BasicProperties.Timestamp);
string transactionId = GetString (headers, TRANSACTION_ID_KEY);
msg.SetDeliveryInfo (Acknowledgment.None,
arrivedTime,
new RabbitMQMessageQueue (provider,
destination,
true),
result.BasicProperties.MessageId,
MessageType.Normal,
new byte[0],
senderVersion,
sentTime,
sourceMachine,
transactionId);
msg.CorrelationId = result.BasicProperties.CorrelationId;
msg.BodyStream = s;
msg.BodyType = (int) result.BasicProperties.Headers[BODY_TYPE_KEY];
msg.AcknowledgeType = (AcknowledgeTypes)
Enum.ToObject (typeof (AcknowledgeTypes),
headers[ACKNOWLEDGE_TYPE_KEY]);
string adminQueuePath = GetString (headers, ADMINISTRATION_QUEUE_KEY);
if (adminQueuePath != null) {
QueueReference qRef = QueueReference.Parse (adminQueuePath);
msg.AdministrationQueue = new RabbitMQMessageQueue (provider,
qRef,
true);
}
msg.AppSpecific = (int) headers[APP_SPECIFIC_KEY];
msg.AuthenticationProviderName = GetString (headers, AUTHENTICATION_PROVIDER_NAME_KEY);
msg.AuthenticationProviderType = (CryptographicProviderType) Enum.ToObject (typeof (CryptographicProviderType), headers[AUTHENTICATION_PROVIDER_TYPE_KEY]);
string connectorType = GetString (headers, CONNECTOR_TYPE_KEY);
msg.ConnectorType = new Guid(connectorType);
msg.DestinationSymmetricKey = (byte[]) headers[DESTINATION_SYMMETRIC_KEY_KEY];
msg.DigitalSignature = (byte[]) headers[DIGITAL_SIGNATURE_KEY];
msg.EncryptionAlgorithm = (EncryptionAlgorithm) Enum.ToObject (typeof (EncryptionAlgorithm), headers[ENCRYPTION_ALGORITHM_KEY]);
msg.Extension = (byte[]) headers[EXTENSION_KEY];
msg.HashAlgorithm = (HashAlgorithm) Enum.ToObject (typeof (HashAlgorithm), headers[HASH_ALGORITHM_KEY]);
msg.Label = GetString (headers, LABEL_KEY);
msg.Priority = (MessagePriority) Enum.ToObject (typeof (MessagePriority), result.BasicProperties.Priority);
msg.Recoverable = result.BasicProperties.DeliveryMode == PERSISTENT_DELIVERY_MODE;
if (result.BasicProperties.ReplyTo != null)
msg.ResponseQueue = new RabbitMQMessageQueue (provider, QueueReference.Parse (result.BasicProperties.ReplyTo), true);
msg.SenderCertificate = (byte[]) headers[SENDER_CERTIFICATE_KEY];
msg.TimeToBeReceived = new TimeSpan((long) headers[TIME_TO_BE_RECEIVED_KEY]);
msg.TimeToReachQueue = new TimeSpan((long) headers[TIME_TO_REACH_QUEUE_KEY]);
msg.UseAuthentication = (bool) headers[USE_AUTHENTICATION_KEY];
msg.UseDeadLetterQueue = (bool) headers[USE_DEAD_LETTER_QUEUE_KEY];
msg.UseEncryption = (bool) headers[USE_ENCRYPTION_KEY];
return msg;
}
public static string GetString (IDictionary properties, String key)
{
byte[] b = (byte[]) properties[key];
if (b == null)
return null;
return Encoding.UTF8.GetString (b);
}
public static AmqpTimestamp DateTimeToAmqpTimestamp (DateTime t)
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0);
TimeSpan ts = t.ToUniversalTime () - epoch;
return new AmqpTimestamp((long) ts.TotalSeconds);
}
public static DateTime AmqpTimestampToDateTime (AmqpTimestamp ats)
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return epoch.AddSeconds (ats.UnixTime).ToLocalTime ();
}
}
}
@@ -0,0 +1,162 @@
//
// Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Mono.Messaging;
using RabbitMQ.Client;
using RabbitMQ.Client.Content;
using RabbitMQ.Client.Events;
using RabbitMQ.Client.Exceptions;
using RabbitMQ.Client.MessagePatterns;
using RabbitMQ.Util;
namespace Mono.Messaging.RabbitMQ {
public class RabbitMQMessageEnumerator : IMessageEnumerator {
private readonly MessageFactory helper;
private readonly QueueReference qRef;
private IConnection cn = null;
private BasicDeliverEventArgs current = null;
private IModel model = null;
private Subscription subscription = null;
public RabbitMQMessageEnumerator (MessageFactory helper,
QueueReference qRef) {
this.helper = helper;
this.qRef = qRef;
}
public IMessage Current {
get {
if (current == null)
throw new InvalidOperationException ();
return CreateMessage (current);
}
}
public void Close ()
{
if (subscription != null) {
subscription.Close ();
subscription = null;
}
if (model != null) {
model.Dispose ();
model = null;
}
if (cn != null) {
cn.Dispose ();
cn = null;
}
}
public void Dispose (bool disposing)
{
}
public void Dispose ()
{
Close ();
}
public void Reset ()
{
Close ();
}
private IModel Model {
get {
if (cn == null) {
ConnectionFactory cf = new ConnectionFactory ();
cn = cf.CreateConnection (qRef.Host);
}
if (model == null) {
model = cn.CreateModel ();
}
return model;
}
}
private Subscription Subscription {
get {
if (subscription == null) {
IModel ch = Model;
ushort ticket = ch.AccessRequest ("/data");
string finalName = ch.QueueDeclare (ticket, qRef.Queue, false);
subscription = new Subscription (ch, ticket, finalName);
}
return subscription;
}
}
public bool MoveNext ()
{
Subscription sub = Subscription;
return sub.Next (500, out current);
}
public IMessage RemoveCurrent ()
{
if (current == null)
throw new InvalidOperationException ();
IMessage msg = CreateMessage (current);
Subscription.Ack (current);
return msg;
}
public IMessage RemoveCurrent (IMessageQueueTransaction transaction)
{
throw new NotSupportedException ("Unable to remove messages within a transaction");
}
public IMessage RemoveCurrent (MessageQueueTransactionType transactionType)
{
throw new NotSupportedException ("Unable to remove messages within a transaction");
}
private IMessage CreateMessage (BasicDeliverEventArgs result)
{
return helper.ReadMessage (qRef, result);
}
}
}
@@ -0,0 +1,752 @@
//
// Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Text;
using RabbitMQ.Client;
using RabbitMQ.Client.Content;
using RabbitMQ.Client.Events;
using RabbitMQ.Client.Exceptions;
using RabbitMQ.Client.MessagePatterns;
using RabbitMQ.Util;
namespace Mono.Messaging.RabbitMQ {
public class RabbitMQMessageQueue : IMessageQueue {
private bool authenticate = false;
private short basePriority = 0;
private Guid category = Guid.Empty;
private bool denySharedReceive = false;
private EncryptionRequired encryptionRequired;
private long maximumJournalSize = -1;
private long maximumQueueSize = -1;
private ISynchronizeInvoke synchronizingObject = null;
private bool useJournalQueue = false;
private QueueReference qRef = QueueReference.DEFAULT;
private readonly RabbitMQMessagingProvider provider;
private readonly MessageFactory helper;
private readonly string realm;
private readonly bool transactional;
public RabbitMQMessageQueue (RabbitMQMessagingProvider provider,
bool transactional)
: this (provider, QueueReference.DEFAULT, transactional)
{
}
public RabbitMQMessageQueue (RabbitMQMessagingProvider provider,
QueueReference qRef,
bool transactional)
: this (provider, "/data", qRef, transactional)
{
}
public RabbitMQMessageQueue (RabbitMQMessagingProvider provider,
string realm, QueueReference qRef,
bool transactional)
{
this.provider = provider;
this.helper = new MessageFactory (provider);
this.realm = realm;
this.qRef = qRef;
this.transactional = transactional;
}
public bool Authenticate {
get { return authenticate; }
set { authenticate = value; }
}
public short BasePriority {
get { return basePriority; }
set { basePriority = value; }
}
public bool CanRead {
get { throw new NotImplementedException (); }
}
public bool CanWrite {
get { throw new NotImplementedException (); }
}
public Guid Category {
get { return category; }
set { category = value; }
}
public DateTime CreateTime {
get { throw new NotImplementedException (); }
}
public bool DenySharedReceive {
get { return denySharedReceive; }
set { denySharedReceive = value; }
}
public EncryptionRequired EncryptionRequired {
get { return encryptionRequired; }
set { encryptionRequired = value; }
}
public Guid Id {
get { throw new NotImplementedException (); }
}
public DateTime LastModifyTime {
get { throw new NotImplementedException (); }
}
public long MaximumJournalSize {
get { return maximumJournalSize; }
set { maximumJournalSize = value; }
}
public long MaximumQueueSize {
get { return maximumQueueSize; }
set { maximumQueueSize = value; }
}
public IntPtr ReadHandle {
get { throw new NotImplementedException (); }
}
public ISynchronizeInvoke SynchronizingObject {
get { return synchronizingObject; }
set { synchronizingObject = value; }
}
public bool Transactional {
get { return transactional; }
}
public bool UseJournalQueue {
get { return useJournalQueue; }
set { useJournalQueue = value; }
}
public IntPtr WriteHandle {
get { throw new NotImplementedException (); }
}
public QueueReference QRef {
get { return qRef; }
set { qRef = value; }
}
private static long GetVersion (IConnection cn)
{
long version = cn.Protocol.MajorVersion;
version = version << 32;
version += cn.Protocol.MinorVersion;
return version;
}
private void SetDeliveryInfo (IMessage msg, long senderVersion,
string transactionId)
{
msg.SetDeliveryInfo (Acknowledgment.None,
DateTime.MinValue,
this,
Guid.NewGuid ().ToString () + "\\0",
MessageType.Normal,
new byte[0],
senderVersion,
DateTime.UtcNow,
null,
transactionId);
}
public void Close ()
{
// No-op (Queue are currently stateless)
}
public static void Delete (string realm, QueueReference qRef)
{
ConnectionFactory cf = new ConnectionFactory ();
using (IConnection cn = cf.CreateConnection (qRef.Host)) {
using (IModel model = cn.CreateModel ()) {
ushort ticket = model.AccessRequest (realm);
model.QueueDelete (ticket, qRef.Queue, false, false, false);
}
}
}
public void Send (IMessage msg)
{
if (QRef == QueueReference.DEFAULT)
throw new MonoMessagingException ("Path has not been specified");
if (msg.BodyStream == null)
throw new ArgumentException ("Message is not serialized properly");
ConnectionFactory cf = new ConnectionFactory ();
try {
using (IConnection cn = cf.CreateConnection (QRef.Host)) {
SetDeliveryInfo (msg, GetVersion (cn), null);
using (IModel ch = cn.CreateModel ()) {
Send (ch, msg);
}
}
} catch (BrokerUnreachableException e) {
throw new ConnectionException (QRef, e);
}
}
public void Send (IMessage msg, IMessageQueueTransaction transaction)
{
if (QRef == QueueReference.DEFAULT)
throw new MonoMessagingException ("Path has not been specified");
if (msg.BodyStream == null)
throw new ArgumentException ("Message is not serialized properly");
RabbitMQMessageQueueTransaction tx = (RabbitMQMessageQueueTransaction) transaction;
tx.RunSend (SendInContext, msg);
}
public void Send (IMessage msg, MessageQueueTransactionType transactionType)
{
switch (transactionType) {
case MessageQueueTransactionType.Single:
using (IMessageQueueTransaction tx = provider.CreateMessageQueueTransaction ()) {
try {
Send (msg, tx);
tx.Commit ();
} catch (Exception e) {
tx.Abort ();
throw new MonoMessagingException(e.Message, e);
}
}
break;
case MessageQueueTransactionType.None:
Send (msg);
break;
case MessageQueueTransactionType.Automatic:
throw new NotSupportedException("Automatic transaction types not supported");
}
}
private void SendInContext (ref string host, ref IConnection cn,
ref IModel model, IMessage msg, string txId)
{
if (host == null)
host = QRef.Host;
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 (model == null) {
model = cn.CreateModel ();
model.TxSelect ();
}
SetDeliveryInfo (msg, GetVersion (cn), txId);
Send (model, msg);
}
private void Send (IModel model, IMessage msg)
{
ushort ticket = model.AccessRequest ("/data");
string finalName = model.QueueDeclare (ticket, QRef.Queue, true);
IMessageBuilder mb = helper.WriteMessage (model, msg);
model.BasicPublish (ticket, "", finalName,
(IBasicProperties) mb.GetContentHeader(),
mb.GetContentBody ());
}
public void Purge ()
{
ConnectionFactory cf = new ConnectionFactory ();
using (IConnection cn = cf.CreateConnection (QRef.Host)) {
using (IModel model = cn.CreateModel ()) {
ushort ticket = model.AccessRequest (realm);
model.QueuePurge (ticket, QRef.Queue, false);
}
}
}
public IMessage Peek ()
{
ConnectionFactory cf = new ConnectionFactory ();
using (IConnection cn = cf.CreateConnection (QRef.Host)) {
using (IModel ch = cn.CreateModel ()) {
return Receive (ch, -1, false);
}
}
}
public IMessage Peek (TimeSpan timeout)
{
return Run (Peeker (timeout));
// ConnectionFactory cf = new ConnectionFactory ();
//
// using (IConnection cn = cf.CreateConnection (QRef.Host)) {
// using (IModel ch = cn.CreateModel ()) {
// if (timeout == TimeSpan.MaxValue) {
// return Receive (ch, -1, false);
// } else {
// return Receive (ch, (int) timeout.TotalMilliseconds, false);
// }
// }
// }
}
public IMessage PeekById (string id)
{
return Run (Peeker (ById (id)));
// ConnectionFactory cf = new ConnectionFactory ();
//
// using (IConnection cn = cf.CreateConnection (QRef.Host)) {
// using (IModel ch = cn.CreateModel ()) {
// return Receive (ch, 500, true, new IdMatcher (id).MatchById);
// }
// }
}
public IMessage PeekById (string id, TimeSpan timeout)
{
return Run (Peeker (timeout, ById (id)));
}
public IMessage PeekByCorrelationId (string id)
{
return Run (Peeker (ByCorrelationId (id)));
// ConnectionFactory cf = new ConnectionFactory ();
//
// using (IConnection cn = cf.CreateConnection (QRef.Host)) {
// using (IModel ch = cn.CreateModel ()) {
// return Receive (ch, 500, false,
// new CorrelationIdMatcher (id).MatchById);
// }
// }
}
public IMessage PeekByCorrelationId (string id, TimeSpan timeout)
{
return Run (Peeker (timeout, ByCorrelationId (id)));
}
public IMessage Receive ()
{
return Run (Receiver ());
}
public IMessage Receive (TimeSpan timeout)
{
return Run (Receiver (timeout));
}
public IMessage Receive (TimeSpan timeout,
IMessageQueueTransaction transaction)
{
return Run (transaction, Receiver (timeout));
}
public IMessage Receive (TimeSpan timeout,
MessageQueueTransactionType transactionType)
{
return Run (transactionType, Receiver (timeout));
}
public IMessage Receive (IMessageQueueTransaction transaction)
{
return Run (transaction, Receiver());
}
public IMessage Receive (MessageQueueTransactionType transactionType)
{
return Run (transactionType, Receiver ());
}
public IMessage ReceiveById (string id)
{
return Run (Receiver (ById (id)));
}
public IMessage ReceiveById (string id, TimeSpan timeout)
{
return Run (Receiver (timeout, ById (id)));
}
public IMessage ReceiveById (string id,
IMessageQueueTransaction transaction)
{
return Run (transaction, Receiver (ById (id)));
}
public IMessage ReceiveById (string id,
MessageQueueTransactionType transactionType)
{
return Run (transactionType, Receiver (ById (id)));
}
public IMessage ReceiveById (string id, TimeSpan timeout,
IMessageQueueTransaction transaction)
{
return Run (transaction, Receiver (timeout, ById (id)));
}
public IMessage ReceiveById (string id, TimeSpan timeout,
MessageQueueTransactionType transactionType)
{
return Run (transactionType, Receiver (timeout, ById (id)));
}
public IMessage ReceiveByCorrelationId (string id)
{
return Run (Receiver (ByCorrelationId (id)));
}
public IMessage ReceiveByCorrelationId (string id, TimeSpan timeout)
{
return Run (Receiver (timeout, ByCorrelationId (id)));
}
public IMessage ReceiveByCorrelationId (string id,
IMessageQueueTransaction transaction)
{
return Run (transaction, Receiver (ByCorrelationId (id)));
}
public IMessage ReceiveByCorrelationId (string id,
MessageQueueTransactionType transactionType)
{
return Run (transactionType, Receiver (ByCorrelationId (id)));
}
public IMessage ReceiveByCorrelationId (string id, TimeSpan timeout,
IMessageQueueTransaction transaction)
{
return Run (transaction, Receiver (timeout, ByCorrelationId (id)));
}
public IMessage ReceiveByCorrelationId (string id, TimeSpan timeout,
MessageQueueTransactionType transactionType)
{
return Run (transactionType, Receiver (timeout, ByCorrelationId (id)));
}
public IMessageEnumerator GetMessageEnumerator ()
{
return new RabbitMQMessageEnumerator (helper, QRef);
}
private IMessage Run (MessageQueueTransactionType transactionType,
TxReceiver.DoReceive r)
{
switch (transactionType) {
case MessageQueueTransactionType.Single:
using (RabbitMQMessageQueueTransaction tx = GetTx ()) {
bool success = false;
try {
IMessage msg = Run (tx, r);
tx.Commit ();
success = true;
return msg;
} finally {
if (!success)
tx.Abort ();
}
}
case MessageQueueTransactionType.None:
return Run (r);
default:
throw new NotSupportedException(transactionType + " not supported");
}
}
private IMessage Run (IMessageQueueTransaction transaction,
TxReceiver.DoReceive r)
{
TxReceiver txr = new TxReceiver (this, r);
RabbitMQMessageQueueTransaction tx =
(RabbitMQMessageQueueTransaction) transaction;
return tx.RunReceive (txr.ReceiveInContext);
}
private IMessage Run (TxReceiver.DoReceive r)
{
ConnectionFactory cf = new ConnectionFactory ();
using (IConnection cn = cf.CreateConnection (QRef.Host)) {
using (IModel model = cn.CreateModel ()) {
return r (this, model);
}
}
}
private IMessage ReceiveInContext (ref string host, ref IConnection cn,
ref IModel model, string txId)
{
if (host == null)
host = QRef.Host;
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 (model == null) {
model = cn.CreateModel ();
model.TxSelect ();
}
return Receive (model, -1, true);
}
private class TxReceiver
{
private readonly DoReceive doReceive;
private readonly RabbitMQMessageQueue q;
public TxReceiver(RabbitMQMessageQueue q, DoReceive doReceive) {
this.q = q;
this.doReceive = doReceive;
}
public delegate IMessage DoReceive (RabbitMQMessageQueue q, IModel model);
public IMessage ReceiveInContext (ref string host, ref IConnection cn,
ref IModel model, string txId)
{
if (host == null)
host = q.QRef.Host;
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 (model == null) {
model = cn.CreateModel ();
model.TxSelect ();
}
return doReceive (q, model);
}
}
private class DoReceiveWithTimeout
{
private readonly int timeout;
private readonly IsMatch matcher;
private readonly bool ack;
public DoReceiveWithTimeout (int timeout, IsMatch matcher)
: this (timeout, matcher, true)
{
}
public DoReceiveWithTimeout (int timeout, IsMatch matcher, bool ack)
{
if (matcher != null && timeout == -1)
this.timeout = 500;
else
this.timeout = timeout;
this.matcher = matcher;
this.ack = ack;
}
public IMessage DoReceive (RabbitMQMessageQueue q, IModel model)
{
if (matcher == null)
return q.Receive (model, timeout, ack);
else
return q.Receive (model, timeout, ack, matcher);
}
}
private static TxReceiver.DoReceive Receiver (TimeSpan timeout,
IsMatch matcher)
{
int to = TimeSpanToInt32 (timeout);
return new DoReceiveWithTimeout (to, matcher).DoReceive;
}
private static TxReceiver.DoReceive Receiver (IsMatch matcher)
{
return new DoReceiveWithTimeout (-1, matcher).DoReceive;
}
private static TxReceiver.DoReceive Receiver (TimeSpan timeout)
{
int to = TimeSpanToInt32 (timeout);
return new DoReceiveWithTimeout (to, null).DoReceive;
}
private TxReceiver.DoReceive Receiver ()
{
return new DoReceiveWithTimeout (-1, null).DoReceive;
}
private TxReceiver.DoReceive Peeker ()
{
return new DoReceiveWithTimeout (-1, null).DoReceive;
}
private TxReceiver.DoReceive Peeker (TimeSpan timeout)
{
int to = TimeSpanToInt32 (timeout);
return new DoReceiveWithTimeout (to, null, false).DoReceive;
}
private TxReceiver.DoReceive Peeker (IsMatch matcher)
{
return new DoReceiveWithTimeout (-1, matcher, false).DoReceive;
}
private TxReceiver.DoReceive Peeker (TimeSpan timeout, IsMatch matcher)
{
int to = TimeSpanToInt32 (timeout);
return new DoReceiveWithTimeout (to, matcher, false).DoReceive;
}
delegate bool IsMatch (BasicDeliverEventArgs result);
private class IdMatcher
{
private readonly string id;
public IdMatcher (string id)
{
this.id = id;
}
public bool MatchById (BasicDeliverEventArgs result)
{
return result.BasicProperties.MessageId == id;
}
}
private static IsMatch ById (string id)
{
return new IdMatcher (id).MatchById;
}
private class CorrelationIdMatcher
{
private readonly string correlationId;
public CorrelationIdMatcher (string correlationId)
{
this.correlationId = correlationId;
}
public bool MatchById (BasicDeliverEventArgs result)
{
return result.BasicProperties.CorrelationId == correlationId;
}
}
private static IsMatch ByCorrelationId (string correlationId)
{
return new CorrelationIdMatcher (correlationId).MatchById;
}
private IMessage Receive (IModel model, int timeout, bool doAck)
{
Console.WriteLine ("{0}, {1}", timeout, doAck);
ushort ticket = model.AccessRequest (realm);
string finalName = model.QueueDeclare (ticket, QRef.Queue, false);
using (Subscription sub = new Subscription (model, ticket, finalName)) {
BasicDeliverEventArgs result;
if (sub.Next (timeout, out result)) {
IMessage m = helper.ReadMessage (QRef, result);
if (doAck)
sub.Ack (result);
return m;
} else {
throw new MonoMessagingException ("No Message Available");
}
}
}
private IMessage Receive (IModel model, int timeout,
bool doAck, IsMatch matcher)
{
Console.WriteLine ("{0}, {1}", timeout, doAck);
ushort ticket = model.AccessRequest (realm);
string finalName = model.QueueDeclare (ticket, QRef.Queue, false);
using (Subscription sub = new Subscription (model, ticket, finalName)) {
BasicDeliverEventArgs result;
while (sub.Next (timeout, out result)) {
if (matcher (result)) {
IMessage m = helper.ReadMessage (QRef, result);
if (doAck)
sub.Ack (result);
return m;
}
}
throw new MessageUnavailableException ("Message not available");
}
}
private RabbitMQMessageQueueTransaction GetTx ()
{
return (RabbitMQMessageQueueTransaction) provider.CreateMessageQueueTransaction ();
}
private static int TimeSpanToInt32 (TimeSpan timespan)
{
if (timespan == TimeSpan.MaxValue)
return -1;
else
return (int) timespan.TotalMilliseconds;
}
}
}
@@ -0,0 +1,140 @@
//
// Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Text;
using Mono.Messaging;
using RabbitMQ.Client;
using RabbitMQ.Client.Content;
using RabbitMQ.Client.Events;
using RabbitMQ.Client.Exceptions;
using RabbitMQ.Client.MessagePatterns;
using RabbitMQ.Util;
namespace Mono.Messaging.RabbitMQ {
public class RabbitMQMessageQueueTransaction : IMessageQueueTransaction {
private readonly string txId;
private MessageQueueTransactionStatus status = MessageQueueTransactionStatus.Initialized;
private IConnection cn = null;
private IModel model = null;
private String host = null;
private bool isDisposed = false;
private Object syncObj = new Object ();
public RabbitMQMessageQueueTransaction (string txId)
{
this.txId = txId;
}
public MessageQueueTransactionStatus Status {
get {
lock (syncObj)
return status;
}
}
public void Abort ()
{
lock (syncObj) {
if (model != null)
model.TxRollback ();
status = MessageQueueTransactionStatus.Aborted;
}
}
public void Begin ()
{
lock (syncObj) {
if (status == MessageQueueTransactionStatus.Pending)
throw new InvalidOperationException ("Transaction already started");
status = MessageQueueTransactionStatus.Pending;
}
}
public void Commit ()
{
lock (syncObj) {
model.TxCommit ();
status = MessageQueueTransactionStatus.Committed;
}
}
public string Id {
get { return txId; }
}
public delegate void Send (ref string host, ref IConnection cn,
ref IModel model, IMessage msg, string txId);
public delegate IMessage Receive (ref string host, ref IConnection cn,
ref IModel model, string txId);
public void RunSend (Send sendDelegate, IMessage msg)
{
lock (syncObj) {
sendDelegate (ref host, ref cn, ref model, msg, Id);
}
}
public IMessage RunReceive (Receive receiveDelegate)
{
lock (syncObj) {
return receiveDelegate (ref host, ref cn, ref model, Id);
}
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
lock (syncObj) {
if (!isDisposed && disposing) {
if (model != null)
model.Dispose ();
if (cn != null)
cn.Dispose ();
isDisposed = true;
}
}
}
}
}
@@ -0,0 +1,152 @@
//
// Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Mono.Messaging;
namespace Mono.Messaging.RabbitMQ {
public class RabbitMQMessagingProvider : IMessagingProvider {
private volatile uint txCounter = 0;
private readonly uint localIp;
private static readonly string DEFAULT_REALM = "/data";
public RabbitMQMessagingProvider()
{
localIp = GetLocalIP ();
}
private static uint GetLocalIP ()
{
//IPHostEntry host = Dns.GetHostEntry (Dns.GetHostName ());
String strHostName = Dns.GetHostName ();
IPHostEntry ipEntry = Dns.GetHostByName (strHostName);
foreach (IPAddress ip in ipEntry.AddressList) {
if (AddressFamily.InterNetwork == ip.AddressFamily) {
byte[] addr = ip.GetAddressBytes ();
uint localIP = 0;
for (int i = 0; i < 4 && i < addr.Length; i++) {
localIP += (uint) (addr[i] << 8 * (3 - i));
}
return localIP;
}
}
return 0;
}
public IMessage CreateMessage ()
{
return new MessageBase ();
}
public IMessageQueueTransaction CreateMessageQueueTransaction ()
{
string txId = localIp.ToString () + (++txCounter).ToString ();
return new RabbitMQMessageQueueTransaction (txId);
}
public void DeleteQueue (QueueReference qRef)
{
RabbitMQMessageQueue.Delete (DEFAULT_REALM, qRef);
}
private readonly IDictionary queues = new Hashtable ();
private readonly ReaderWriterLock qLock = new ReaderWriterLock ();
private const int TIMEOUT = 15000;
public IMessageQueue[] GetPublicQueues ()
{
IMessageQueue[] qs;
qLock.AcquireReaderLock (TIMEOUT);
try {
ICollection qCollection = queues.Values;
qs = new IMessageQueue[qCollection.Count];
qCollection.CopyTo (qs, 0);
return qs;
} finally {
qLock.ReleaseReaderLock ();
}
}
public bool Exists (QueueReference qRef)
{
qLock.AcquireReaderLock (TIMEOUT);
try {
return queues.Contains (qRef);
} finally {
qLock.ReleaseReaderLock ();
}
}
public IMessageQueue CreateMessageQueue (QueueReference qRef,
bool transactional)
{
qLock.AcquireWriterLock (TIMEOUT);
try {
IMessageQueue mq = new RabbitMQMessageQueue (this, qRef,
transactional);
queues[qRef] = mq;
return mq;
} finally {
qLock.ReleaseWriterLock ();
}
}
public IMessageQueue GetMessageQueue (QueueReference qRef)
{
qLock.AcquireReaderLock (TIMEOUT);
try {
if (queues.Contains (qRef))
return (IMessageQueue) queues[qRef];
else {
LockCookie lc = qLock.UpgradeToWriterLock (TIMEOUT);
try {
IMessageQueue mq = new RabbitMQMessageQueue (this, qRef,
false);
queues[qRef] = mq;
return mq;
} finally {
qLock.DowngradeFromWriterLock (ref lc);
}
}
} finally {
qLock.ReleaseReaderLock ();
}
}
}
}
@@ -0,0 +1,9 @@
Mono.Messaging.RabbitMQ/MQUtil.cs
Mono.Messaging.RabbitMQ/BasicMessagingTest.cs
Mono.Messaging.RabbitMQ/AdminTest.cs
Mono.Messaging.RabbitMQ/FailuresTest.cs
Mono.Messaging.RabbitMQ/RabbitMQMessagingProviderTest.cs
Mono.Messaging.RabbitMQ/MessageEnumeratorTest.cs
Mono.Messaging.RabbitMQ/PeekTest.cs
Mono.Messaging.RabbitMQ/TransactionMessagingTest.cs
Mono.Messaging.RabbitMQ/SelectorTest.cs
@@ -0,0 +1,130 @@
//
// Test.Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Messaging;
using System.Reflection;
using System.Threading;
using System.Text.RegularExpressions;
using NUnit.Framework;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class AdminTest {
[Test]
public void CreateNonTransactionalQueue ()
{
string qName = @".\private$\admin-queue-1";
Assert.IsFalse (MessageQueue.Exists (qName), "Queue should not exist");
MessageQueue q = MessageQueue.Create (qName);
Assert.IsFalse (q.Transactional);
Assert.IsTrue (MessageQueue.Exists (qName), "Queue should exist");
}
[Test]
public void CreateTransactionalQueue ()
{
string qName = @".\private$\admin-queue-2";
Assert.IsFalse (MessageQueue.Exists (qName), "Queue should not exist");
MessageQueue q = MessageQueue.Create (qName, true);
Assert.IsTrue (q.Transactional, "Queue should be transactional");
Assert.IsTrue (MessageQueue.Exists (qName), "Queue should exist");
}
private bool Contains(MessageQueue[] qs, String qName)
{
foreach (MessageQueue q in qs)
{
if (q.QueueName == qName)
return true;
}
return false;
}
[Test]
public void GetPublicQueues ()
{
string qName1 = @".\admin-queue-3";
string qName2 = @".\admin-queue-4";
MessageQueue.Create (qName1);
MessageQueue.Create (qName2);
MessageQueue[] mq = MessageQueue.GetPublicQueues ();
Assert.IsTrue (Contains (mq, "admin-queue-3"), qName1 + " not found");
Assert.IsTrue (Contains (mq, "admin-queue-4"), qName2 + " not found");
}
[Test]
public void GetQueue ()
{
MessageQueue q1 = MQUtil.GetQueue(@".\private$\admin-queue-5", true);
Assert.IsTrue (q1.Transactional, "Queue should be transactional");
MessageQueue q2 = MQUtil.GetQueue(@".\private$\admin-queue-5", true);
Assert.IsTrue (q2.Transactional, "Queue should be transactional");
}
[Test]
[ExpectedException (typeof (MessageQueueException))]
public void PurgeQueue ()
{
MessageQueue q = MQUtil.GetQueue(@".\private$\purge-queue");
Message m1 = new Message ("foobar1", new BinaryMessageFormatter ());
Message m2 = new Message ("foobar2", new BinaryMessageFormatter ());
Message m3 = new Message ("foobar3", new BinaryMessageFormatter ());
Message m4 = new Message ("foobar4", new BinaryMessageFormatter ());
q.Send (m1);
q.Send (m2);
q.Send (m3);
q.Send (m4);
Message received = q.Receive ();
q.Purge ();
q.Receive (new TimeSpan (0, 0, 2));
}
[Test]
public void DeleteQueue ()
{
MessageQueue q = MQUtil.GetQueue(@".\private$\delete-queue");
Message m1 = new Message ("foobar1", new BinaryMessageFormatter ());
q.Send (m1);
Message received = q.Receive ();
MessageQueue.Delete(@".\private$\delete-queue");
}
}
}
@@ -0,0 +1,483 @@
//
// Test.Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Messaging;
using System.Reflection;
using System.Threading;
using System.Text.RegularExpressions;
using NUnit.Framework;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class BasicMessageTest {
[Test]
public void SendReceiveBinaryMessage ()
{
String qName = @"private$\testq";
String qPath = @".\" + qName;
MessageQueue mq = MQUtil.GetQueue (qPath);
Assert.AreEqual(qName, mq.QueueName, "Queue name not set properly");
String s = "Test: " + DateTime.Now;
Message m = new Message (s, new BinaryMessageFormatter ());
m.CorrelationId = Guid.NewGuid () + "\\0";
mq.MessageReadPropertyFilter.SetAll ();
mq.Send (m);
Message m2 = mq.Receive ();
m2.Formatter = new BinaryMessageFormatter ();
Assert.AreEqual (s, m2.Body);
//Assert.IsTrue (DateTime.MinValue == m.ArrivedTime);
Assert.IsNotNull(m2.Id, "Id is null");
Assert.IsTrue (Guid.Empty.ToString () != m2.Id, "Id is Empty");
Assert.IsTrue (DateTime.MinValue != m2.ArrivedTime, "Arrived Time is not set");
Assert.AreEqual (Acknowledgment.None, m2.Acknowledgment, "Acknowledgment");
Assert.AreEqual (m.CorrelationId, m2.CorrelationId, "CorrelationId not set properly");
Assert.IsTrue (0 != m2.SenderVersion);
// TODO: This is not support on a workgroup installation.
//Assert.IsNotNull (m2.SourceMachine, "SourceMachine is null");
Assert.AreEqual (qName, m2.DestinationQueue.QueueName, "Destination Queue not set");
mq.Close ();
}
[Test]
public void SendMessageWithLabel ()
{
String qName = @".\private$\testq";
String label = "mylabel";
MessageQueue mq = MQUtil.GetQueue (qName);
Assert.AreEqual (@"private$\testq", mq.QueueName, "Queue name not set properly");
String s = "Test: " + DateTime.Now;
Message m = new Message (s, new BinaryMessageFormatter ());
m.CorrelationId = Guid.NewGuid () + "\\0" ;
mq.Send (m, label);
Message m2 = mq.Receive ();
m2.Formatter = new BinaryMessageFormatter ();
Assert.AreEqual (s, m2.Body, "Message not passed correctly");
Assert.AreEqual (label, m2.Label, "Label not passed correctly");
}
[Test]
public void CheckDefaults ()
{
Message m = new Message ("Test", new BinaryMessageFormatter ());
Assert.AreEqual (true, m.AttachSenderId, "AttachSenderId has incorrect default");
Assert.AreEqual (Guid.Empty.ToString () + "\\0", m.Id, "Id has incorrect default");
Assert.AreEqual ("Microsoft Base Cryptographic Provider, Ver. 1.0",
m.AuthenticationProviderName,
"AuthenticationProviderName has incorrect default");
Assert.AreEqual (0, m.Extension.Length, "Extension has incorrect default");
Assert.AreEqual ("", m.Label, "Label has incorrect default");
Assert.IsFalse (m.Recoverable, "Recoverable has incorrect default");
Assert.IsFalse (m.IsFirstInTransaction, "IsFirstInTransaction has incorrect default");
Assert.IsFalse (m.IsLastInTransaction, "IsLastInTransaction has incorrect default");
Assert.AreEqual ("", m.TransactionId, "TransactionId has incorrect default");
Assert.AreEqual (MessagePriority.Normal, m.Priority, "MessagePriority has incorrect default");
}
private static void CheckInvalidOperation (Message m, String property)
{
PropertyInfo pi = m.GetType ().GetProperty (property);
try {
Assert.IsNotNull (pi, "Property not defined: " + property);
object o = pi.GetValue (m, null);
Assert.Fail (property + ": " + o);
} catch (InvalidOperationException e) {
} catch (TargetInvocationException e) {
Assert.AreEqual (typeof (InvalidOperationException),
e.InnerException.GetType ());
}
}
[Test]
public void CheckInvalidPropertyOperations ()
{
Message m = new Message ("Test", new BinaryMessageFormatter ());
CheckInvalidOperation (m, "Acknowledgment");
CheckInvalidOperation (m, "ArrivedTime");
CheckInvalidOperation (m, "Authenticated");
CheckInvalidOperation (m, "DestinationQueue");
//CheckInvalidOperation (m, "Id");
//CheckInvalidOperation (m, "IsFirstInTransaction");
//CheckInvalidOperation (m, "IsLastInTransaction");
// TODO: Support 2.0 features.
//CheckInvalidOperation (m, "LookupId");
CheckInvalidOperation (m, "MessageType");
CheckInvalidOperation (m, "SenderId");
CheckInvalidOperation (m, "SenderVersion");
CheckInvalidOperation (m, "SentTime");
CheckInvalidOperation (m, "SourceMachine");
//CheckInvalidOperation (m, "TransactionId");
}
private static void CheckArgumentInvalid(Message m, String property, Type exceptionType)
{
PropertyInfo pi = m.GetType().GetProperty(property);
try {
Assert.IsNotNull(pi, "Property not defined: " + property);
pi.SetValue(m, null, null);
Assert.Fail(property);
} catch (InvalidOperationException e) {
} catch (TargetInvocationException e) {
Assert.AreEqual(exceptionType,
e.InnerException.GetType(),
property);
}
}
[Test]
public void CheckArgumentInvalidForProperties ()
{
Message m = new Message ("Stuff");
CheckArgumentInvalid (m, "DestinationSymmetricKey", typeof (ArgumentNullException));
CheckArgumentInvalid (m, "DigitalSignature", typeof(ArgumentNullException));
CheckArgumentInvalid (m, "Extension", typeof(ArgumentNullException));
}
[Test]
public void SendReceiveBinaryMessageWithAllPropertiesSet ()
{
String qName = @"private$\testq";
String qPath = @".\" + qName;
MessageQueue mq = MQUtil.GetQueue (qPath);
mq.MessageReadPropertyFilter.SetAll ();
Assert.AreEqual(qName, mq.QueueName, "Queue name not set properly");
MessageQueue adminQ = MQUtil.GetQueue (@".\private$\myadmin");
MessageQueue responseQ = MQUtil.GetQueue (@".\private$\myresponse");
Guid connectorType = Guid.NewGuid ();
String s = "Test: " + DateTime.Now;
Message m = new Message (s, new BinaryMessageFormatter ());
m.CorrelationId = Guid.NewGuid () + "\\0";
m.AcknowledgeType = AcknowledgeTypes.PositiveArrival;
m.AdministrationQueue = adminQ;
m.AppSpecific = 5;
//m.AuthenticationProviderName = "Test Provider Name";
//m.AuthenticationProviderType = CryptographicProviderType.None;
//m.ConnectorType = connectorType;
//m.DestinationSymmetricKey = new byte[] { 0x0A, 0x0B, 0x0C };
//m.DigitalSignature = new byte[] { 0x0C, 0x0D, 0x0E };
//m.EncryptionAlgorithm = EncryptionAlgorithm.Rc4;
m.Extension = new byte[] { 0x01, 0x02, 0x03 };
//m.HashAlgorithm = HashAlgorithm.Sha;
m.Label = "MyLabel";
m.Priority = MessagePriority.AboveNormal;
m.Recoverable = true;
m.ResponseQueue = responseQ;
m.SenderCertificate = new byte[] { 0x04, 0x05, 0x06 };
m.TimeToBeReceived = new TimeSpan(0, 0, 10);
m.TimeToReachQueue = new TimeSpan(0, 0, 5);
//m.UseAuthentication = true;
m.UseDeadLetterQueue = true;
//m.UseEncryption = true;
mq.Send (m);
Message m2 = mq.Receive ();
m2.Formatter = new BinaryMessageFormatter ();
Assert.AreEqual (s, m2.Body);
Assert.AreEqual (AcknowledgeTypes.PositiveArrival, m2.AcknowledgeType,
"AcknowledgeType not passed correctly");
Assert.AreEqual (adminQ.QueueName, m2.AdministrationQueue.QueueName,
"AdministrationQueue not passed correctly");
Assert.AreEqual (5, m2.AppSpecific, "AppSpecific not passed correctly");
//Assert.AreEqual (m.AuthenticationProviderName, m2.AuthenticationProviderName,
// "AuthenticationProviderName not passed correctly");
//Assert.AreEqual (m.AuthenticationProviderType, m2.AuthenticationProviderType,
// "AuthenticationProviderType not passed correctly");
//Assert.AreEqual (connectorType, m2.ConnectorType,
// "ConnectorType not passed correctly");
Assert.AreEqual (m.CorrelationId, m2.CorrelationId,
"CorrelationId not passed correctly");
//AreEqual (m.DestinationSymmetricKey, m2.DestinationSymmetricKey,
// "DestinationSymmetricKey not passed correctly");
//AreEqual (m.DigitalSignature, m2.DigitalSignature,
// "DigitalSignature not passed properly");
//Assert.AreEqual (EncryptionAlgorithm.Rc4, m2.EncryptionAlgorithm,
// "EncryptionAlgorithm not passed properly");
AreEqual (m.Extension, m2.Extension, "Extension not passed properly");
//Assert.AreEqual (m.HashAlgorithm, m2.HashAlgorithm,
// "HashAlgorithm not passed properly");
Assert.AreEqual (m.Label, m2.Label, "Label not passed correctly");
Assert.AreEqual (MessagePriority.AboveNormal, m2.Priority,
"Priority not passed properly");
Assert.AreEqual (true, m2.Recoverable, "Recoverable not passed properly");
Assert.AreEqual (responseQ.QueueName, m2.ResponseQueue.QueueName,
"ResponseQueue not passed properly");
AreEqual (m.SenderCertificate, m2.SenderCertificate,
"SenderCertificate not passed properly");
Assert.AreEqual (m.TimeToBeReceived, m2.TimeToBeReceived,
"TimeToBeReceived not passed properly");
Assert.AreEqual (m.TimeToReachQueue, m2.TimeToReachQueue,
"TimeToReachQueue not passed properly");
//Assert.IsTrue (m2.UseAuthentication,
// "UseAuthentication not passed properly");
Assert.IsTrue (m2.UseDeadLetterQueue,
"UseDeadLetterQueue not passed properly");
//Assert.IsTrue (m2.UseEncryption, "UseEncryption not pass properly");
//Assert.AreEqual ();
Assert.IsNotNull (m2.Id, "Id is null");
Assert.IsTrue (Guid.Empty.ToString () != m2.Id, "Id is Empty");
Assert.IsTrue (DateTime.MinValue != m2.ArrivedTime, "Arrived Time is not set");
Assert.AreEqual (Acknowledgment.None, m2.Acknowledgment, "Acknowledgment");
Assert.IsTrue (0 != m2.SenderVersion);
//Assert.IsNotNull (m2.SourceMachine, "SourceMachine is null");
}
private static void AreEqual(byte[] expected, byte[] actual, string message)
{
Assert.AreEqual (expected.Length, actual.Length, message);
for (int i = 0; i < expected.Length; i++)
Assert.AreEqual (expected[i], actual[i], message);
}
//[Test]
// No supported by Rabbit
public void SendPriorityMessages ()
{
MessageQueue mq = MQUtil.GetQueue ("testpriority");
Message sent1 = new Message ("Highest", new BinaryMessageFormatter ());
sent1.Priority = MessagePriority.Highest;
Message sent2 = new Message ("Lowest", new BinaryMessageFormatter ());
sent2.Priority = MessagePriority.Lowest;
mq.Send (sent1);
mq.Send (sent2);
Message received1 = mq.Receive ();
Message received2 = mq.Receive ();
Assert.AreEqual (MessagePriority.Highest, received2.Priority,
"Priority delivery incorrect");
Assert.AreEqual (MessagePriority.Lowest, received1.Priority,
"Priority delivery incorrect");
}
[Test]
public void SendReceiveXmlMessage ()
{
MessageQueue mq = MQUtil.GetQueue (@".\private$\testq");
String s = "Test: " + DateTime.Now;
Message m = new Message (s, new XmlMessageFormatter (new Type[] { typeof (string) }));
mq.MessageReadPropertyFilter.SetAll();
mq.Send (m);
Message m2 = mq.Receive ();
m2.Formatter = new XmlMessageFormatter (new Type[] { typeof (string) });
Assert.AreEqual (s, m2.Body);
Assert.AreEqual (Acknowledgment.None, m2.Acknowledgment, "Acknowledgment");
Assert.IsNotNull (m2.ArrivedTime, "Acknowledgment");
Assert.IsNotNull (m2.Id, "Id");
}
[Test]
public void SendBinaryText ()
{
string path = @".\private$\MyQ";
string body = "This is a test";
MessageQueue q = MQUtil.GetQueue (path);
q.Formatter = new BinaryMessageFormatter ();
q.Send (body);
Message m2 = q.Receive ();
Assert.IsNotNull (m2.Formatter, "Formatter is null");
Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
Assert.AreEqual (body, m2.Body);
}
[Test]
public void SendDefaultText ()
{
string path = @".\private$\MyQ";
string body = "This is a test";
MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());
q.Send (body);
Message m2 = q.Receive ();
XmlMessageFormatter xmlf = (XmlMessageFormatter) q.Formatter;
//Assert.AreEqual (typeof (string), xmlf.TargetTypes[0]);
Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
Assert.AreEqual (body, m2.Body);
Assert.AreEqual (0, m2.BodyType);
}
[Test]
public void SendBinaryObject ()
{
string path = @".\private$\MyQ";
Thingy body = new Thingy ();
body.MyProperty1 = 42;
body.MyProperty2 = "Something";
body.MyProperty3 = "Something else";
MessageQueue q = MQUtil.GetQueue (path);
q.Formatter = new BinaryMessageFormatter ();
q.Send (body);
Message m2 = q.Receive ();
Thingy body2 = (Thingy) m2.Body;
Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
Assert.AreEqual (768, m2.BodyType);
}
[Test]
public void SendDefaultObject ()
{
string path = @".\private$\MyQ";
Thingy body = new Thingy();
body.MyProperty1 = 42;
body.MyProperty2 = "Something";
body.MyProperty3 = "Something else";
MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());
q.Send (body);
MessageQueue q2 = MQUtil.GetQueue (path);
q2.Formatter = new XmlMessageFormatter (new Type[] { typeof(Thingy) });
Message m2 = q2.Receive ();
Thingy body2 = (Thingy) m2.Body;
Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
}
[Test]
public void SendBinaryMessage ()
{
string path = @".\private$\MyQ";
Thingy body = new Thingy ();
body.MyProperty1 = 42;
body.MyProperty2 = "Something";
body.MyProperty3 = "Something else";
Message m1 = new Message (body);
m1.Formatter = new BinaryMessageFormatter ();
MessageQueue q = MQUtil.GetQueue (path);
q.Send (m1);
Message m2 = q.Receive ();
m2.Formatter = new BinaryMessageFormatter ();
Assert.IsNotNull (m2.Formatter);
Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
Thingy body2 = (Thingy) m2.Formatter.Read (m2);
Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
}
[Test]
public void SendDefaultMessage ()
{
string path = @".\private$\MyQ";
Thingy body = new Thingy ();
body.MyProperty1 = 42;
body.MyProperty2 = "Something";
body.MyProperty3 = "Something else";
Message m1 = new Message (body);
Assert.IsNull (m1.Formatter);
MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());
q.Send (m1);
Message m2 = q.Receive ();
m2.Formatter = new XmlMessageFormatter (new Type[] { typeof (Thingy) });
Assert.IsNotNull (m2.Formatter);
Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
Thingy body2 = (Thingy) m2.Formatter.Read (m2);
Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
}
}
[Serializable]
public class Thingy
{
private int myVar1;
public int MyProperty1
{
get { return myVar1; }
set { myVar1 = value; }
}
private string myVar2;
public string MyProperty2
{
get { return myVar2; }
set { myVar2 = value; }
}
private string myVar3;
public string MyProperty3
{
get { return myVar3; }
set { myVar3 = value; }
}
}
}
@@ -0,0 +1,40 @@
2008-12-06 Michael Barker <[email protected]>
* AdminTest.cs: Updated to run against MS.NET
* BasicMessagingTest.cs: Updated to run against MS.NET
* FailuresTest.cs: Updated to run against MS.NET
* MessageEnumeratorTest.cs: Updated to run against MS.NET
* MQUtil.cs: Updated to run against MS.NET
* PeekTest.cs: Updated to run against MS.NET
* SelectorTest.cs: Updated to run against MS.NET
* TransactionMessagingTest.cs: Updated to run against MS.NET
2008-12-01 Michael Barker <[email protected]>
* AdminTest.cs: Added tests for queue discovery methods.
2008-11-23 Michael Barker <[email protected]>
* TransactionMessagingTest.cs: Added tests for all methods that the
transaction type argument, currently only Single is supported. Added methods
with transactions and timeout.
* PeekTest.cs: Added PeekBy{Id,CorrelationId} tests.
2008-11-09 Michael Barker <[email protected]>
* SelectorTest.cs: New, tests for ReceiveByXYZ() methods
2008-11-04 Michael Barker <[email protected]>
* PeekTest.cs: New, tests for peeking at messages.
2008-11-02 Michael Barker <[email protected]>
* TransactionMessagingTest.cs: New, tests for transactional messaging.
* FailuresTest.cs: New, tests for exceptions.
* AdminTest.cs: New, tests for administration functions.
2008-09-29 Michael Barker <[email protected]>
* BasicMessagingTest.cs: New
* RabbitMQMessagingProviderTest.cs: New
@@ -0,0 +1,66 @@
//
// Test.Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Messaging;
using System.Reflection;
using System.Threading;
using System.Text.RegularExpressions;
using NUnit.Framework;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class FailuresTest {
[Test]
[ExpectedException (typeof (MessageQueueException))]
public void SendWithPathNotSet ()
{
MessageQueue q = new MessageQueue ();
Message m = new Message ("foobar", new BinaryMessageFormatter ());
q.Send (m);
}
[Test]
[ExpectedException (typeof (MessageQueueException))]
public void SendInTransactionWithPathNotSet ()
{
MessageQueue q = new MessageQueue ();
Message m = new Message ("foobar", new BinaryMessageFormatter ());
MessageQueueTransaction tx = new MessageQueueTransaction ();
q.Send (m, tx);
}
}
}
@@ -0,0 +1,67 @@
//
// Test.Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Messaging;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
public class MQUtil
{
public static MessageQueue GetQueue (string path)
{
return GetQueue (path, false);
}
public static MessageQueue GetQueue (string path, bool isTransactional)
{
return GetQueue (path, isTransactional,
new BinaryMessageFormatter ());
}
public static MessageQueue GetQueue (string path, IMessageFormatter formatter)
{
return GetQueue (path, false, formatter);
}
public static MessageQueue GetQueue (string path, bool isTransactional,
IMessageFormatter formatter)
{
MessageQueue q;
if (MessageQueue.Exists (path)) {
q = new MessageQueue (path);
} else {
q = MessageQueue.Create (path, isTransactional);
}
q.Formatter = formatter;
return q;
}
}
}
@@ -0,0 +1,115 @@
//
// Test.Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Messaging;
//using Mono.Messaging;
//using Mono.Messaging.RabbitMQ;
using NUnit.Framework;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class MessageEnumeratorTest {
private readonly String qName = @".\private$\testq2";
private void SendMessage (string s) {
MessageQueue mq = MQUtil.GetQueue (qName);
Message m = new Message (s, new BinaryMessageFormatter ());
m.CorrelationId = Guid.NewGuid () + "\\0";
mq.Send (m);
}
[Test]
public void RemoveMessage ()
{
SendMessage ("message 1");
SendMessage ("message 2");
SendMessage ("message 3");
SendMessage ("message 4");
MessageQueue mq0 = MQUtil.GetQueue (qName);
MessageEnumerator me0 = mq0.GetMessageEnumerator ();
me0.MoveNext ();
me0.MoveNext ();
me0.MoveNext ();
Message m0 = me0.RemoveCurrent ();
me0.MoveNext ();
me0.Dispose ();
mq0.Dispose ();
MessageQueue mq1 = MQUtil.GetQueue (qName);
MessageEnumerator me1 = mq1.GetMessageEnumerator ();
me1.MoveNext();
me1.MoveNext();
me1.MoveNext();
Message m1 = me1.Current;
m1.Formatter = new BinaryMessageFormatter ();
Console.WriteLine ("{0}", m1.Body);
Assert.AreEqual ("message 4", (String) m1.Body, "body incorrect");
mq1.Purge ();
MessageQueue.Delete (qName);
}
//[Test]
// Not supported with AMQP
public void RemoveMessageWithTx ()
{
MessageQueue q = MQUtil.GetQueue ("testq3");
q.Formatter = new BinaryMessageFormatter ();
q.Send ("foo1");
q.Send ("foo2");
MessageEnumerator me1 = q.GetMessageEnumerator ();
MessageQueueTransaction tx = new MessageQueueTransaction ();
me1.MoveNext ();
Message m1 = me1.Current;
me1.RemoveCurrent (tx);
tx.Commit ();
me1.Close ();
MessageEnumerator me2 = q.GetMessageEnumerator ();
Assert.IsTrue (me1.MoveNext ());
me2.RemoveCurrent ();
Assert.IsFalse (me2.MoveNext ());
}
}
}
@@ -0,0 +1,187 @@
//
// Test.Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Messaging;
using NUnit.Framework;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class PeekTest {
[Test]
public void PeekMessage ()
{
String body = "foo-" + DateTime.Now.ToString ();
Message s1 = new Message(body, new BinaryMessageFormatter());
MessageQueue mq = MQUtil.GetQueue (@".\private$\peek-queue-1");
mq.Send (s1);
Message r1 = mq.Peek ();
Assert.AreEqual (body, r1.Body);
Message r2 = mq.Receive ();
Assert.AreEqual (body, r2.Body);
}
[Test]
public void PeekMessageWithTimeout ()
{
String body = "foo-" + DateTime.Now.ToString();
Message s1 = new Message(body, new BinaryMessageFormatter());
MessageQueue mq = MQUtil.GetQueue(@".\private$\peek-queue-2");
mq.Send (s1);
Message r1 = mq.Peek (new TimeSpan (0, 0, 2));
Assert.AreEqual (body, r1.Body);
Message r2 = mq.Receive ();
Assert.AreEqual (body, r2.Body);
}
[Test]
[ExpectedException (typeof (MessageQueueException))]
public void PeekNoMessageWithTimeout ()
{
MessageQueue mq = MQUtil.GetQueue(@".\private$\peek-queue-3");
Message r1 = mq.Peek (new TimeSpan (0, 0, 2));
}
[Test]
public void PeekById ()
{
String body = "Foo-" + DateTime.Now.ToString ();
Message s1 = new Message (body, new BinaryMessageFormatter());
MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-4");
q.Send (s1);
String id = s1.Id;
try {
Message r1 = q.PeekById (id);
Assert.AreEqual (body, r1.Body, "Unable to PeekById correctly");
} finally {
q.Purge ();
}
}
[Test]
public void PeekByIdWithTimeout ()
{
String body = "Foo-" + DateTime.Now.ToString ();
Message s1 = new Message (body, new BinaryMessageFormatter());
MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-5");
q.Send (s1);
String id = s1.Id;
try {
Message r1 = q.PeekById (id, new TimeSpan (0, 0, 2));
Assert.AreEqual (body, r1.Body, "Unable to PeekById correctly");
} finally {
q.Purge ();
}
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void PeekByIdNotFound ()
{
String body = "Foo-" + DateTime.Now.ToString ();
Message s1 = new Message (body, new BinaryMessageFormatter());
MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-6");
q.Send (s1);
String id = "fail!";
try {
Message r1 = q.PeekById (id);
} finally {
q.Purge ();
}
}
[Test]
public void PeekByCorrelationId ()
{
String correlationId = Guid.NewGuid () + "\\0";
String body = "Foo-" + DateTime.Now.ToString ();
Message s1 = new Message (body, new BinaryMessageFormatter());
s1.CorrelationId = correlationId;
MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-7");
q.Formatter = new BinaryMessageFormatter ();
q.Send (s1);
try {
Message r1 = q.PeekByCorrelationId (correlationId);
Assert.AreEqual (body, r1.Body, "Unable to PeekByCorrelationId correctly");
} finally {
q.Purge ();
}
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void PeekByCorrelationIdNotFound ()
{
String body = "Foo-" + DateTime.Now.ToString ();
Message s1 = new Message (body);
String correlationId = Guid.NewGuid() + "\\0";
MessageQueue q = MQUtil.GetQueue(@".\private$\peek-queue-8");
q.Formatter = new BinaryMessageFormatter ();
q.Send (s1);
try {
Message r1 = q.PeekByCorrelationId ("fail!");
} finally {
q.Purge ();
}
}
[Test]
public void PeekByCorrelationIdWithTimeout ()
{
String correlationId = Guid.NewGuid () + "\\0";
String body = "Foo-" + DateTime.Now.ToString ();
Message s1 = new Message (body, new BinaryMessageFormatter());
s1.CorrelationId = correlationId;
MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-9");
q.Formatter = new BinaryMessageFormatter ();
q.Send (s1);
try {
Message r1 = q.PeekByCorrelationId (correlationId, new TimeSpan (0, 0, 2));
Assert.AreEqual (body, r1.Body, "Unable to PeekByCorrelationId correctly");
} finally {
q.Purge ();
}
}
}
}
@@ -0,0 +1,60 @@
//
// Test.Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Mono.Messaging;
using Mono.Messaging.RabbitMQ;
using NUnit.Framework;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class RabbitMQMessagingProviderTest {
[Test]
public void CreateMessage ()
{
IMessagingProvider p = new RabbitMQMessagingProvider ();
IMessage m = p.CreateMessage ();
Assert.IsNotNull (m);
}
[Test]
public void GetMessageQueue ()
{
IMessagingProvider p = new RabbitMQMessagingProvider ();
IMessageQueue q = p.CreateMessageQueue (QueueReference.DEFAULT, true);
Assert.IsNotNull (q);
}
}
}
@@ -0,0 +1,138 @@
//
// Test.Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Messaging;
using NUnit.Framework;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class SelectorTest
{
[Test]
public void SelectById ()
{
String body = "Foo-" + DateTime.Now.ToString ();
Message s1 = new Message (body, new BinaryMessageFormatter());
MessageQueue q = MQUtil.GetQueue (@".\private$\selector-queue-1");
q.Send (s1);
String id = s1.Id;
Message r1 = q.ReceiveById (id);
Assert.AreEqual (body, r1.Body, "Unable to ReceiveById correctly");
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void SelectByIdNotFound ()
{
String body = "Foo-" + DateTime.Now.ToString();
Message s1 = new Message(body, new BinaryMessageFormatter());
MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-2");
q.Send (s1);
String id = "fail!";
try {
Message r1 = q.ReceiveById (id);
} finally {
q.Purge ();
}
}
[Test]
public void SelectByCorrelationId ()
{
string correlationId = Guid.NewGuid () + "\\0";
String body = "Foo-" + DateTime.Now.ToString();
Message s1 = new Message(body, new BinaryMessageFormatter());
s1.CorrelationId = correlationId;
MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-3");
q.Send (s1);
Message r1 = q.ReceiveByCorrelationId (correlationId);
Assert.AreEqual (body, r1.Body, "Unable to ReceiveByCorrelationId correctly");
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void SelectByCorrelationIdNotFound ()
{
string correlationId = Guid.NewGuid() + "\\0";
String body = "Foo-" + DateTime.Now.ToString();
Message s1 = new Message(body, new BinaryMessageFormatter());
s1.CorrelationId = correlationId;
MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-4");
q.Send (s1);
try {
Message r1 = q.ReceiveByCorrelationId ("fail!");
} finally {
q.Purge ();
}
}
[Test]
public void SelectByIdWithTimeout ()
{
String body = "Foo-" + DateTime.Now.ToString();
Message s1 = new Message(body, new BinaryMessageFormatter());
MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-5");
q.Send (s1);
String id = s1.Id;
Message r1 = q.ReceiveById (id, new TimeSpan (0, 0, 2));
Assert.AreEqual (body, r1.Body, "Unable to ReceiveById correctly");
}
[Test]
public void SelectByCorrelationIdWithTimeout ()
{
string correlationId = Guid.NewGuid() + "\\0";
String body = "Foo-" + DateTime.Now.ToString();
Message s1 = new Message(body, new BinaryMessageFormatter());
s1.CorrelationId = correlationId;
MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-3");
q.Send (s1);
Message r1 = q.ReceiveByCorrelationId (correlationId, new TimeSpan (0, 0, 2));
Assert.AreEqual (body, r1.Body, "Unable to ReceiveByCorrelationId correctly");
}
}
}
@@ -0,0 +1,467 @@
//
// Test.Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Messaging;
using System.Reflection;
using System.Threading;
using System.Text.RegularExpressions;
using NUnit.Framework;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class TransactionMessageTest {
[Test]
public void Send2WithTransaction ()
{
Message sent1 = new Message ("Message 1", new BinaryMessageFormatter ());
Message sent2 = new Message ("Message 2", new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-1", true);
mq.MessageReadPropertyFilter.SetAll ();
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
mq.Send (sent1, tx);
mq.Send (sent2, tx);
tx.Commit ();
Message received1 = mq.Receive ();
Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
Message received2 = mq.Receive ();
Assert.IsNotNull (received2.TransactionId, "TransactionId not set");
Assert.AreEqual (received1.TransactionId, received2.TransactionId, "Messages have differing TransactionIds");
Assert.IsTrue (received1.TransactionId.Length > 1);
Assert.AreEqual (sent1.Body, received1.Body, "Message 1 not delivered correctly");
Assert.AreEqual (sent2.Body, received2.Body, "Message 2 not delivered correctly");
}
}
[Test]
public void Send2WithLabelWithTransaction ()
{
String label1 = "label1";
String label2 = "label2";
Message sent1 = new Message ("Message 1", new BinaryMessageFormatter ());
Message sent2 = new Message ("Message 2", new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-2", true);
mq.MessageReadPropertyFilter.SetAll ();
Assert.IsTrue(mq.Transactional, "Message Queue should be transactional");
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
mq.Send (sent1, label1, tx);
mq.Send (sent2, label2, tx);
tx.Commit ();
Message received1 = mq.Receive ();
Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
Message received2 = mq.Receive ();
Assert.IsNotNull (received2.TransactionId, "TransactionId not set");
Assert.AreEqual (received1.TransactionId, received2.TransactionId, "Messages have differing TransactionIds");
Assert.IsTrue (received1.TransactionId.Length > 1);
Assert.AreEqual (sent1.Body, received1.Body, "Message 1 not delivered correctly");
Assert.AreEqual (sent2.Body, received2.Body, "Message 2 not delivered correctly");
Assert.AreEqual (label1, received1.Label, "Label 1 not passed correctly");
Assert.AreEqual (label2, received2.Label, "Label 2 not passed correctly");
}
}
[Test]
[ExpectedException (typeof (MessageQueueException))]
public void Send2WithTransactionAbort ()
{
Message sent1 = new Message ("Message 1", new BinaryMessageFormatter ());
Message sent2 = new Message ("Message 2", new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-1", true);
mq.MessageReadPropertyFilter.SetAll ();
Assert.IsTrue(mq.Transactional, "Message Queue should be transactional");
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
mq.Send (sent1, tx);
mq.Send (sent2, tx);
tx.Abort ();
mq.Receive (new TimeSpan (0, 0, 2));
}
}
[Test]
public void ReceiveWithTransaction ()
{
String body = "Message 4";
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-4", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.Receive (tx);
tx.Commit ();
Assert.AreEqual (body, received1.Body);
}
}
[Test]
public void ReceiveWithTransactionAbort ()
{
String body = "foo-" + DateTime.Now.ToString ();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-5", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.Receive (tx);
tx.Abort ();
}
Message received2 = mq.Receive ();
Assert.AreEqual (body, received2.Body);
}
[Test]
public void ReceiveWithTransactionType ()
{
String body = "foo-" + DateTime.Now.ToString ();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-6", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
Message received1 = mq.Receive (MessageQueueTransactionType.Single);
Assert.AreEqual (body, received1.Body);
}
[Test]
public void SendWithTransactionType ()
{
Message sent1 = new Message ("Message 1");
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-7", true);
mq.MessageReadPropertyFilter.SetAll();
mq.Send (sent1, MessageQueueTransactionType.Single);
Message received1 = mq.Receive ();
Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
}
[Test]
public void SendWithTransactionTypeAndLabel ()
{
Message sent1 = new Message ("Message 1");
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-8", true);
mq.MessageReadPropertyFilter.SetAll();
String label = "mylabel";
mq.Send (sent1, label, MessageQueueTransactionType.Single);
Message received1 = mq.Receive ();
Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
Assert.AreEqual (label, received1.Label, "Label not set");
}
[Test]
public void ReceiveByIdWithTransaction ()
{
String body = "Message 4";
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-9", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.ReceiveById (id, tx);
tx.Commit ();
Assert.AreEqual (body, received1.Body);
}
}
[Test]
public void ReceiveByIdWithTransactionAbort ()
{
String body = "foo-" + DateTime.Now.ToString ();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-10", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.ReceiveById (id, tx);
tx.Abort ();
}
Message received2 = mq.Receive ();
Assert.AreEqual (body, received2.Body);
}
[Test]
public void ReceiveByIdWithTransactionType ()
{
String body = "Message 4";
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-11", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
Message received1 = mq.ReceiveById (id, MessageQueueTransactionType.Single);
Assert.AreEqual (body, received1.Body);
}
[Test]
public void ReceiveByCorrelationIdWithTransaction ()
{
string correlationId = Guid.NewGuid() + "\\0";
String body = "Message 4";
Message sent1 = new Message (body, new BinaryMessageFormatter ());
sent1.CorrelationId = correlationId;
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-12", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.ReceiveByCorrelationId(correlationId, tx);
tx.Commit ();
Assert.AreEqual (body, received1.Body);
}
}
[Test]
public void ReceiveByCorrelationIdWithTransactionAbort ()
{
string correlationId = Guid.NewGuid() + "\\0";
String body = "foo-" + DateTime.Now.ToString();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
sent1.CorrelationId = correlationId;
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-13", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.ReceiveByCorrelationId (correlationId, tx);
tx.Abort ();
}
Message received2 = mq.Receive ();
Assert.AreEqual (body, received2.Body);
}
[Test]
public void ReceiveByCorrelationIdWithTransactionType ()
{
string correlationId = Guid.NewGuid() + "\\0";
String body = "Message 10";
Message sent1 = new Message (body, new BinaryMessageFormatter ());
sent1.CorrelationId = correlationId;
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-14", true);
mq.Formatter = new BinaryMessageFormatter ();
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
Message received1 = mq.ReceiveByCorrelationId (correlationId, MessageQueueTransactionType.Single);
Assert.AreEqual (body, received1.Body);
}
[Test]
public void ReceiveWithTransactionAndTimeout ()
{
String body = "Message 11";
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-15", true);
mq.Formatter = new BinaryMessageFormatter ();
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.Receive (new TimeSpan (0, 0, 2), tx);
tx.Commit ();
Assert.AreEqual (body, received1.Body);
}
}
[Test]
public void ReceiveWithTransactionAndTimeoutAndAbort ()
{
String body = "foo-" + DateTime.Now.ToString ();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-16", true);
mq.Formatter = new BinaryMessageFormatter ();
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.Receive (new TimeSpan (0, 0, 2), tx);
tx.Abort ();
}
Message received2 = mq.Receive ();
Assert.AreEqual (body, received2.Body);
}
[Test]
public void ReceiveWithTransactionTypeAndTimeout ()
{
String body = "foo-" + DateTime.Now.ToString ();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-17", true);
mq.Formatter = new BinaryMessageFormatter ();
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
Message received1 = mq.Receive (new TimeSpan (0, 0, 5), MessageQueueTransactionType.Single);
Assert.AreEqual (body, received1.Body);
}
[Test]
[ExpectedException (typeof (MessageQueueException))]
public void ReceiveWithTransactionTypeAndTimeoutFailure ()
{
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-18", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
Message received1 = mq.Receive (new TimeSpan (0, 0, 2), MessageQueueTransactionType.Single);
}
[Test]
public void ReceiveByIdWithTransactionAndTimeout ()
{
String body = "foo-" + DateTime.Now.ToString ();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-19", true);
mq.Formatter = new BinaryMessageFormatter ();
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.ReceiveById (id, new TimeSpan (0, 0, 2), tx);
tx.Commit ();
Assert.AreEqual (body, received1.Body);
}
}
[Test]
public void ReceiveByIdWithTransactionTypeAndTimeout ()
{
String body = "foo-" + DateTime.Now.ToString ();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-20", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
Message received1 = mq.ReceiveById (id, new TimeSpan (0, 0, 2), MessageQueueTransactionType.Single);
Assert.AreEqual (body, received1.Body);
}
[Test]
public void ReceiveByCorrelationIdWithTransactionAndTimeout ()
{
string correlationId = Guid.NewGuid () + "\\0";
String body = "foo-" + DateTime.Now.ToString ();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
sent1.CorrelationId = correlationId;
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-21", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
tx.Begin ();
Message received1 = mq.ReceiveByCorrelationId (correlationId, new TimeSpan (0, 0, 2), tx);
tx.Commit ();
Assert.AreEqual (body, received1.Body);
}
}
[Test]
public void ReceiveByCorrelationIdWithTransactionTypeAndTimeout ()
{
string correlationId = Guid.NewGuid() + "\\0";
String body = "foo-" + DateTime.Now.ToString();
Message sent1 = new Message (body, new BinaryMessageFormatter ());
sent1.CorrelationId = correlationId;
MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-22", true);
Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
mq.Send (sent1, MessageQueueTransactionType.Single);
string id = sent1.Id;
Message received1 = mq.ReceiveByCorrelationId (correlationId, new TimeSpan (0, 0, 2), MessageQueueTransactionType.Single);
Assert.AreEqual (body, received1.Body);
}
}
}
@@ -0,0 +1,71 @@
//
// AssemblyInfo.cs
//
// Author:
// Andreas Nahr ([email protected])
//
// (C) 2003 Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Resources;
using System.Security;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about the System.Messaging assembly
[assembly: AssemblyTitle ("Mono.Messaging.dll")]
[assembly: AssemblyDescription ("Mono.Messaging.dll")]
[assembly: AssemblyDefaultAlias ("Mono.Messaging.dll")]
[assembly: AssemblyCompany (Consts.MonoCompany)]
[assembly: AssemblyProduct (Consts.MonoProduct)]
[assembly: AssemblyCopyright (Consts.MonoCopyright)]
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: SatelliteContractVersion (Consts.FxVersion)]
[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: ComVisible (false)]
[assembly: CLSCompliant (true)]
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile("../msfinal.pub")]
#if NET_2_0
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
[assembly: Debuggable (DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility (WrapNonExceptionThrows = true)]
#elif NET_1_1
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyConfiguration ("")]
#elif NET_1_0
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyConfiguration ("")]
#endif
@@ -0,0 +1,3 @@
2008-09-29 Michael Barker <[email protected]>
* AssemblyInfo.cs: New
+7
View File
@@ -0,0 +1,7 @@
2008-09-29 Michael Barker <[email protected]>
* Assembly: New
* Test: New
* Makefile: New
* Mono.Messaging.dll.sources: New
* Mono.Messaging_test.dll.sources: New
+10
View File
@@ -0,0 +1,10 @@
thisdir = class/Mono.Messaging
SUBDIRS =
include ../../build/rules.make
LIBRARY = Mono.Messaging.dll
LIB_MCS_FLAGS = /r:System.dll
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169
include ../../build/library.make
@@ -0,0 +1,25 @@
./Assembly/AssemblyInfo.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
./Mono.Messaging/AcknowledgeTypes.cs
./Mono.Messaging/Acknowledgment.cs
./Mono.Messaging/ConnectionException.cs
./Mono.Messaging/CryptographicProviderType.cs
./Mono.Messaging/EncryptionAlgorithm.cs
./Mono.Messaging/EncryptionRequired.cs
./Mono.Messaging/HashAlgorithm.cs
./Mono.Messaging/IMessagingProvider.cs
./Mono.Messaging/IMessageEnumerator.cs
./Mono.Messaging/IMessageQueueTransaction.cs
./Mono.Messaging/IMessageQueue.cs
./Mono.Messaging/IMessage.cs
./Mono.Messaging/MessageBase.cs
./Mono.Messaging/MessagePriority.cs
./Mono.Messaging/MessageQueueTransactionStatus.cs
./Mono.Messaging/MessageQueueTransactionType.cs
./Mono.Messaging/MessageType.cs
./Mono.Messaging/MessageUnavailableException.cs
./Mono.Messaging/MessagingProviderLocator.cs
./Mono.Messaging/MonoMessagingException.cs
./Mono.Messaging/QueueReference.cs
@@ -0,0 +1,47 @@
//
// Mono.Messaging
//
// Authors:
// Peter Van Isacker ([email protected])
//
// (C) 2003 Peter Van Isacker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Flags]
[Serializable]
public enum AcknowledgeTypes
{
FullReachQueue = 5,
FullReceive = 14,
NegativeReceive = 8,
None = 0,
NotAcknowledgeReachQueue = 4,
NotAcknowledgeReceive = 12,
PositiveArrival = 1,
PositiveReceive = 2
}
}
@@ -0,0 +1,55 @@
//
// Mono.Messaging
//
// Authors:
// Peter Van Isacker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Serializable]
public enum Acknowledgment
{
AccessDenied = 32772,
BadDestinationQueue = 32768,
BadEncryption = 32775,
BadSignature = 32774,
CouldNotEncrypt = 32776,
HopCountExceeded = 32773,
None = 0,
NotTransactionalMessage = 32778,
NotTransactionalQueue = 32777,
Purged = 32769,
QueueDeleted = 49152,
QueueExceedMaximumSize = 32771,
QueuePurged = 49153,
ReachQueue = 2,
ReachQueueTimeout = 32770,
Receive = 16384,
ReceiveTimeout = 49154
}
}
@@ -0,0 +1,56 @@
2008-12-07 Michael Barker <[email protected]>
* MessageUnavailableException.cs: Specific exception for messages not being
available on the queue.
* QueueReference.cs: Change queue name to return "private$" as required.
2008-11-23 Michael Barker <[email protected]>
* IMessageQueue.cs: Added support for MessageQueueTransactionType,
ReceiveBy{Id,CorrelationId} and PeekBy{Id,CorrelationId} methods.
2008-11-09 Michael Barker <[email protected]>
* MessageQueueTransactionType.cs: New, copy of
System.Messaging.MessageQueueTransactionStatus.cs
2008-11-02 Michael Barker <[email protected]>
* IMessageQueueTransaction.cs: New, interface for supporting transactions
* MessageQueueTransactionStatus.cs: New, straight copy of the class from
System.Messaging
* IMessageQueue.cs: Added methods for transactional delivery and purging
queues.
* IMessageQueueProvider.cs: Added method for creating transactions and
deleting queues.
2008-10-26 Michael Barker <[email protected]>
* ConnectionException.cs: Added support for InnerExceptions
* MessageBase.cs: Added check for delivered messages and throwing exceptions
for appropriate properties. Add null argument checks for some byte[]
properties.
* IMessage.cs: Added SentTime to the list of delivery properties.
2008-10-12 Michael Barker <[email protected]>
* IMessageEnumerator.cs: New
2008-09-29 Michael Barker <[email protected]>
* AcknowledgeTypes.cs: New
* Acknowledgment.cs: New
* ConnectionException.cs: New
* CryptographicProviderType.cs: New
* EncryptionAlgorithm.cs: New
* EncryptionRequired.cs: New
* HashAlgorithm.cs: New
* IMessage.cs: New
* IMessageQueue.cs: New
* IMessagingProvider.cs: New
* MessageBase.cs: New
* MessagePriority.cs: New
* MessageType.cs: New
* MessagingProviderLocator.cs: New
* MonoMessagingException.cs: New
* QueueReference.cs: New
@@ -0,0 +1,54 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging {
public class ConnectionException : MonoMessagingException {
private readonly QueueReference qRef;
public ConnectionException (QueueReference qRef, Exception e)
: base ("Unable to connect to Queue", e)
{
this.qRef = qRef;
}
public ConnectionException (QueueReference qRef)
: base ("Unable to connect to Queue")
{
this.qRef = qRef;
}
public QueueReference QRef {
get { return qRef; }
}
}
}
@@ -0,0 +1,50 @@
//
// Mono.Messaging
//
// Authors:
// Peter Van Isacker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Serializable]
public enum CryptographicProviderType
{
Dss = 3,
Fortezza = 4,
MicrosoftExchange = 5,
None = 0,
RsaFull = 1,
RsqSig = 2,
Ssl = 6,
SttAcq = 8,
SttBrnd = 9,
SttIss = 11,
SttMer = 7,
SttRoot = 10
}
}
@@ -0,0 +1,41 @@
//
// Mono.Messaging
//
// Authors:
// Peter Van Isacker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Serializable]
public enum EncryptionAlgorithm
{
None = 0,
Rc2 = 26114,
Rc4 = 26625
}
}
@@ -0,0 +1,41 @@
//
// Mono.Messaging
//
// Authors:
// Peter Van Isacker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Serializable]
public enum EncryptionRequired
{
Body = 2,
None = 0,
Optional = 1
}
}
@@ -0,0 +1,44 @@
//
// Mono.Messaging
//
// Authors:
// Peter Van Isacker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Serializable]
public enum HashAlgorithm
{
Mac = 32773,
Md2 = 32769,
Md4 = 32770,
Md5 = 32771,
None = 0,
Sha = 32772
}
}
@@ -0,0 +1,214 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
namespace Mono.Messaging {
public interface IMessage {
AcknowledgeTypes AcknowledgeType {
get; set;
}
Acknowledgment Acknowledgment {
get;
}
IMessageQueue AdministrationQueue {
get; set;
}
int AppSpecific {
get; set;
}
DateTime ArrivedTime {
get;
}
bool AttachSenderId {
get; set;
}
bool Authenticated {
get;
}
string AuthenticationProviderName {
get; set;
}
CryptographicProviderType AuthenticationProviderType {
get; set;
}
Stream BodyStream {
get; set;
}
int BodyType {
get; set;
}
Guid ConnectorType {
get; set;
}
string CorrelationId {
get; set;
}
IMessageQueue DestinationQueue {
get;
}
byte[] DestinationSymmetricKey {
get; set;
}
byte[] DigitalSignature {
get; set;
}
EncryptionAlgorithm EncryptionAlgorithm {
get; set;
}
byte[] Extension {
get; set;
}
HashAlgorithm HashAlgorithm {
get; set;
}
string Id {
get;
}
bool IsFirstInTransaction {
get;
}
bool IsLastInTransaction {
get;
}
string Label {
get;
set;
}
MessageType MessageType {
get;
}
MessagePriority Priority {
get; set;
}
bool Recoverable {
get; set;
}
IMessageQueue ResponseQueue {
get; set;
}
byte[] SenderCertificate {
get; set;
}
byte[] SenderId {
get;
}
long SenderVersion {
get;
}
DateTime SentTime {
get;
}
string SourceMachine {
get;
}
TimeSpan TimeToBeReceived {
get; set;
}
TimeSpan TimeToReachQueue {
get; set;
}
string TransactionId {
get;
}
IMessageQueue TransactionStatusQueue {
get; set;
}
bool UseAuthentication {
get; set;
}
bool UseDeadLetterQueue {
get; set;
}
bool UseEncryption {
get; set;
}
bool UseJournalQueue {
get; set;
}
bool UseTracing {
get; set;
}
void SetDeliveryInfo (Acknowledgment acknowledgment,
DateTime arrivedTime,
IMessageQueue destinationQueue,
string id,
MessageType messageType,
byte[] senderId,
long senderVersion,
DateTime sentTime,
string sourceMachine,
string transactionId);
}
}
@@ -0,0 +1,63 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.ComponentModel;
namespace Mono.Messaging {
public interface IMessageEnumerator : IDisposable {
IMessage Current { get; }
void Close();
void Dispose(bool disposing);
bool MoveNext();
//bool MoveNext(TimeSpan timeout);
IMessage RemoveCurrent();
IMessage RemoveCurrent(IMessageQueueTransaction transaction);
IMessage RemoveCurrent(MessageQueueTransactionType transactionType);
//IMessage RemoveCurrent(TimeSpan timeout);
//IMessage RemoveCurrent(TimeSpan timeout, MessageQueueTransaction transaction);
//IMessage RemoveCurrent(TimeSpan timeout, MessageQueueTransactionType transactionType);
}
}
@@ -0,0 +1,171 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.ComponentModel;
namespace Mono.Messaging {
public interface IMessageQueue {
bool Authenticate {
get; set;
}
short BasePriority {
get; set;
}
bool CanRead {
get;
}
bool CanWrite {
get;
}
Guid Category {
get; set;
}
DateTime CreateTime {
get;
}
bool DenySharedReceive {
get; set;
}
EncryptionRequired EncryptionRequired {
get; set;
}
Guid Id {
get;
}
DateTime LastModifyTime {
get;
}
long MaximumJournalSize {
get; set;
}
long MaximumQueueSize {
get; set;
}
IntPtr ReadHandle {
get;
}
ISynchronizeInvoke SynchronizingObject {
get; set;
}
bool Transactional {
get;
}
bool UseJournalQueue {
get; set;
}
IntPtr WriteHandle {
get;
}
QueueReference QRef {
get; set;
}
void Close ();
void Purge ();
void Send (IMessage message);
void Send (IMessage message, IMessageQueueTransaction transaction);
void Send (IMessage message, MessageQueueTransactionType transactionType);
IMessage Peek ();
IMessage Peek (TimeSpan timeout);
IMessage PeekById (string id);
IMessage PeekById (string id, TimeSpan timeout);
IMessage PeekByCorrelationId (string correlationId);
IMessage PeekByCorrelationId (string correlationId, TimeSpan timeout);
IMessage Receive ();
IMessage Receive (TimeSpan timeout);
IMessage Receive (IMessageQueueTransaction transaction);
IMessage Receive (TimeSpan timeout, IMessageQueueTransaction transaction);
IMessage Receive (MessageQueueTransactionType transactionType);
IMessage Receive (TimeSpan timeout, MessageQueueTransactionType transactionType);
IMessage ReceiveById (string id);
IMessage ReceiveById (string id, TimeSpan timeout);
IMessage ReceiveById (string id, IMessageQueueTransaction transaction);
IMessage ReceiveById (string id, MessageQueueTransactionType transactionType);
IMessage ReceiveById (string id, TimeSpan timeout, IMessageQueueTransaction transaction);
IMessage ReceiveById (string id, TimeSpan timeout, MessageQueueTransactionType transactionType);
IMessage ReceiveByCorrelationId (string correlationId);
IMessage ReceiveByCorrelationId (string correlationId, TimeSpan timeout);
IMessage ReceiveByCorrelationId (string correlationId, IMessageQueueTransaction transaction);
IMessage ReceiveByCorrelationId (string correlationId, MessageQueueTransactionType transactionType);
IMessage ReceiveByCorrelationId (string correlationId, TimeSpan timeout, IMessageQueueTransaction transaction);
IMessage ReceiveByCorrelationId (string correlationId, TimeSpan timeout, MessageQueueTransactionType transactionType);
IMessageEnumerator GetMessageEnumerator ();
}
}
@@ -0,0 +1,47 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.ComponentModel;
namespace Mono.Messaging {
public interface IMessageQueueTransaction : IDisposable {
MessageQueueTransactionStatus Status { get; }
void Abort ();
void Begin ();
void Commit ();
}
}
@@ -0,0 +1,51 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Mono.Messaging {
public interface IMessagingProvider {
bool Exists (QueueReference qRef);
IMessageQueue CreateMessageQueue (QueueReference qRef,
bool transactional);
IMessageQueue GetMessageQueue (QueueReference qRef);
IMessage CreateMessage ();
IMessageQueueTransaction CreateMessageQueueTransaction ();
void DeleteQueue (QueueReference qRef);
IMessageQueue[] GetPublicQueues ();
}
}
@@ -0,0 +1,356 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
namespace Mono.Messaging {
public class MessageBase : IMessage {
AcknowledgeTypes acknowledgeType;
Acknowledgment acknowledgment;
IMessageQueue administrationQueue = null;
int appSpecific;
DateTime arrivedTime;
bool attachSenderId = true;
bool authenticated;
string authenticationProviderName = "Microsoft Base Cryptographic Provider, Ver. 1.0";
CryptographicProviderType authenticationProviderType
= CryptographicProviderType.RsaFull;
Stream bodyStream;
int bodyType;
Guid connectorType = Guid.Empty;
string correlationId;
IMessageQueue destinationQueue;
byte[] destinationSymmetricKey = new byte[0];
byte[] digitalSignature = new byte[0];
EncryptionAlgorithm encryptionAlgorithm
= EncryptionAlgorithm.Rc2;
byte[] extension = new byte[0];
HashAlgorithm hashAlgorithm = HashAlgorithm.Sha;
string id = Guid.Empty.ToString () + "\\0";
bool isFirstInTransaction = false;
bool isLastInTransaction = false;
string label = "";
MessageType messageType;
MessagePriority priority = MessagePriority.Normal;
bool recoverable = false;
IMessageQueue responseQueue;
byte[] senderCertificate = new byte[0];
byte[] senderId = new byte[0];
long senderVersion;
DateTime sentTime;
string sourceMachine;
TimeSpan timeToBeReceived;
TimeSpan timeToReachQueue;
string transactionId = "";
IMessageQueue transactionStatusQueue;
bool useAuthentication;
bool useDeadLetterQueue;
bool useEncryption;
bool useJournalQueue;
bool useTracing;
bool isDelivered;
public AcknowledgeTypes AcknowledgeType {
get { return acknowledgeType; }
set { acknowledgeType = value; }
}
public Acknowledgment Acknowledgment {
get {
CheckDelivered ();
return acknowledgment;
}
}
public IMessageQueue AdministrationQueue {
get { return administrationQueue; }
set { administrationQueue = value; }
}
public int AppSpecific {
get { return appSpecific; }
set { appSpecific = value; }
}
public DateTime ArrivedTime {
get {
CheckDelivered ();
return arrivedTime;
}
}
public bool AttachSenderId {
get { return attachSenderId; }
set { attachSenderId = value; }
}
public bool Authenticated {
get {
CheckDelivered ();
return authenticated;
}
}
public string AuthenticationProviderName {
get { return authenticationProviderName; }
set { authenticationProviderName = value; }
}
public CryptographicProviderType AuthenticationProviderType {
get { return authenticationProviderType; }
set { authenticationProviderType = value; }
}
public Stream BodyStream {
get { return bodyStream; }
set { bodyStream = value; }
}
public int BodyType {
get { return bodyType; }
set { bodyType = value; }
}
public Guid ConnectorType {
get { return connectorType; }
set { connectorType = value; }
}
public string CorrelationId {
get { return correlationId; }
set { correlationId = value; }
}
public IMessageQueue DestinationQueue {
get {
CheckDelivered ();
return destinationQueue;
}
}
public byte[] DestinationSymmetricKey {
get { return destinationSymmetricKey; }
set {
if (value == null)
throw new ArgumentNullException ("DestinationSymmetricKey can not be null");
destinationSymmetricKey = value;
}
}
public byte[] DigitalSignature {
get { return digitalSignature; }
set {
if (value == null)
throw new ArgumentNullException ("DigitalSignature can not be null");
digitalSignature = value;
}
}
public EncryptionAlgorithm EncryptionAlgorithm {
get { return encryptionAlgorithm; }
set { encryptionAlgorithm = value; }
}
public byte[] Extension {
get { return extension; }
set {
if (value == null)
throw new ArgumentNullException ("Extension can not be null");
extension = value;
}
}
public HashAlgorithm HashAlgorithm {
get { return hashAlgorithm; }
set { hashAlgorithm = value; }
}
public string Id {
get {
//CheckDelivered ();
return id;
}
}
public bool IsFirstInTransaction {
get {
//CheckDelivered ();
return isFirstInTransaction;
}
}
public bool IsLastInTransaction {
get {
//CheckDelivered ();
return isLastInTransaction;
}
}
public string Label {
get { return label; }
set { label = value; }
}
public MessageType MessageType {
get {
CheckDelivered ();
return messageType;
}
}
public MessagePriority Priority {
get { return priority; }
set { priority = value; }
}
public bool Recoverable {
get { return recoverable; }
set { recoverable = value; }
}
public IMessageQueue ResponseQueue {
get { return responseQueue; }
set { responseQueue = value; }
}
public byte[] SenderCertificate {
get { return senderCertificate; }
set { senderCertificate = value; }
}
public byte[] SenderId {
get {
CheckDelivered ();
return senderId;
}
}
public long SenderVersion {
get {
CheckDelivered ();
return senderVersion;
}
}
public DateTime SentTime {
get {
CheckDelivered ();
return sentTime;
}
}
public string SourceMachine {
get {
CheckDelivered ();
return sourceMachine;
}
}
public TimeSpan TimeToBeReceived {
get { return timeToBeReceived; }
set { timeToBeReceived = value; }
}
public TimeSpan TimeToReachQueue {
get { return timeToReachQueue; }
set { timeToReachQueue = value; }
}
public string TransactionId {
get {
//CheckDelivered ();
return transactionId;
}
}
public IMessageQueue TransactionStatusQueue {
get { return transactionStatusQueue; }
set { transactionStatusQueue = value; }
}
public bool UseAuthentication {
get { return useAuthentication; }
set { useAuthentication = value; }
}
public bool UseDeadLetterQueue {
get { return useDeadLetterQueue; }
set { useDeadLetterQueue = value; }
}
public bool UseEncryption {
get { return useEncryption; }
set { useEncryption = value; }
}
public bool UseJournalQueue {
get { return useJournalQueue; }
set { useJournalQueue = value; }
}
public bool UseTracing {
get { return useTracing; }
set { useTracing = value; }
}
private void CheckDelivered ()
{
if (!isDelivered)
throw new InvalidOperationException ("Message has not been delivered");
}
public void SetDeliveryInfo (Acknowledgment acknowledgment,
DateTime arrivedTime,
IMessageQueue destinationQueue,
string id,
MessageType messageType,
byte[] senderId,
long senderVersion,
DateTime sentTime,
string sourceMachine,
string transactionId)
{
this.acknowledgment = acknowledgment;
this.arrivedTime = arrivedTime;
this.destinationQueue = destinationQueue;
this.id = id;
this.messageType = messageType;
this.senderId = senderId;
this.senderVersion = senderVersion;
this.sentTime = sentTime;
this.sourceMachine = sourceMachine;
this.transactionId = transactionId;
this.isDelivered = true;
}
}
}
@@ -0,0 +1,46 @@
//
// Mono.Messaging
//
// Authors:
// Peter Van Isacker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Serializable]
public enum MessagePriority
{
AboveNormal = 4,
High = 5,
Highest = 7,
Low = 2,
Lowest = 0,
Normal = 3,
VeryHigh = 6,
VeryLow = 1
}
}
@@ -0,0 +1,42 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Serializable]
public enum MessageQueueTransactionStatus
{
Aborted = 0,
Committed = 1,
Initialized = 2,
Pending = 3
}
}
@@ -0,0 +1,41 @@
//
// System.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Serializable]
public enum MessageQueueTransactionType
{
Automatic = 1,
None = 0,
Single = 3
}
}
@@ -0,0 +1,41 @@
//
// Mono.Messaging
//
// Authors:
// Peter Van Isacker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging
{
[Serializable]
public enum MessageType
{
Acknowledgment = 1,
Normal = 2,
Report = 3
}
}
@@ -0,0 +1,28 @@
// MessageUnavailableException.cs created with MonoDevelop
// User: mike at 11:46 a 7/12/2008
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
using System;
namespace Mono.Messaging
{
public class MessageUnavailableException : MonoMessagingException
{
public MessageUnavailableException () : base ()
{
}
public MessageUnavailableException (string msg) : base (msg)
{
}
public MessageUnavailableException (string msg, Exception e)
: base (msg, e)
{
}
}
}
@@ -0,0 +1,64 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:(
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
namespace Mono.Messaging
{
public class MessagingProviderLocator
{
private static IMessagingProvider provider = null;
private static readonly object syncObj = new object();
public static IMessagingProvider GetProvider ()
{
//Assembly a = Assembly.Load("Mono.Messaging.RabbitMQ.dll");
//Type[] ts = a.GetTypes ();
//foreach (type in ts)
// Console.WriteLine (type.GetName ());
lock (syncObj) {
if (provider == null) {
Type t = Type.GetType ("Mono.Messaging.RabbitMQ.RabbitMQMessagingProvider, Mono.Messaging.RabbitMQ");
if (t == null)
throw new Exception ("Can't find class");
ConstructorInfo ci = t.GetConstructor (
BindingFlags.Public | BindingFlags.Instance,
Type.DefaultBinder, new Type[0],
new ParameterModifier[0]);
if (ci == null)
throw new Exception ("Can't find constructor");
provider = (IMessagingProvider) ci.Invoke (new object[0]);
}
}
return provider;
}
}
}
@@ -0,0 +1,49 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Messaging {
public class MonoMessagingException : Exception {
public MonoMessagingException () : base ()
{
}
public MonoMessagingException (string msg) : base (msg)
{
}
public MonoMessagingException (string msg, Exception e)
: base (msg, e)
{
}
}
}
@@ -0,0 +1,159 @@
//
// Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Text.RegularExpressions;
namespace Mono.Messaging
{
public sealed class QueueReference
{
private static readonly char[] DELIM = new char[] { '\\' };
private readonly string host;
private readonly bool isPrivate;
private readonly string queue;
public static readonly string LOCALHOST = ".";
public static readonly QueueReference DEFAULT = new QueueReference (LOCALHOST, null, false);
public QueueReference (string host, string queue, bool isPrivate)
{
this.host = host;
this.isPrivate = isPrivate;
this.queue = queue;
}
public string Host {
get {
if (host == LOCALHOST)
return "localhost";
else
return host;
}
}
public string Queue {
get {
if (isPrivate)
return @"private$\" + queue;
else
return queue;
}
}
public bool IsPrivate {
get { return isPrivate; }
}
public QueueReference SetHost (string host)
{
return new QueueReference (host, this.queue, this.isPrivate);
}
public QueueReference SetQueue (string queue)
{
return new QueueReference (this.host, queue, this.isPrivate);
}
public override bool Equals (object other)
{
Console.Write("Equals Called\n");
if (other == null)
return false;
else if (typeof (QueueReference) != other.GetType ())
return false;
else {
QueueReference qr = (QueueReference) other;
return Equals (qr);
}
}
public bool Equals (QueueReference other)
{
return host == other.host
&& isPrivate == other.isPrivate
&& queue == other.queue;
}
public override int GetHashCode ()
{
return queue == null ? 0 : queue.GetHashCode () + host.GetHashCode ();
}
public static QueueReference Parse (string path)
{
string trimedPath = RemoveLeadingSlashes (path);
string[] parts = trimedPath.Split (DELIM, 3);
if (parts.Length == 0) {
throw new ArgumentException ();
} else if (parts.Length == 1) {
return new QueueReference (QueueReference.LOCALHOST, parts[0], false);
} else if (parts.Length == 2) {
return new QueueReference (parts[0], parts[1], false);
} else {
return new QueueReference (parts[0], parts[2], IsPrivateStr (parts[1]));
}
}
public static bool IsPrivateStr (string s)
{
return "private$" == s.ToLower ();
}
public static string RemoveLeadingSlashes (string s)
{
int idx = 0;
while (idx < s.Length && (s[idx] == '\\'))
idx++;
return s.Substring (idx);
}
public override string ToString ()
{
if (IsPrivate) {
return Host + "\\$private\\" + Queue;
} else {
return Host + "\\" + Queue;
}
}
public static bool operator == (QueueReference a, QueueReference b)
{
return a.Equals (b);
}
public static bool operator != (QueueReference a, QueueReference b)
{
return !a.Equals (b);
}
}
}
@@ -0,0 +1,2 @@
Mono.Messaging/MessageBaseTest.cs
Mono.Messaging/QueueReferenceTest.cs
@@ -0,0 +1,4 @@
2008-09-29 Michael Barker <[email protected]>
* MessageBaseTest.cs: New
* QueueReferenceTest.cs: New
@@ -0,0 +1,100 @@
//
// Mono.Messaging.RabbitMQ
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Messaging;
using NUnit.Framework;
namespace MonoTests.Mono.Messaging {
[TestFixture]
public class MessageBaseTest {
[Test]
public void CheckDefaultValues ()
{
Message m = new Message ();
Assert.IsNull (m.Body, "Body default should be Null");
Assert.IsNull (m.Formatter, "Formatter default should null");
Assert.AreEqual (System.Messaging.AcknowledgeTypes.None,
m.AcknowledgeType,
"AcknowledgeType default should be None");
Assert.AreEqual (null, m.AdministrationQueue,
"AdministrationQueue default should be null");
Assert.AreEqual (0, m.AppSpecific, "AppSpecific default should be 0");
Assert.AreEqual (true, m.AttachSenderId, "AttachSenderId default should be true");
Assert.AreEqual ("", m.AuthenticationProviderName,
"AuthenticationProviderName should default to \"\"");
Assert.AreEqual (System.Messaging.CryptographicProviderType.RsaFull,
m.AuthenticationProviderType,
"AuthenticationProviderType should default to RsaFull");
Assert.AreEqual (null, m.BodyStream, "BodyStream should default to null");
Assert.AreEqual (Guid.Empty, m.ConnectorType, "ConnectorType should default to empty");
Assert.AreEqual (null, m.CorrelationId, "CorrelationId should default to null");
Assert.AreEqual (new byte[0], m.DestinationSymmetricKey,
"DestinationSymmetricKey should default to an empty array");
Assert.AreEqual (new byte[0], m.DigitalSignature,
"DigitalSignature default to an empty array");
Assert.AreEqual (System.Messaging.EncryptionAlgorithm.Rc2,
m.EncryptionAlgorithm,
"EncryptionAlgorithm should default to Rc2");
Assert.AreEqual (new byte[0], m.Extension,
"Extension should default to an empty array");
Assert.AreEqual (System.Messaging.HashAlgorithm.Sha, m.HashAlgorithm,
"HashAlgorithm should default to Sha");
Assert.AreEqual (Guid.Empty.ToString (), m.Id, "Id should default to Guid.Empty");
Assert.AreEqual ("", m.Label, "Label should default to \"\"");
Assert.AreEqual (false, m.IsFirstInTransaction, "IsFirstInTransaction should default to false");
Assert.AreEqual (false, m.IsLastInTransaction, "IsLastInTransaction should default to false");
Assert.AreEqual (MessagePriority.Normal, m.Priority,
"Priority should default to Normal");
Assert.AreEqual (false, m.Recoverable, "Recoverable should default to false");
Assert.AreEqual (null, m.ResponseQueue, "ResponseQueue should default to null");
//Assert.AreEqual (null, m.SecurityContext, "SecurityContext should default to null");
Assert.AreEqual (new byte[0], m.SenderCertificate,
"SenderCertificate should default to an empty array");
Assert.AreEqual (Message.InfiniteTimeout, m.TimeToBeReceived,
"TimeToBeReceived should default to InfiniteTimeout");
Assert.AreEqual (Message.InfiniteTimeout, m.TimeToReachQueue,
"TimeToReadQueue should default to InfiniteTimeout");
Assert.AreEqual (false, m.UseAuthentication,
"UseAuthentication should default to false");
Assert.AreEqual (false, m.UseDeadLetterQueue,
"UseDeadLetterQueue should default to false");
Assert.AreEqual (false, m.UseEncryption, "Encryption should default to false");
Assert.AreEqual (false, m.UseJournalQueue,
"UseJournalQueue should default to false");
Assert.AreEqual (false, m.UseTracing, "UseTracing should default to false");
}
}
}
@@ -0,0 +1,85 @@
//
// Test.Mono.Messaging
//
// Authors:
// Michael Barker ([email protected])
//
// (C) 2008 Michael Barker
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Text.RegularExpressions;
using Mono.Messaging;
using NUnit.Framework;
namespace MonoTests.Mono.Messsaging
{
[TestFixture]
public class QueueReferenceTest
{
[Test]
public void Equals ()
{
QueueReference qr1 = new QueueReference ("abc", "def", false);
QueueReference qr2 = new QueueReference ("abc", "def", false);
//Assert.IsTrue(qr1.Equals(qr2), "QueueReferences should be equal");
Assert.AreEqual (qr1, qr2, "QueueReferences should be equal");
}
[Test]
public void Parse ()
{
string[] s = @".\def\ghi".Split (new char[] { '\\' }, 3);
Assert.AreEqual (3, s.Length, "Fail");
Assert.AreEqual (".", s[0], "Fail");
QueueReference qr0 = QueueReference.Parse (@"\\host\$private\myqueue");
Assert.AreEqual ("host", qr0.Host);
Assert.AreEqual (true, qr0.IsPrivate);
Assert.AreEqual ("myqueue", qr0.Queue);
QueueReference qr1 = QueueReference.Parse (@"\\host\myqueue");
Assert.AreEqual ("host", qr1.Host);
Assert.AreEqual (false, qr1.IsPrivate);
Assert.AreEqual ("myqueue", qr1.Queue);
QueueReference qr2 = QueueReference.Parse ("myqueue");
Assert.AreEqual (QueueReference.LOCALHOST, qr2.Host);
Assert.AreEqual (false, qr2.IsPrivate);
Assert.AreEqual ("myqueue", qr2.Queue);
}
[Test]
public void StringLeadingChars ()
{
Assert.AreEqual (@"asdfb\asdfasd",
QueueReference.RemoveLeadingSlashes (@"\\asdfb\asdfasd"),
"Failed to removed slashes");
}
}
}
+13
View File
@@ -0,0 +1,13 @@
2008-12-07 Michael BArker <[email protected]>
* Makefile: Removed apigen, bootstrap and spec. The code for
the generated interfaces is added to source control.
2008-10-20 Atsushi Enomoto <[email protected]>
(This ChangeLog is for Mono integration.)
Patch by Michael Barker (patches are on bug #432471). Imported
RabbitMQ.Client assembly from RabbitMQ project.
http://www.rabbitmq.com/
+12
View File
@@ -0,0 +1,12 @@
This package, the RabbitMQ .NET client library, is dual-licensed under
the Apache License v2 and the Mozilla Public License v1.1.
For the Apache License, please see the file LICENSE-APACHE2.
For the Mozilla Public License, please see the file LICENSE-MPL-RabbitMQ.
For attribution of copyright and other details of provenance, please
refer to the source code.
If you have any questions regarding licensing, please contact us at
[email protected].
+202
View File
@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
@@ -0,0 +1,467 @@
MOZILLA PUBLIC LICENSE
Version 1.1
---------------
1. Definitions.
1.0.1. "Commercial Use" means distribution or otherwise making the
Covered Code available to a third party.
1.1. "Contributor" means each entity that creates or contributes to
the creation of Modifications.
1.2. "Contributor Version" means the combination of the Original
Code, prior Modifications used by a Contributor, and the Modifications
made by that particular Contributor.
1.3. "Covered Code" means the Original Code or Modifications or the
combination of the Original Code and Modifications, in each case
including portions thereof.
1.4. "Electronic Distribution Mechanism" means a mechanism generally
accepted in the software development community for the electronic
transfer of data.
1.5. "Executable" means Covered Code in any form other than Source
Code.
1.6. "Initial Developer" means the individual or entity identified
as the Initial Developer in the Source Code notice required by Exhibit
A.
1.7. "Larger Work" means a work which combines Covered Code or
portions thereof with code not governed by the terms of this License.
1.8. "License" means this document.
1.8.1. "Licensable" means having the right to grant, to the maximum
extent possible, whether at the time of the initial grant or
subsequently acquired, any and all of the rights conveyed herein.
1.9. "Modifications" means any addition to or deletion from the
substance or structure of either the Original Code or any previous
Modifications. When Covered Code is released as a series of files, a
Modification is:
A. Any addition to or deletion from the contents of a file
containing Original Code or previous Modifications.
B. Any new file that contains any part of the Original Code or
previous Modifications.
1.10. "Original Code" means Source Code of computer software code
which is described in the Source Code notice required by Exhibit A as
Original Code, and which, at the time of its release under this
License is not already Covered Code governed by this License.
1.10.1. "Patent Claims" means any patent claim(s), now owned or
hereafter acquired, including without limitation, method, process,
and apparatus claims, in any patent Licensable by grantor.
1.11. "Source Code" means the preferred form of the Covered Code for
making modifications to it, including all modules it contains, plus
any associated interface definition files, scripts used to control
compilation and installation of an Executable, or source code
differential comparisons against either the Original Code or another
well known, available Covered Code of the Contributor's choice. The
Source Code can be in a compressed or archival form, provided the
appropriate decompression or de-archiving software is widely available
for no charge.
1.12. "You" (or "Your") means an individual or a legal entity
exercising rights under, and complying with all of the terms of, this
License or a future version of this License issued under Section 6.1.
For legal entities, "You" includes any entity which controls, is
controlled by, or is under common control with You. For purposes of
this definition, "control" means (a) the power, direct or indirect,
to cause the direction or management of such entity, whether by
contract or otherwise, or (b) ownership of more than fifty percent
(50%) of the outstanding shares or beneficial ownership of such
entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Initial Developer to use, reproduce,
modify, display, perform, sublicense and distribute the Original
Code (or portions thereof) with or without Modifications, and/or
as part of a Larger Work; and
(b) under Patents Claims infringed by the making, using or
selling of Original Code, to make, have made, use, practice,
sell, and offer for sale, and/or otherwise dispose of the
Original Code (or portions thereof).
(c) the licenses granted in this Section 2.1(a) and (b) are
effective on the date Initial Developer first distributes
Original Code under the terms of this License.
(d) Notwithstanding Section 2.1(b) above, no patent license is
granted: 1) for code that You delete from the Original Code; 2)
separate from the Original Code; or 3) for infringements caused
by: i) the modification of the Original Code or ii) the
combination of the Original Code with other software or devices.
2.2. Contributor Grant.
Subject to third party intellectual property claims, each Contributor
hereby grants You a world-wide, royalty-free, non-exclusive license
(a) under intellectual property rights (other than patent or
trademark) Licensable by Contributor, to use, reproduce, modify,
display, perform, sublicense and distribute the Modifications
created by such Contributor (or portions thereof) either on an
unmodified basis, with other Modifications, as Covered Code
and/or as part of a Larger Work; and
(b) under Patent Claims infringed by the making, using, or
selling of Modifications made by that Contributor either alone
and/or in combination with its Contributor Version (or portions
of such combination), to make, use, sell, offer for sale, have
made, and/or otherwise dispose of: 1) Modifications made by that
Contributor (or portions thereof); and 2) the combination of
Modifications made by that Contributor with its Contributor
Version (or portions of such combination).
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
effective on the date Contributor first makes Commercial Use of
the Covered Code.
(d) Notwithstanding Section 2.2(b) above, no patent license is
granted: 1) for any code that Contributor has deleted from the
Contributor Version; 2) separate from the Contributor Version;
3) for infringements caused by: i) third party modifications of
Contributor Version or ii) the combination of Modifications made
by that Contributor with other software (except as part of the
Contributor Version) or other devices; or 4) under Patent Claims
infringed by Covered Code in the absence of Modifications made by
that Contributor.
3. Distribution Obligations.
3.1. Application of License.
The Modifications which You create or to which You contribute are
governed by the terms of this License, including without limitation
Section 2.2. The Source Code version of Covered Code may be
distributed only under the terms of this License or a future version
of this License released under Section 6.1, and You must include a
copy of this License with every copy of the Source Code You
distribute. You may not offer or impose any terms on any Source Code
version that alters or restricts the applicable version of this
License or the recipients' rights hereunder. However, You may include
an additional document offering the additional rights described in
Section 3.5.
3.2. Availability of Source Code.
Any Modification which You create or to which You contribute must be
made available in Source Code form under the terms of this License
either on the same media as an Executable version or via an accepted
Electronic Distribution Mechanism to anyone to whom you made an
Executable version available; and if made available via Electronic
Distribution Mechanism, must remain available for at least twelve (12)
months after the date it initially became available, or at least six
(6) months after a subsequent version of that particular Modification
has been made available to such recipients. You are responsible for
ensuring that the Source Code version remains available even if the
Electronic Distribution Mechanism is maintained by a third party.
3.3. Description of Modifications.
You must cause all Covered Code to which You contribute to contain a
file documenting the changes You made to create that Covered Code and
the date of any change. You must include a prominent statement that
the Modification is derived, directly or indirectly, from Original
Code provided by the Initial Developer and including the name of the
Initial Developer in (a) the Source Code, and (b) in any notice in an
Executable version or related documentation in which You describe the
origin or ownership of the Covered Code.
3.4. Intellectual Property Matters
(a) Third Party Claims.
If Contributor has knowledge that a license under a third party's
intellectual property rights is required to exercise the rights
granted by such Contributor under Sections 2.1 or 2.2,
Contributor must include a text file with the Source Code
distribution titled "LEGAL" which describes the claim and the
party making the claim in sufficient detail that a recipient will
know whom to contact. If Contributor obtains such knowledge after
the Modification is made available as described in Section 3.2,
Contributor shall promptly modify the LEGAL file in all copies
Contributor makes available thereafter and shall take other steps
(such as notifying appropriate mailing lists or newsgroups)
reasonably calculated to inform those who received the Covered
Code that new knowledge has been obtained.
(b) Contributor APIs.
If Contributor's Modifications include an application programming
interface and Contributor has knowledge of patent licenses which
are reasonably necessary to implement that API, Contributor must
also include this information in the LEGAL file.
(c) Representations.
Contributor represents that, except as disclosed pursuant to
Section 3.4(a) above, Contributor believes that Contributor's
Modifications are Contributor's original creation(s) and/or
Contributor has sufficient rights to grant the rights conveyed by
this License.
3.5. Required Notices.
You must duplicate the notice in Exhibit A in each file of the Source
Code. If it is not possible to put such notice in a particular Source
Code file due to its structure, then You must include such notice in a
location (such as a relevant directory) where a user would be likely
to look for such a notice. If You created one or more Modification(s)
You may add your name as a Contributor to the notice described in
Exhibit A. You must also duplicate this License in any documentation
for the Source Code where You describe recipients' rights or ownership
rights relating to Covered Code. You may choose to offer, and to
charge a fee for, warranty, support, indemnity or liability
obligations to one or more recipients of Covered Code. However, You
may do so only on Your own behalf, and not on behalf of the Initial
Developer or any Contributor. You must make it absolutely clear than
any such warranty, support, indemnity or liability obligation is
offered by You alone, and You hereby agree to indemnify the Initial
Developer and every Contributor for any liability incurred by the
Initial Developer or such Contributor as a result of warranty,
support, indemnity or liability terms You offer.
3.6. Distribution of Executable Versions.
You may distribute Covered Code in Executable form only if the
requirements of Section 3.1-3.5 have been met for that Covered Code,
and if You include a notice stating that the Source Code version of
the Covered Code is available under the terms of this License,
including a description of how and where You have fulfilled the
obligations of Section 3.2. The notice must be conspicuously included
in any notice in an Executable version, related documentation or
collateral in which You describe recipients' rights relating to the
Covered Code. You may distribute the Executable version of Covered
Code or ownership rights under a license of Your choice, which may
contain terms different from this License, provided that You are in
compliance with the terms of this License and that the license for the
Executable version does not attempt to limit or alter the recipient's
rights in the Source Code version from the rights set forth in this
License. If You distribute the Executable version under a different
license You must make it absolutely clear that any terms which differ
from this License are offered by You alone, not by the Initial
Developer or any Contributor. You hereby agree to indemnify the
Initial Developer and every Contributor for any liability incurred by
the Initial Developer or such Contributor as a result of any such
terms You offer.
3.7. Larger Works.
You may create a Larger Work by combining Covered Code with other code
not governed by the terms of this License and distribute the Larger
Work as a single product. In such a case, You must make sure the
requirements of this License are fulfilled for the Covered Code.
4. Inability to Comply Due to Statute or Regulation.
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Code due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description
must be included in the LEGAL file described in Section 3.4 and must
be included with all distributions of the Source Code. Except to the
extent prohibited by statute or regulation, such description must be
sufficiently detailed for a recipient of ordinary skill to be able to
understand it.
5. Application of this License.
This License applies to code to which the Initial Developer has
attached the notice in Exhibit A and to related Covered Code.
6. Versions of the License.
6.1. New Versions.
Netscape Communications Corporation ("Netscape") may publish revised
and/or new versions of the License from time to time. Each version
will be given a distinguishing version number.
6.2. Effect of New Versions.
Once Covered Code has been published under a particular version of the
License, You may always continue to use it under the terms of that
version. You may also choose to use such Covered Code under the terms
of any subsequent version of the License published by Netscape. No one
other than Netscape has the right to modify the terms applicable to
Covered Code created under this License.
6.3. Derivative Works.
If You create or use a modified version of this License (which you may
only do in order to apply it to code which is not already Covered Code
governed by this License), You must (a) rename Your license so that
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
"MPL", "NPL" or any confusingly similar phrase do not appear in your
license (except to note that your license differs from this License)
and (b) otherwise make it clear that Your version of the license
contains terms which differ from the Mozilla Public License and
Netscape Public License. (Filling in the name of the Initial
Developer, Original Code or Contributor in the notice described in
Exhibit A shall not of themselves be deemed to be modifications of
this License.)
7. DISCLAIMER OF WARRANTY.
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
8. TERMINATION.
8.1. This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to cure
such breach within 30 days of becoming aware of the breach. All
sublicenses to the Covered Code which are properly granted shall
survive any termination of this License. Provisions which, by their
nature, must remain in effect beyond the termination of this License
shall survive.
8.2. If You initiate litigation by asserting a patent infringement
claim (excluding declatory judgment actions) against Initial Developer
or a Contributor (the Initial Developer or Contributor against whom
You file such action is referred to as "Participant") alleging that:
(a) such Participant's Contributor Version directly or indirectly
infringes any patent, then any and all rights granted by such
Participant to You under Sections 2.1 and/or 2.2 of this License
shall, upon 60 days notice from Participant terminate prospectively,
unless if within 60 days after receipt of notice You either: (i)
agree in writing to pay Participant a mutually agreeable reasonable
royalty for Your past and future use of Modifications made by such
Participant, or (ii) withdraw Your litigation claim with respect to
the Contributor Version against such Participant. If within 60 days
of notice, a reasonable royalty and payment arrangement are not
mutually agreed upon in writing by the parties or the litigation claim
is not withdrawn, the rights granted by Participant to You under
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
the 60 day notice period specified above.
(b) any software, hardware, or device, other than such Participant's
Contributor Version, directly or indirectly infringes any patent, then
any rights granted to You by such Participant under Sections 2.1(b)
and 2.2(b) are revoked effective as of the date You first made, used,
sold, distributed, or had made, Modifications made by that
Participant.
8.3. If You assert a patent infringement claim against Participant
alleging that such Participant's Contributor Version directly or
indirectly infringes any patent where such claim is resolved (such as
by license or settlement) prior to the initiation of patent
infringement litigation, then the reasonable value of the licenses
granted by such Participant under Sections 2.1 or 2.2 shall be taken
into account in determining the amount or value of any payment or
license.
8.4. In the event of termination under Sections 8.1 or 8.2 above,
all end user license agreements (excluding distributors and resellers)
which have been validly granted by You or any distributor hereunder
prior to termination shall survive termination.
9. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
10. U.S. GOVERNMENT END USERS.
The Covered Code is a "commercial item," as that term is defined in
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
software" and "commercial computer software documentation," as such
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
all U.S. Government End Users acquire Covered Code with only those
rights set forth herein.
11. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed by
California law provisions (except to the extent applicable law, if
any, provides otherwise), excluding its conflict-of-law provisions.
With respect to disputes in which at least one party is a citizen of,
or an entity chartered or registered to do business in the United
States of America, any litigation relating to this License shall be
subject to the jurisdiction of the Federal Courts of the Northern
District of California, with venue lying in Santa Clara County,
California, with the losing party responsible for costs, including
without limitation, court costs and reasonable attorneys' fees and
expenses. The application of the United Nations Convention on
Contracts for the International Sale of Goods is expressly excluded.
Any law or regulation which provides that the language of a contract
shall be construed against the drafter shall not apply to this
License.
12. RESPONSIBILITY FOR CLAIMS.
As between Initial Developer and the Contributors, each party is
responsible for claims and damages arising, directly or indirectly,
out of its utilization of rights under this License and You agree to
work with Initial Developer and Contributors to distribute such
responsibility on an equitable basis. Nothing herein is intended or
shall be deemed to constitute any admission of liability.
13. MULTIPLE-LICENSED CODE.
Initial Developer may designate portions of the Covered Code as
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
Developer permits you to utilize portions of the Covered Code under
Your choice of the NPL or the alternative licenses, if any, specified
by the Initial Developer in the file described in Exhibit A.
EXHIBIT A -Mozilla Public License.
``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.mozilla.org/MPL/
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 RabbitMQ.
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 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit
Technologies Ltd.;
All Rights Reserved.
Contributor(s): ______________________________________.''
[NOTE: The text of this Exhibit A may differ slightly from the text of
the notices in the Source Code files of the Original Code. You should
use the text of this Exhibit A rather than the text found in the
Original Code Source Code for Your Modifications.]
+11
View File
@@ -0,0 +1,11 @@
thisdir := class/RabbitMQ.Client
include ../../build/rules.make
#SUBDIRS := src/bootstrap src/apigen docs/specs src/client
SUBDIRS := src/client
.PHONY: all-local $(STD_TARGETS:=-local)
all-local $(STD_TARGETS:=-local):
@:
+64
View File
@@ -0,0 +1,64 @@
NAME=rabbitmq-dotnet-client
NAME_VSN=${NAME}-${RABBIT_VSN}
RELEASE_DIR=releases/${NAME}/v${RABBIT_VSN}
STAGE_RELEASE_DIR=charlotte:/home/rabbitmq/stage-extras/releases/${NAME}
LIVE_RELEASE_DIR=charlotte:/home/rabbitmq/live-extras/releases/${NAME}
RSYNC_CMD=rsync -irvl --delete-after
TMPXMLZIP=${NAME_VSN}-tmp-xmldoc.zip
ifeq "$(RABBIT_VSN)" ""
rabbit-vsn:
@echo "RABBIT_VSN is not set"
@false
else
rabbit-vsn:
endif
deploy-stage: rabbit-vsn ensure-deliverables
${RSYNC_CMD} --exclude=${TMPXMLZIP} releases/${NAME}/ ${STAGE_RELEASE_DIR}
deploy-live: rabbit-vsn ensure-deliverables
${RSYNC_CMD} --exclude=${TMPXMLZIP} releases/${NAME}/ ${LIVE_RELEASE_DIR}
ensure-deliverables: rabbit-vsn
file ${RELEASE_DIR}/${NAME_VSN}.zip
file ${RELEASE_DIR}/${NAME_VSN}-api-guide.pdf
file ${RELEASE_DIR}/${NAME_VSN}-user-guide.pdf
file ${RELEASE_DIR}/${NAME_VSN}-wcf-service-model.pdf
file ${RELEASE_DIR}/${NAME_VSN}-net-2.0.zip
file ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc.zip
file ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc
file ${RELEASE_DIR}/${NAME_VSN}-net-3.0-wcf.zip
file ${RELEASE_DIR}/${NAME_VSN}-net-3.0-wcf-htmldoc.zip
file ${RELEASE_DIR}/${NAME_VSN}-net-3.0-wcf-htmldoc
ensure-prerequisites: rabbit-vsn
dpkg -p htmldoc plotutils transfig graphviz > /dev/null
ensure-release-dir: rabbit-vsn
touch ${RELEASE_DIR}/
ensure-docs: rabbit-vsn
file ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc.zip
file ${RELEASE_DIR}/${TMPXMLZIP}
doc: rabbit-vsn ensure-prerequisites ensure-release-dir ensure-docs
rm -rf build/tmpdoc build/doc
mkdir -p build/tmpdoc/html build/tmpdoc/xml
unzip -j ${RELEASE_DIR}/${NAME_VSN}-net-2.0-htmldoc.zip -d build/tmpdoc/html
unzip -j ${RELEASE_DIR}/${NAME_VSN}-tmp-xmldoc.zip -d build/tmpdoc/xml
cd docs && ./api-guide.sh && \
mv api-guide.pdf ../${RELEASE_DIR}/${NAME_VSN}-api-guide.pdf
$(MAKE) -C docs
mv build/doc/userguide/user-guide.pdf ${RELEASE_DIR}/${NAME_VSN}-user-guide.pdf
cp docs/"RabbitMQ Service Model.pdf" \
${RELEASE_DIR}/${NAME_VSN}-wcf-service-model.pdf
cd ${RELEASE_DIR} && \
rm -rf ${NAME_VSN}-net-2.0-htmldoc && \
unzip ${NAME_VSN}-net-2.0-htmldoc.zip && \
rm -rf unzip ${NAME_VSN}-net-3.0-wcf-htmldoc && \
unzip ${NAME_VSN}-net-3.0-wcf-htmldoc.zip
+13
View File
@@ -0,0 +1,13 @@
README for RabbitMQ .NET client, version @FULLVERSION@
===========================================================================
* Building the client (source distribution only)
---------------------------------------------------------------------------
Please see the instructions in docs/wikipages/data.BuildingTheClient.txt,
or the equivalent chapter in the User's Guide PDF. (Briefly, configure
local.build and run NAnt.)
The Microsoft .NET framework v3.0 is required to build the WCF
binding. Please see docs/wikipages/data.BuildingTheWcfBinding.txt.
@@ -0,0 +1,6 @@
<!-- NAnt build file. -*- nxml -*- -->
<project>
<property name="target.framework" value="net-1.1" />
<property name="debug" value="true"/>
<property name="python.exec" value="python.exe"/>
</project>
@@ -0,0 +1,6 @@
<!-- NAnt build file. -*- nxml -*- -->
<project>
<property name="target.framework" value="net-2.0" />
<property name="debug" value="true"/>
<property name="python.exec" value="python.exe"/>
</project>
@@ -0,0 +1,7 @@
<!-- NAnt build file. -*- nxml -*- -->
<project>
<property name="target.framework" value="mono-1.0" />
<property name="debug" value="true"/>
<property name="msbuild" value="xbuild"/>
<property name="python.exec" value="python"/>
</project>
@@ -0,0 +1,7 @@
<!-- NAnt build file. -*- nxml -*- -->
<project>
<property name="target.framework" value="mono-2.0" />
<property name="debug" value="true"/>
<property name="msbuild" value="xbuild"/>
<property name="python.exec" value="python"/>
</project>
+523
View File
@@ -0,0 +1,523 @@
<!-- NAnt build file. -*- nxml -*- -->
<project name="RabbitMQ C# Client" default="build" basedir=".">
<property name="target.framework" value="mono-2.0" />
<property name="debug" value="false"/>
<property name="msbuild" value="msbuild"/>
<property name="build.dir" value="build"/>
<property name="bin.dir" value="${build.dir}/bin" />
<property name="dist.dir" value="${build.dir}/dist" />
<property name="wcf.dist.dir" value="${dist.dir}/wcf" />
<property name="doc.dir" value="${build.dir}/doc" />
<property name="gendoc.xml.dir" value="${doc.dir}/xml" />
<property name="gendoc.html.dir" value="${doc.dir}/html" />
<property name="gensrc.dir" value="${build.dir}/gensrc" />
<property name="apigen.exename" value="${bin.dir}/rabbitmq-dotnet-apigen.exe" />
<property name="target.dllname.base" value="RabbitMQ.Client" />
<property name="target.dllname" value="${bin.dir}/${target.dllname.base}.dll" />
<property name="bootstrap.dllname" value="${bin.dir}/apigen-bootstrap.dll" />
<property name="existence.test.probe" value="${gensrc.dir}/autogenerated-api-0-9.cs"/>
<property name="unit-tests.dllname" value="${bin.dir}/unit-tests.dll"/>
<property name="nunit.dllname" value="src/unit/nunit/nunit.framework.dll"/>
<property name="core.assemblyinfo.src" value="src/client/api/AssemblyInfo.cs.in"/>
<property name="core.assemblyinfo.target" value="${gensrc.dir}/AssemblyInfo.cs"/>
<property name="wcf.assemblyinfo.src" value="src/wcf/RabbitMQ.ServiceModel/AssemblyInfo.cs.in"/>
<property name="wcf.assemblyinfo.target" value="src/wcf/RabbitMQ.ServiceModel/AssemblyInfo.cs"/>
<property name="wcf.bin.dir" value="src/wcf/RabbitMQ.ServiceModel/bin"/>
<property name="wcf.test.bin.dir" value="src/wcf/Test/bin"/>
<property name="hg.exec" value="/usr/bin/hg" />
<include buildfile="local.build" />
<include buildfile="configs/${config.name}.build" />
<property name="nant.settings.currentframework" value="${target.framework}" />
<property name="fullversion" value="${version.major.minor.release}"/>
<property name="version.assembly" value="${fullversion}.0" />
<property name="nameversion" value="rabbitmq-dotnet-client-${fullversion}"/>
<property name="release.dir" value="releases/rabbitmq-dotnet-client"/>
<property name="release.version.dir" value="${release.dir}/v${fullversion}"/>
<property name="release.src.zip" value="${nameversion}.zip" />
<target name="clean" description="remove all generated files"
depends="clean-base,clean-wcf" />
<target name="clean-base" description="remove all generated files in the core client">
<delete dir="${build.dir}" failonerror="false" />
</target>
<target name="clean-wcf" description="remove all generated files in the WCF binding">
<delete dir="${wcf.bin.dir}" failonerror="false" />
<delete dir="${wcf.test.bin.dir}" failonerror="false" />
<delete dir="src/wcf/RabbitMQ.ServiceModel/obj" failonerror="false" />
<delete dir="src/wcf/Test/obj" failonerror="false" />
<delete dir="src/wcf/ConfigDemo/Client/bin" failonerror="false"/>
<delete dir="src/wcf/ConfigDemo/Client/obj" failonerror="false"/>
<delete dir="src/wcf/ConfigDemo/Server/bin" failonerror="false"/>
<delete dir="src/wcf/ConfigDemo/Server/obj" failonerror="false"/>
<delete dir="src/wcf/ConfigDemo/WcfServiceLibrary1/bin" failonerror="false"/>
<delete dir="src/wcf/ConfigDemo/WcfServiceLibrary1/obj" failonerror="false"/>
<delete file="${wcf.assemblyinfo.target}" failonerror="false"/> <!-- it's autogenerated -->
</target>
<target name="generate-assemblyinfo">
<if test="${(not file::up-to-date(gen.assemblyinfo.src, gen.assemblyinfo.target))}">
<delete file="${gen.assemblyinfo.target}" failonerror="false" />
<copy file="${gen.assemblyinfo.src}" tofile="${gen.assemblyinfo.target}">
<filterchain>
<replacetokens>
<token key="VERSION" value="${version.assembly}" />
</replacetokens>
</filterchain>
</copy>
</if>
</target>
<target name="build" description="compiles the source code"
depends="generate-api">
<mkdir dir="${bin.dir}" />
<mkdir dir="${doc.dir}" />
<property name="gen.assemblyinfo.src" value="${core.assemblyinfo.src}"/>
<property name="gen.assemblyinfo.target" value="${core.assemblyinfo.target}"/>
<call target="generate-assemblyinfo"/>
<csc target="library"
output="${target.dllname}"
doc="${bin.dir}/${target.dllname.base}.xml"
debug="${debug}">
<sources>
<include name="src/client/**/*.cs" />
<include name="src/util/**/*.cs" />
<include name="${gensrc.dir}/**/*.cs" />
</sources>
<nowarn>
<warning number="1591"/>
</nowarn>
</csc>
</target>
<target name="build-wcf" description="Builds the WCF component. Requires .NET 3.0."
depends="build">
<property name="gen.assemblyinfo.src" value="${wcf.assemblyinfo.src}"/>
<property name="gen.assemblyinfo.target" value="${wcf.assemblyinfo.target}"/>
<call target="generate-assemblyinfo"/>
<exec program="${msbuild}" workingdir="src/wcf/RabbitMQ.ServiceModel">
<arg value="RabbitMQ.ServiceModel.csproj"/>
</exec>
</target>
<target name="wcf-examples" description="Builds the WCF examples. Requires .NET 3.0."
depends="build-wcf">
<exec program="${msbuild}" workingdir="src/wcf/Test">
<arg value="RabbitMQ.ServiceModel.Test.csproj"/>
</exec>
<exec program="${msbuild}" workingdir="src/wcf/ConfigDemo/WcfServiceLibrary1">
<arg value="WcfServiceLibrary1.csproj"/>
</exec>
<exec program="${msbuild}" workingdir="src/wcf/ConfigDemo/Server">
<arg value="Server.csproj"/>
</exec>
<exec program="${msbuild}" workingdir="src/wcf/ConfigDemo/Client">
<arg value="Client.csproj"/>
</exec>
</target>
<target name="wcf-doc" description="produces HTML documentation from the code"
depends="build-wcf">
<property name="wcf.xml.dir" value="${wcf.bin.dir}/Debug/doc/xml"/>
<property name="wcf.html.dir" value="${wcf.bin.dir}/Debug/doc/html"/>
<delete dir="${wcf.xml.dir}" failonerror="false" />
<delete dir="${wcf.html.dir}" failonerror="false" />
<mkdir dir="${wcf.xml.dir}" />
<mkdir dir="${wcf.html.dir}" />
<exec program="tools/ndocproc-bin/bin/ndocproc.exe" useruntimeengine="true">
<arg value="/nosubtypes"/>
<arg value="${wcf.xml.dir}"/>
<arg value="${wcf.bin.dir}/Debug/RabbitMQ.ServiceModel.xml"/>
<arg value="docs/namespaces.xml"/>
</exec>
<nant buildfile="tools/ndocproc-bin/xsl/transform-xml.build">
<properties>
<property name="xml.dir" value="${project::get-base-directory()}/${wcf.xml.dir}"/>
<property name="html.dir" value="${project::get-base-directory()}/${wcf.html.dir}"/>
</properties>
</nant>
<copy file="tools/ndocproc-bin/xsl/style.css" todir="${wcf.html.dir}"/>
</target>
<target name="stamp" description="removes the version identifier, so that the next build generates a fresh one">
<delete file="${assemblyinfo.target}" failonerror="false" />
</target>
<target name="doc" description="produces HTML documentation from the code"
depends="build,generate-docs,copy-stylesheet" />
<target name="generate-docs">
<delete dir="${gendoc.xml.dir}" failonerror="false" />
<delete dir="${gendoc.html.dir}" failonerror="false" />
<mkdir dir="${gendoc.xml.dir}" />
<mkdir dir="${gendoc.html.dir}" />
<exec program="tools/ndocproc-bin/bin/ndocproc.exe" useruntimeengine="true">
<arg value="/nosubtypes"/>
<arg value="/suppress:RabbitMQ.Client.Framing.v0_8"/>
<arg value="/suppress:RabbitMQ.Client.Framing.v0_8qpid"/>
<arg value="/suppress:RabbitMQ.Client.Framing.v0_9"/>
<arg value="/suppress:RabbitMQ.Client.Framing.Impl.v0_8"/>
<arg value="/suppress:RabbitMQ.Client.Framing.Impl.v0_8qpid"/>
<arg value="/suppress:RabbitMQ.Client.Framing.Impl.v0_9"/>
<arg value="/suppress:RabbitMQ.Client.Impl"/>
<arg value="/suppress:RabbitMQ.Client.Apigen.Attributes"/>
<arg value="${gendoc.xml.dir}"/>
<arg value="${bin.dir}/${target.dllname.base}.xml"/>
<arg value="docs/namespaces.xml"/>
</exec>
<nant buildfile="tools/ndocproc-bin/xsl/transform-xml.build">
<properties>
<property name="xml.dir" value="${project::get-base-directory()}/${gendoc.xml.dir}"/>
<property name="html.dir" value="${project::get-base-directory()}/${gendoc.html.dir}"/>
</properties>
</nant>
</target>
<target name="copy-stylesheet">
<copy file="tools/ndocproc-bin/xsl/style.css" todir="${gendoc.html.dir}"/>
</target>
<target name="generate-api" description="runs apigen to build the autogen part of the client"
depends="apigen">
<if test="${(not file::up-to-date(bootstrap.dllname,existence.test.probe)) or
(not file::up-to-date(apigen.exename,existence.test.probe))}">
<delete file="${existence.test.probe}" failonerror="false"/>
</if>
<if test="${not file::exists(existence.test.probe)}">
<mkdir dir="${gensrc.dir}" />
<exec program="${apigen.exename}" useruntimeengine="true">
<arg value="/apiName:AMQP_0_9"/>
<arg value="docs/specs/amqp0-9.xml"/>
<arg value="${gensrc.dir}/autogenerated-api-0-9.cs" />
</exec>
<exec program="${apigen.exename}" useruntimeengine="true">
<arg value="/apiName:AMQP_0_8_QPID"/>
<arg value="/n:v0_8qpid"/>
<arg value="docs/specs/qpid-amqp.0-8.xml"/>
<arg value="${gensrc.dir}/autogenerated-api-qpid-0-8.cs" />
</exec>
<exec program="${apigen.exename}" useruntimeengine="true">
<arg value="/apiName:AMQP_0_8"/>
<arg value="/n:v0_8"/>
<arg value="docs/specs/amqp0-8.xml"/>
<arg value="${gensrc.dir}/autogenerated-api-0-8.cs" />
</exec>
</if>
</target>
<target name="apigen" description="compile the API autogeneration tool"
depends="bootstrap-model">
<mkdir dir="${bin.dir}" />
<csc target="exe" output="${apigen.exename}" debug="true">
<sources>
<include name="src/apigen/**/*.cs" />
</sources>
<references>
<include name="${bootstrap.dllname}"/>
</references>
</csc>
</target>
<target name="bootstrap-model" description="compile the apigen bootstrap DLL">
<mkdir dir="${bin.dir}" />
<csc target="library"
output="${bootstrap.dllname}"
debug="${debug}">
<sources>
<include name="src/client/api/IModel.cs" />
<include name="src/client/api/IContentHeader.cs" />
<include name="src/client/api/IBasicProperties.cs" />
<include name="src/client/api/IFileProperties.cs" />
<include name="src/client/api/IStreamProperties.cs" />
<include name="src/client/api/AmqpTimestamp.cs" />
<include name="src/client/api/IBasicConsumer.cs" />
<include name="src/client/api/ShutdownEventArgs.cs" />
<include name="src/client/api/ShutdownInitiator.cs" />
<include name="src/client/api/PublicationAddress.cs" />
<include name="src/client/events/BasicReturnEventArgs.cs" />
<include name="src/client/events/BasicReturnEventHandler.cs" />
<include name="src/client/events/CallbackExceptionEventArgs.cs" />
<include name="src/client/events/CallbackExceptionEventHandler.cs" />
<include name="src/client/events/ModelShutdownEventHandler.cs"/>
</sources>
</csc>
</target>
<target name="one-example">
<csc target="exe" output="${bin.dir}/${example.program}.exe" debug="true">
<sources>
<include name="src/examples/${example.program}.cs" />
</sources>
<references>
<include name="${target.dllname}"/>
</references>
</csc>
</target>
<target name="examples" description="compile C# client sample code"
depends="build">
<mkdir dir="${bin.dir}" />
<property name="example.program" value="SendString"/><call target="one-example"/>
<property name="example.program" value="SendMap"/><call target="one-example"/>
<property name="example.program" value="LogTail"/><call target="one-example"/>
<property name="example.program" value="SingleGet"/><call target="one-example"/>
<property name="example.program" value="ExceptionTest"/><call target="one-example"/>
<property name="example.program" value="DeclareQueue"/><call target="one-example"/>
<property name="example.program" value="AddServer"/><call target="one-example"/>
<property name="example.program" value="AddClient"/><call target="one-example"/>
</target>
<target name="build-unit" description="compile unit tests"
depends="build">
<mkdir dir="${bin.dir}" />
<csc target="library" output="${unit-tests.dllname}" debug="true">
<sources>
<include name="src/unit/*.cs" />
</sources>
<references>
<include name="${target.dllname}"/>
<include name="${nunit.dllname}"/>
</references>
</csc>
<copy file="${nunit.dllname}" todir="${bin.dir}"/>
</target>
<target name="unit" description="run unit tests"
depends="build-unit">
<exec program="src/unit/nunit/nunit-console.exe" useruntimeengine="true">
<arg value="${unit-tests.dllname}"/>
</exec>
</target>
<target name="dist" description="build a binary distribution zip"
depends="clean,doc,build-doc-zip,dist-dir,build-dist-zip"/>
<target name="wcf-dist" description="build a binary distribution zip"
depends="clean,doc,build-doc-zip,wcf-doc,build-wcf-doc-zip,wcf-dist-dir,build-wcf-dist-zip"/>
<target name="build-doc-zip" description="(internal) zips up a HTML doc distribution">
<property name="fq.dist"
value="${nameversion}-${target.framework}-htmldoc"/>
<property name="doc.zip.source.dir" value="${gendoc.html.dir}"/>
<call target="generic-build-doc-zip"/>
</target>
<target name="build-wcf-doc-zip" description="(internal) zips up a WCF HTML doc distribution">
<property name="fq.dist"
value="${nameversion}-net-3.0-wcf-htmldoc"/>
<property name="doc.zip.source.dir" value="${wcf.bin.dir}/Debug/doc/html"/>
<call target="generic-build-doc-zip"/>
</target>
<target name="generic-build-doc-zip">
<property name="fq.dist.dir" value="${build.dir}/${fq.dist}"/>
<property name="fq.dist.zipname" value="${fq.dist.dir}.zip"/>
<mkdir dir="${fq.dist.dir}"/>
<copy todir="${fq.dist.dir}">
<fileset basedir="${doc.zip.source.dir}">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${fq.dist.dir}">
<fileset>
<include name="LICENSE"/>
<include name="LICENSE-APACHE2"/>
<include name="LICENSE-MPL-RabbitMQ"/>
</fileset>
</copy>
<zip zipfile="${fq.dist.zipname}" encoding="ASCII">
<fileset basedir="${fq.dist.dir}" prefix="${fq.dist}">
<include name="**/*"/>
</fileset>
</zip>
<delete dir="${fq.dist.dir}"/>
</target>
<target name="build-dist-zip" description="(internal) zips up a binary distribution">
<property name="basename.suffix" value=""/>
<call target="generic-build-dist-zip"/>
</target>
<target name="build-wcf-dist-zip" description="(internal) zips up a binary distribution">
<property name="target.framework" value="net-3.0"/>
<property name="basename.suffix" value="-wcf"/>
<call target="generic-build-dist-zip"/>
</target>
<target name="generic-build-dist-zip" description="(internal) zips up a binary distribution">
<property name="fq.dist" value="${nameversion}-${target.framework}${basename.suffix}"/>
<property name="fq.dist.dir" value="${build.dir}/${fq.dist}"/>
<property name="fq.dist.zipname" value="${fq.dist.dir}.zip"/>
<move todir="${fq.dist.dir}">
<fileset basedir="${dist.dir}">
<include name="**/*"/>
</fileset>
</move>
<delete dir="${dist.dir}"/>
<zip zipfile="${fq.dist.zipname}" encoding="ASCII">
<fileset basedir="${fq.dist.dir}" prefix="${fq.dist}">
<include name="**/*"/>
</fileset>
</zip>
<delete dir="${fq.dist.dir}"/>
</target>
<target name="dist-dir" description="clean and build a binary distribution (not packed into a zip)"
depends="clean,examples,build-dist-dir"/>
<target name="wcf-dist-dir" description="clean and build a WCF binary distribution (not packed into a zip)"
depends="dist-dir,wcf-examples,build-wcf-dist-dir"/>
<target name="build-dist-dir" description="(internal) just copy files into a dist dir, without cleaning or stamping">
<delete dir="${dist.dir}" failonerror="false"/>
<mkdir dir="${dist.dir}"/>
<copy todir="${dist.dir}">
<fileset>
<include name="README.txt"/>
<include name="LICENSE"/>
<include name="LICENSE-APACHE2"/>
<include name="LICENSE-MPL-RabbitMQ"/>
</fileset>
<filterchain>
<replacetokens>
<token key="FULLVERSION" value="${fullversion}" />
</replacetokens>
</filterchain>
</copy>
<mkdir dir="${dist.dir}/bin"/>
<copy todir="${dist.dir}/bin" flatten="true">
<fileset>
<include name="${target.dllname}"/>
<include name="${bin.dir}/SendString.exe"/>
<include name="${bin.dir}/SendMap.exe"/>
<include name="${bin.dir}/LogTail.exe"/>
<include name="${bin.dir}/SingleGet.exe"/>
<include name="${bin.dir}/ExceptionTest.exe"/>
<include name="${bin.dir}/DeclareQueue.exe"/>
</fileset>
</copy>
<mkdir dir="${dist.dir}/examples"/>
<copy todir="${dist.dir}/examples">
<fileset basedir="src/examples">
<include name="**/*.cs"/>
</fileset>
</copy>
</target>
<target name="build-wcf-dist-dir" description="(internal) just copy WCF files into a dist dir, without cleaning or stamping">
<delete dir="${wcf.dist.dir}" failonerror="false"/>
<mkdir dir="${wcf.dist.dir}"/>
<mkdir dir="${wcf.dist.dir}/bin"/>
<copy todir="${wcf.dist.dir}/bin">
<fileset basedir="${wcf.bin.dir}">
<include name="Debug/*"/>
<exclude name="Debug/doc"/>
<include name="Release/*"/>
<exclude name="Release/doc"/>
</fileset>
</copy>
<mkdir dir="${wcf.dist.dir}/doc"/>
<copy todir="${wcf.dist.dir}/doc">
<fileset basedir="docs">
<include name="RabbitMQ Service Model.*"/>
</fileset>
</copy>
<mkdir dir="${wcf.dist.dir}/examples/basic/bin"/>
<copy todir="${wcf.dist.dir}/examples/basic/bin">
<fileset basedir="${wcf.test.bin.dir}">
<include name="Debug/**/*"/>
<include name="Release/**/*"/>
</fileset>
</copy>
<mkdir dir="${wcf.dist.dir}/examples/basic/source"/>
<copy todir="${wcf.dist.dir}/examples/basic/source">
<fileset basedir="src/wcf/Test">
<include name="**/*.cs"/>
<include name="**/*.csproj"/>
<include name="**/*.config"/>
<exclude name="bin/**/*"/>
</fileset>
</copy>
<mkdir dir="${wcf.dist.dir}/examples/config-demo/bin"/>
<copy todir="${wcf.dist.dir}/examples/config-demo/bin">
<fileset basedir="src/wcf/ConfigDemo/Server/bin">
<include name="Debug/**/*"/>
<include name="Release/**/*"/>
</fileset>
</copy>
<copy todir="${wcf.dist.dir}/examples/config-demo/bin">
<fileset basedir="src/wcf/ConfigDemo/Client/bin">
<include name="Debug/**/*"/>
<include name="Release/**/*"/>
</fileset>
</copy>
<mkdir dir="${wcf.dist.dir}/examples/config-demo/source"/>
<copy todir="${wcf.dist.dir}/examples/config-demo/source">
<fileset basedir="src/wcf/ConfigDemo">
<include name="**/*.cs"/>
<include name="**/*.csproj"/>
<include name="**/*.sln"/>
<include name="**/*.config"/>
<exclude name="**/bin/**/*"/>
</fileset>
</copy>
</target>
<target name="release-dir">
<delete dir="${release.dir}" failonerror="false"/>
<mkdir dir="${release.version.dir}"/>
</target>
<target name="copy-deliverables">
<copy todir="${release.version.dir}">
<fileset basedir="${build.dir}">
<include name="*.zip"/>
</fileset>
</copy>
</target>
<target name="src-dist" description="create zip from current state of the repository">
<mkdir dir="${build.dir}"/>
<exec program="${python.exec}">
<arg value="${hg.exec}"/>
<arg value="archive"/>
<arg value="-t"/>
<arg value="zip"/>
<arg value="-r"/>
<arg value="${fullversion}"/>
<arg value="${build.dir}/${release.src.zip}" />
</exec>
</target>
<target name="windows-deliverables"
depends="release-dir">
<call target="dist"/>
<zip zipfile="${build.dir}/${nameversion}-tmp-xmldoc.zip" encoding="ASCII">
<fileset basedir="${gendoc.xml.dir}">
<include name="**/*"/>
</fileset>
</zip>
<call target="copy-deliverables"/>
<call target="clean"/>
<call target="wcf-dist"/>
<call target="copy-deliverables"/>
<call target="clean"/>
<call target="src-dist"/>
<call target="copy-deliverables"/>
</target>
</project>
@@ -0,0 +1,32 @@
thisdir = class/RabbitMQ.Client/docs/specs
SUBDIRS =
include ../../../../build/rules.make
all-local: autogenerated-api-0-9.cs autogenerated-api-0-8.cs autogenerated-api-qpid-0-8.cs
copy:
cp ../../../lib/net_2_0/apigen-bootstrap.dll ../../src/apigen/.
autogenerated-api-0-9.cs: amqp0-9.xml
mono ../../src/apigen/RabbitMQ.Client.Apigen.exe /n:v0_9 "/apiName:AMQP_0_9" $^ $@
autogenerated-api-0-8.cs: amqp0-8.xml
mono ../../src/apigen/RabbitMQ.Client.Apigen.exe /n:v0_8 "/apiName:AMQP_0_8" $^ $@
autogenerated-api-qpid-0-8.cs: qpid-amqp.0-8.xml
mono ../../src/apigen/RabbitMQ.Client.Apigen.exe /n:v0_8qpid "/apiName:AMQP_0_8_QPID" $^ $@
install-local:
clean-local:
rm -f ../../src/apigen/apigen-bootstrap.dll
test-local:
run-test-local:
run-test-ondotnet-local:
DISTFILES =
dist-local:
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+6
View File
@@ -0,0 +1,6 @@
<!-- NAnt build file. -*- nxml -*- -->
<project>
<property name="config.name" value="mono-2.0" />
<property name="version.major.minor.release" value="1.2.0"/>
</project>
@@ -0,0 +1,6 @@
<!-- NAnt build file. -*- nxml -*- -->
<project>
<property name="config.name" value="dotnet-1.1" />
<property name="version.major.minor.release" value="1.2.0"/>
</project>
@@ -0,0 +1,97 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Xml;
namespace RabbitMQ.Client.Apigen {
public class AmqpClass: AmqpEntity {
public ArrayList Methods;
public ArrayList Fields;
public AmqpClass(XmlNode n)
: base(n)
{
Methods = new ArrayList();
foreach (XmlNode m in n.SelectNodes("method")) {
Methods.Add(new AmqpMethod(m));
}
Fields = new ArrayList();
foreach (XmlNode f in n.SelectNodes("field")) {
Fields.Add(new AmqpField(f));
}
}
public int Index {
get {
return GetInt("@index");
}
}
public bool NeedsProperties {
get {
foreach (AmqpMethod m in Methods) {
if (m.HasContent) return true;
}
return false;
}
}
public AmqpMethod MethodNamed(string name) {
foreach (AmqpMethod m in Methods) {
if (m.Name == name) {
return m;
}
}
return null;
}
}
}
@@ -0,0 +1,103 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
using System.Xml;
namespace RabbitMQ.Client.Apigen {
public class AmqpEntity {
public XmlNode node;
public AmqpEntity(XmlNode n) {
this.node = n;
}
public string GetString(string path) {
return Apigen.GetString(node, path);
}
public string GetString(string path, string d) {
return Apigen.GetString(node, path, d);
}
public int GetInt(string path) {
return Apigen.GetInt(node, path);
}
public string Name {
get {
return GetString("@name");
}
}
public string DocumentationComment(string prefixSpaces) {
return DocumentationComment(prefixSpaces, "doc");
}
public string DocumentationCommentVariant(string prefixSpaces, string tagname) {
return DocumentationComment(prefixSpaces, "doc", tagname);
}
public string DocumentationComment(string prefixSpaces, string docXpath) {
return DocumentationComment(prefixSpaces, docXpath, "summary");
}
public string DocumentationComment(string prefixSpaces, string docXpath, string tagname) {
string docStr = GetString(docXpath, "").Trim();
if (docStr.Length > 0) {
return (prefixSpaces + "/// <"+tagname+">\n" +
GetString(docXpath, "") + "\n</"+tagname+">")
.Replace("\n", "\n" + prefixSpaces + "/// ");
} else {
return prefixSpaces + "// (no documentation)";
}
}
}
}
@@ -0,0 +1,68 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
using System.Xml;
namespace RabbitMQ.Client.Apigen {
public class AmqpField: AmqpEntity {
public AmqpField(XmlNode n): base(n) {}
public string Domain {
get {
string result = GetString("@domain", "");
if (result.Equals("")) {
result = GetString("@type");
}
return result;
}
}
}
}
@@ -0,0 +1,91 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Xml;
namespace RabbitMQ.Client.Apigen {
public class AmqpMethod: AmqpEntity {
public ArrayList Fields;
public ArrayList ResponseMethods;
public AmqpMethod(XmlNode n)
: base(n)
{
Fields = new ArrayList();
foreach (XmlNode f in n.SelectNodes("field")) {
Fields.Add(new AmqpField(f));
}
ResponseMethods = new ArrayList();
foreach (XmlNode r in n.SelectNodes("response")) {
ResponseMethods.Add(Apigen.GetString(r, "@name"));
}
}
public bool HasContent {
get {
return GetString("@content", null) != null;
}
}
public bool IsSimpleRpcRequest {
get {
return ResponseMethods.Count == 1;
}
}
public int Index {
get {
return GetInt("@index");
}
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,13 @@
thisdir := class/RabbitMQ.Client/src/apigen
SUBDIRS =
include ../../../../build/rules.make
PROGRAM = RabbitMQ.Client.Apigen.exe
LOCAL_MCS_FLAGS = /r:System.dll \
/r:System.Xml.dll \
/r:apigen-bootstrap.dll \
/main:RabbitMQ.Client.Apigen.Apigen
include ../../../../build/executable.make
@@ -0,0 +1,20 @@
Apigen.cs
AmqpClass.cs
AmqpEntity.cs
AmqpField.cs
AmqpMethod.cs
../client/api/IModel.cs
../client/api/IContentHeader.cs
../client/api/IBasicProperties.cs
../client/api/IFileProperties.cs
../client/api/IStreamProperties.cs
../client/api/AmqpTimestamp.cs
../client/api/IBasicConsumer.cs
../client/api/ShutdownEventArgs.cs
../client/api/ShutdownInitiator.cs
../client/api/PublicationAddress.cs
../client/events/BasicReturnEventArgs.cs
../client/events/BasicReturnEventHandler.cs
../client/events/CallbackExceptionEventArgs.cs
../client/events/CallbackExceptionEventHandler.cs
../client/events/ModelShutdownEventHandler.cs
@@ -0,0 +1,10 @@
thisdir := class/RabbitMQ.Client/src/apigen
SUBDIRS =
include ../../../../build/rules.make
LIBRARY = apigen-bootstrap.dll
LIB_MCS_FLAGS = /r:System.dll
NO_TEST = yes
NO_SIGN_ASSEMBLY = yes
include ../../../../build/library.make
@@ -0,0 +1,15 @@
../client/api/IModel.cs
../client/api/IContentHeader.cs
../client/api/IBasicProperties.cs
../client/api/IFileProperties.cs
../client/api/IStreamProperties.cs
../client/api/AmqpTimestamp.cs
../client/api/IBasicConsumer.cs
../client/api/ShutdownEventArgs.cs
../client/api/ShutdownInitiator.cs
../client/api/PublicationAddress.cs
../client/events/BasicReturnEventArgs.cs
../client/events/BasicReturnEventHandler.cs
../client/events/CallbackExceptionEventArgs.cs
../client/events/CallbackExceptionEventHandler.cs
../client/events/ModelShutdownEventHandler.cs
@@ -0,0 +1,71 @@
//
// AssemblyInfo.cs
//
// Author:
// Andreas Nahr ([email protected])
//
// (C) 2003 Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Resources;
using System.Security;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about the apigen-bootstrap.dll assembly
[assembly: AssemblyTitle ("RabbitMQ.Client.dll")]
[assembly: AssemblyDescription ("RabbitMQ.Client.dll")]
[assembly: AssemblyDefaultAlias ("RabbitMQ.Client.dll")]
[assembly: AssemblyCompany (Consts.MonoCompany)]
[assembly: AssemblyProduct (Consts.MonoProduct)]
[assembly: AssemblyCopyright (Consts.MonoCopyright)]
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: SatelliteContractVersion (Consts.FxVersion)]
[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: ComVisible (false)]
[assembly: CLSCompliant (true)]
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile("../../../msfinal.pub")]
#if NET_2_0
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
[assembly: Debuggable (DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility (WrapNonExceptionThrows = true)]
#elif NET_1_1
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyConfiguration ("")]
#elif NET_1_0
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyConfiguration ("")]
#endif
@@ -0,0 +1,9 @@
thisdir := class/RabbitMQ.Client/src/client
SUBDIRS =
include ../../../../build/rules.make
LIBRARY = RabbitMQ.Client.dll
LIB_MCS_FLAGS = /r:System.dll /r:System.Xml
NO_TEST = yes
include ../../../../build/library.make
@@ -0,0 +1,127 @@
./AssemblyInfo.cs
../../../../build/common/Consts.cs
./messagepatterns/SimpleRpcServer.cs
./messagepatterns/SimpleRpcClient.cs
./messagepatterns/Subscription.cs
./exceptions/AlreadyClosedException.cs
./exceptions/PacketNotRecognizedException.cs
./exceptions/UnsupportedMethodFieldException.cs
./exceptions/WireFormattingException.cs
./exceptions/BrokerUnreachableException.cs
./exceptions/ProtocolVersionMismatchException.cs
./exceptions/ChannelAllocationException.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
./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/AbstractProtocolBase.cs
./impl/SocketFrameHandler_0_9.cs
./impl/WireFormatting.cs
./impl/RedirectException.cs
./impl/ISession.cs
./impl/Session.cs
./impl/QuiescingSession.cs
./impl/v0_9/Connection.cs
./impl/v0_9/ProtocolBase.cs
./impl/BasicProperties.cs
./impl/Frame.cs
./impl/SoftProtocolException.cs
./impl/MalformedFrameException.cs
./impl/HardProtocolException.cs
./impl/IRpcContinuation.cs
./impl/ContentHeaderBase.cs
./impl/ContentHeaderPropertyWriter.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
./api/IFileProperties.cs
./api/QueueingBasicConsumer.cs
./api/AmqpTimestamp.cs
./api/IMethod.cs
./api/ConnectionParameters.cs
./api/AmqpTcpEndpoint.cs
./api/IContentHeader.cs
./api/DefaultBasicConsumer.cs
./api/ExchangeType.cs
./api/IProtocol.cs
./api/BinaryTableValue.cs
./api/AmqpVersion.cs
./api/IBasicConsumer.cs
./api/IConnection.cs
./api/AccessRequestConfig.cs
./api/ShutdownInitiator.cs
./api/IModel.cs
./api/ConnectionFactory.cs
./api/IStreamProperties.cs
./api/IBasicProperties.cs
./api/ShutdownEventArgs.cs
../../docs/specs/autogenerated-api-0-9.cs
../../docs/specs/autogenerated-api-0-8.cs
../../docs/specs/autogenerated-api-qpid-0-8.cs
../util/DebugUtil.cs
../util/NetworkBinaryReader.cs
../util/NetworkBinaryWriter.cs
../util/BlockingCell.cs
../util/Semaphore.cs
../util/Either.cs
../util/SharedQueue.cs
../util/XmlUtil.cs
@@ -0,0 +1,73 @@
// 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
};
}
@@ -0,0 +1,174 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using RabbitMQ.Client.Impl;
namespace RabbitMQ.Client
{
///<summary>Represents a TCP-addressable AMQP peer, including the
///protocol variant to use, and a host name and port
///number.</summary>
public class AmqpTcpEndpoint
{
private IProtocol m_protocol;
///<summary>Retrieve or set the IProtocol of this AmqpTcpEndpoint.</summary>
public IProtocol Protocol
{
get { return m_protocol; }
set { m_protocol = value; }
}
private string m_hostName;
///<summary>Retrieve or set the hostname of this AmqpTcpEndpoint.</summary>
public string HostName
{
get { return m_hostName; }
set { m_hostName = value; }
}
private int m_port;
///<summary>Retrieve or set the port number of this
///AmqpTcpEndpoint. A port number of -1 causes the default
///port number for the IProtocol to be used.</summary>
public int Port
{
get { return (m_port == -1) ? m_protocol.DefaultPort : m_port; }
set { m_port = value; }
}
///<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)
{
m_protocol = protocolVariant;
m_hostName = hostname;
m_port = portOrMinusOne;
}
///<summary>Returns a URI-like string of the form
///amqp-PROTOCOL://HOSTNAME:PORTNUMBER</summary>
///<remarks>
/// This method is intended mainly for debugging and logging use.
///</remarks>
public override string ToString()
{
return "amqp-" + Protocol + "://" + HostName + ":" + Port;
}
///<summary>Compares this instance by value (protocol,
///hostname, port) against another instance</summary>
public override bool Equals(object obj)
{
AmqpTcpEndpoint other = obj as AmqpTcpEndpoint;
if (other == null) return false;
if (other.Protocol != Protocol) return false;
if (other.HostName != HostName) return false;
if (other.Port != Port) return false;
return true;
}
///<summary>Implementation of hash code depending on protocol,
///hostname and port, to line up with the implementation of
///Equals()</summary>
public override int GetHashCode()
{
return
Protocol.GetHashCode() ^
HostName.GetHashCode() ^
Port;
}
///<summary>Construct an instance from a protocol and an
///address in "hostname:port" format.</summary>
///<remarks>
/// If the address string passed in contains ":", it is split
/// into a hostname and a port-number part. Otherwise, the
/// entire string is used as the hostname, and the port-number
/// is set to -1 (meaning the default number for the protocol
/// variant specified).
///</remarks>
public static AmqpTcpEndpoint Parse(IProtocol protocol, string address) {
int index = address.IndexOf(':');
if (index == -1) {
return new AmqpTcpEndpoint(protocol, address, -1);
} else {
string portStr = address.Substring(index + 1).Trim();
int portNum = (portStr.Length == 0) ? -1 : int.Parse(portStr);
return new AmqpTcpEndpoint(protocol,
address.Substring(0, index),
portNum);
}
}
///<summary>Splits the passed-in string on ",", and passes the
///substrings to AmqpTcpEndpoint.Parse()</summary>
///<remarks>
/// Accepts a string of the form "hostname:port,
/// hostname:port, ...", where the ":port" pieces are
/// optional, and returns a corresponding array of
/// AmqpTcpEndpoints.
///</remarks>
public static AmqpTcpEndpoint[] ParseMultiple(IProtocol protocol, string addresses) {
string[] partsArr = addresses.Split(new char[] { ',' });
ArrayList results = new ArrayList();
foreach (string partRaw in partsArr) {
string part = partRaw.Trim();
if (part.Length > 0) {
results.Add(Parse(protocol, part));
}
}
return (AmqpTcpEndpoint[]) results.ToArray(typeof(AmqpTcpEndpoint));
}
}
}
@@ -0,0 +1,99 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
namespace RabbitMQ.Client
{
// time representations in mainstream languages: the horror, the horror
// see in particular the difference between .NET 1.x and .NET 2.0's versions of DateTime
///<summary>Structure holding an AMQP timestamp, a posix 64-bit time_t.</summary>
///<remarks>
///<para>
///When converting between an AmqpTimestamp and a System.DateTime,
///be aware of the effect of your local timezone. In particular,
///different versions of the .NET framework assume different
///defaults.
///</para>
///<para>
///We have chosen a signed 64-bit time_t here, since the AMQP
///specification through versions 0-9 is silent on whether
///timestamps are signed or unsigned.
///</para>
///</remarks>
public struct AmqpTimestamp
{
private long m_unixTime;
///<summary>Construct an AmqpTimestamp holding the given time_t value.</summary>
///<remarks>
///</remarks>
public AmqpTimestamp(long unixTime)
{
m_unixTime = unixTime;
}
///<summary>Retrieve the time_t from this structure.</summary>
public long UnixTime
{
get
{
return m_unixTime;
}
}
///<summary>Provides a debugger-friendly display.</summary>
public override string ToString()
{
return "((time_t)" + m_unixTime + ")";
}
}
}
@@ -0,0 +1,121 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
namespace RabbitMQ.Client
{
///<summary>Represents a version of the AMQP specification.</summary>
///<remarks>
///<para>
///Vendor-specific variants of particular official specification
///versions exist: this class simply represents the AMQP
///specification version, and does not try to represent
///information about any custom variations involved.
///</para>
///<para>
///AMQP version 0-8 peers sometimes advertise themselves as
///version 8-0: for this reason, this class's constructor
///special-cases 8-0, rewriting it at construction time to be 0-8
///instead.
///</para>
///</remarks>
public class AmqpVersion
{
private readonly int m_major;
private readonly int m_minor;
///<summary>The AMQP specification major version number</summary>
public int Major { get { return m_major; } }
///<summary>The AMQP specification minor version number</summary>
public int Minor { get { return m_minor; } }
///<summary>Construct an AmqpVersion from major and minor version numbers.</summary>
///<remarks>
///Converts major=8 and minor=0 into major=0 and
///minor=8. Please see the class comment.
///</remarks>
public AmqpVersion(int major, int minor)
{
if (major == 8 && minor == 0)
{
// The AMQP 0-8 spec confusingly defines the version
// as 8-0. This maps the latter to the former, for
// cases where our peer might be confused.
major = 0;
minor = 8;
}
m_major = major;
m_minor = minor;
}
///<summary>Format appropriately for display.</summary>
///<remarks>
///The specification currently uses "MAJOR-MINOR" as a display format.
///</remarks>
public override string ToString()
{
return m_major + "-" + m_minor;
}
///<summary>Implement value-equality comparison.</summary>
public override bool Equals(object other)
{
AmqpVersion v = other as AmqpVersion;
return (v != null) && (v.m_major == m_major) && (v.m_minor == m_minor);
}
///<summary>Implement hashing as for value-equality.</summary>
public override int GetHashCode()
{
return 31 * m_major.GetHashCode() + m_minor.GetHashCode();
}
}
}
@@ -0,0 +1,18 @@
using System.Reflection; // -*- java -*- in the absence of anything better
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("RabbitMQ Client Library for .Net")]
[assembly: AssemblyDescription("Open Source Enterprise Messaging")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("LShift Ltd.")]
[assembly: AssemblyProduct("RabbitMQ")]
[assembly: AssemblyCopyright("Copyright © 2007, 2008 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("32a32ed8-c871-45ad-86b3-f50723a7434b")]
[assembly: AssemblyVersion("@VERSION@")]
@@ -0,0 +1,104 @@
// 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>Wrapper for a byte[]. May appear as values read from
///and written to AMQP field tables.</summary>
///<remarks>
///<para>
/// The sole reason for the existence of this class is to permit
/// encoding of byte[] as 'x' in AMQP field tables, an extension
/// to the specification that is part of the tentative JMS mapping
/// implemented by QPid.
///</para>
///<para>
/// Instances of this object may be found as values held in
/// IDictionary instances returned from
/// RabbitMQ.Client.Impl.WireFormatting.ReadTable, e.g. as part of
/// IBasicProperties.Headers tables. Likewise, instances may be
/// set as values in an IDictionary table to be encoded by
/// RabbitMQ.Client.Impl.WireFormatting.WriteTable.
///</para>
///<para>
/// When an instance of this class is encoded/decoded, the type
/// tag 'x' is used in the on-the-wire representation. The AMQP
/// standard type tag 'S' is decoded to a raw byte[], and a raw
/// byte[] is encoded as 'S'. Instances of System.String are
/// converted to a UTF-8 binary representation, and then encoded
/// using tag 'S'. In order to force the use of tag 'x', instances
/// of this class must be used.
///</para>
///</remarks>
public class BinaryTableValue
{
private byte[] m_bytes = null;
///<summary>The wrapped byte array, as decoded or as to be
///encoded.</summary>
public byte[] Bytes {
get { return m_bytes; }
set { m_bytes = value; }
}
///<summary>Constructs an instance with null for its Bytes
///property.</summary>
public BinaryTableValue()
: this(null)
{}
///<summary>Constructs an instance with the passed-in value
///for its Bytes property.</summary>
public BinaryTableValue(byte[] bytes)
{
m_bytes = bytes;
}
}
}
@@ -0,0 +1,302 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Collections;
using RabbitMQ.Client.Impl;
using RabbitMQ.Client.Exceptions;
namespace RabbitMQ.Client
{
///<summary>Main entry point to the RabbitMQ .NET AMQP client
///API. Constructs IConnection instances.</summary>
///<remarks>
///<para>
/// A simple example of connecting to a broker:
///</para>
///<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;
/// //
/// IProtocol protocol = Protocols.DefaultProtocol;
/// IConnection conn = factory.CreateConnection(protocol, hostName, portNumber);
/// //
/// IModel ch = conn.CreateModel();
/// ushort ticket = ch.AccessRequest("/data");
/// //
/// // ... use ch's IModel methods ...
/// //
/// ch.Close(200, "Closing the channel");
/// conn.Close(200, "Closing the connection");
///</code></example>
///<para>
/// Please see also the API overview and tutorial in the User Guide.
///</para>
///<para>
/// Some of the static methods described below 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>
///</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>Constructs a ConnectionFactory with default values
///for Parameters.</summary>
public ConnectionFactory()
{
}
protected virtual IConnection FollowRedirectChain
(int maxRedirects,
IDictionary connectionAttempts,
IDictionary connectionErrors,
ref AmqpTcpEndpoint[] mostRecentKnownHosts,
AmqpTcpEndpoint endpoint)
{
AmqpTcpEndpoint candidate = endpoint;
try {
while (true) {
int attemptCount =
connectionAttempts.Contains(candidate)
? (int) connectionAttempts[candidate]
: 0;
connectionAttempts[candidate] = attemptCount + 1;
bool insist = attemptCount >= maxRedirects;
try {
IProtocol p = candidate.Protocol;
IFrameHandler fh = p.CreateFrameHandler(candidate);
// At this point, we may be able to create
// 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);
} catch (RedirectException re) {
if (insist) {
// We've been redirected, but we insisted that
// we shouldn't be redirected! Well-behaved
// brokers should never do this.
string message = string.Format("Server {0} ignored 'insist' flag, redirecting us to {1}",
candidate,
re.Host);
throw new ProtocolViolationException(message);
} else {
// We've been redirected. Follow this new link
// in the chain, by setting
// mostRecentKnownHosts (in case the chain
// runs out), and updating candidate for the
// next time round the loop.
connectionErrors[candidate] = re;
mostRecentKnownHosts = re.KnownHosts;
candidate = re.Host;
}
}
}
} catch (Exception e) {
connectionErrors[candidate] = e;
return null;
}
}
protected virtual IConnection CreateConnection(int maxRedirects,
IDictionary connectionAttempts,
IDictionary connectionErrors,
params AmqpTcpEndpoint[] endpoints)
{
foreach (AmqpTcpEndpoint endpoint in endpoints)
{
AmqpTcpEndpoint[] mostRecentKnownHosts = new AmqpTcpEndpoint[0];
// ^^ holds a list of known-hosts that came back with
// a connection.redirect. If, once we reach the end of
// a chain of redirects, we still haven't managed to
// get a usable connection, we recurse on
// mostRecentKnownHosts, trying each of those in
// turn. Finally, if neither the initial
// chain-of-redirects for the current endpoint, nor
// the chains-of-redirects for each of the
// mostRecentKnownHosts gives us a usable connection,
// we give up on this particular endpoint, and
// continue with the foreach loop, trying the
// remainder of the array we were given.
IConnection conn = FollowRedirectChain(maxRedirects,
connectionAttempts,
connectionErrors,
ref mostRecentKnownHosts,
endpoint);
if (conn != null) {
return conn;
}
// Connection to this endpoint failed at some point
// down the redirection chain - either the first
// entry, or one of the re.Host values from subsequent
// RedirectExceptions. We recurse into
// mostRecentKnownHosts, to see if one of those is
// suitable.
if (mostRecentKnownHosts.Length > 0) {
// Only bother recursing if we know of some
// hosts. If we were to recurse with no endpoints
// in the array, we'd stomp on
// mostRecentException, which makes debugging
// connectivity problems needlessly more
// difficult.
conn = CreateConnection(maxRedirects,
connectionAttempts,
connectionErrors,
mostRecentKnownHosts);
if (conn != null) {
return conn;
}
}
}
return null;
}
///<summary>Create a connection to the first available
///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)
{
IDictionary connectionAttempts = new Hashtable();
IDictionary connectionErrors = new Hashtable();
IConnection conn = CreateConnection(maxRedirects,
connectionAttempts,
connectionErrors,
endpoints);
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)
{
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));
}
}
}
@@ -0,0 +1,156 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
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 number of
/// channels, 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;
private AccessRequestConfig m_accessRequestConfig = AccessRequestConfig.UseDefault;
///<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>Channel-max parameter to ask for (number of channels)</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>Used to control whether Access.Request methods
/// are sent to the peer or not, in conjunction with the
/// protocol default.</summary>
public AccessRequestConfig AccessRequestConfig
{
get { return m_accessRequestConfig; }
set { m_accessRequestConfig = 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;
}
}
}
@@ -0,0 +1,171 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
namespace RabbitMQ.Client
{
///<summary>Useful default/base implementation of
///IBasicConsumer. Subclass and override HandleBasicDeliver in
///application code.</summary>
///<remarks>
/// Note that the "Handle*" methods run in the connection's
/// thread! Consider using QueueingBasicConsumer, which uses a
/// SharedQueue instance to safely pass received messages across
/// to user threads, or
/// RabbitMQ.Client.MessagePatterns.Subscription, which manages
/// resource declaration and binding in addition to providing a
/// thread-safe interface.
///</remarks>
public class DefaultBasicConsumer : IBasicConsumer
{
private IModel m_model = null;
private string m_consumerTag = null;
private bool m_running = false;
private ShutdownEventArgs m_shutdownReason = null;
///<summary>Retrieve the IModel instance this consumer is
///registered with.</summary>
public IModel Model
{
get { return m_model; }
set { m_model = value; }
}
///<summary>Retrieve the consumer tag this consumer is
///registered as; to be used when discussing this consumer
///with the server, for instance with
///IModel.BasicCancel().</summary>
public string ConsumerTag
{
get { return m_consumerTag; }
set { m_consumerTag = value; }
}
///<summary>Returns true while the consumer is registered and
///expecting deliveries from the broker.</summary>
public bool IsRunning
{
get { return m_running; }
}
///<summary>If our IModel shuts down, this property will
///contain a description of the reason for the
///shutdown. Otherwise it will contain null. See
///ShutdownEventArgs.</summary>
public ShutdownEventArgs ShutdownReason
{
get { return m_shutdownReason; }
}
///<summary>Default constructor.</summary>
public DefaultBasicConsumer() { }
///<summary>Constructor which sets the Model property to the
///given value.</summary>
public DefaultBasicConsumer(IModel model)
{
m_model = model;
}
///<summary>Default implementation - overridable in subclasses.</summary>
///<remarks>
/// This default implementation simply sets the IsRunning
/// property to false, and takes no further action.
///</remarks>
public virtual void OnCancel()
{
m_running = false;
}
///<summary>Default implementation - sets the ConsumerTag
///property and sets IsRunning to true.</summary>
public virtual void HandleBasicConsumeOk(string consumerTag)
{
ConsumerTag = consumerTag;
m_running = true;
}
///<summary>Default implementation - calls OnCancel().</summary>
public virtual void HandleBasicCancelOk(string consumerTag)
{
OnCancel();
}
///<summary>Default implementation - sets ShutdownReason and
///calls OnCancel().</summary>
public virtual void HandleModelShutdown(IModel model, ShutdownEventArgs reason)
{
m_shutdownReason = reason;
OnCancel();
}
///<summary>Default implementation - override in subclasses.</summary>
///<remarks>
/// Does nothing with the passed in information. Note that in
/// particular, some delivered messages may require
/// acknowledgement via IModel.BasicAck; the implementation of
/// this method in this class does NOT acknowledge such
/// messages.
///</remarks>
public virtual void HandleBasicDeliver(string consumerTag,
ulong deliveryTag,
bool redelivered,
string exchange,
string routingKey,
IBasicProperties properties,
byte[] body)
{
// Nothing to do here.
}
}
}
@@ -0,0 +1,85 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System.Collections;
namespace RabbitMQ.Client
{
///<summary>
/// Convenience class providing compile-time names for various exchange types.
///</summary>
///<remarks>
/// Use the static members of this class as values for the
/// "exchangeType" arguments for IModel methods such as
/// ExchangeDeclare.
///</remarks>
public class ExchangeType
{
///<summary>Exchange type used for AMQP fanout exchanges.</summary>
public const string Fanout = "fanout";
///<summary>Exchange type used for AMQP direct exchanges.</summary>
public const string Direct = "direct";
///<summary>Exchange type used for AMQP topic exchanges.</summary>
public const string Topic = "topic";
///<summary>Private constructor - this class has no instances</summary>
private ExchangeType() {}
///<summary>Retrieve a collection containing all defined exchange types.</summary>
public static ICollection All()
{
return new string[] {
Fanout,
Direct,
Topic
};
}
}
}
@@ -0,0 +1,98 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
namespace RabbitMQ.Client
{
///<summary>Consumer interface for Basic content-class. Used to
///receive messages from a queue by subscription.</summary>
///<remarks>
///<para>
/// See IModel.BasicConsume, IModel.BasicCancel.
///</para>
///<para>
/// Note that the "Handle*" methods run in the connection's
/// thread! Consider using QueueingBasicConsumer, which uses a
/// SharedQueue instance to safely pass received messages across
/// to user threads.
///</para>
///</remarks>
public interface IBasicConsumer
{
///<summary>Retrieve the IModel this consumer is associated
///with, for use in acknowledging received messages, for
///instance.</summary>
IModel Model { get; }
///<summary>Called upon successful registration of the
///consumer with the broker.</summary>
void HandleBasicConsumeOk(string consumerTag);
///<summary>Called upon successful deregistration of the
///consumer from the broker.</summary>
void HandleBasicCancelOk(string consumerTag);
///<summary>Called when the model shuts down.</summary>
void HandleModelShutdown(IModel model, ShutdownEventArgs reason);
///<summary>Called each time a message arrives for this consumer.</summary>
///<remarks>
///Be aware that acknowledgement may be required. See IModel.BasicAck.
///</remarks>
void HandleBasicDeliver(string consumerTag,
ulong deliveryTag,
bool redelivered,
string exchange,
string routingKey,
IBasicProperties properties,
byte[] body);
}
}
@@ -0,0 +1,181 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
namespace RabbitMQ.Client
{
///<summary>Common AMQP Basic content-class headers interface,
///spanning the union of the functionality offered by versions
///0-8, 0-8qpid and 0-9 (without WIP) of AMQP.</summary>
///<remarks>
///<para>
///The specification code generator provides
///protocol-version-specific implementations of this interface. To
///obtain an implementation of this interface in a
///protocol-version-neutral way, use
///IModel.CreateBasicProperties().
///</para>
///<para>
///Each property is readable, writable and clearable: a cleared
///property will not be transmitted over the wire. Properties on a
///fresh instance are clear by default.
///</para>
///</remarks>
public interface IBasicProperties : IContentHeader
{
///<summary> MIME content type </summary>
string ContentType { get; set; }
///<summary> MIME content encoding </summary>
string ContentEncoding { get; set; }
///<summary> message header field table </summary>
IDictionary Headers { get; set; }
///<summary> non-persistent (1) or persistent (2) </summary>
byte DeliveryMode { get; set; }
///<summary> message priority, 0 to 9 </summary>
byte Priority { get; set; }
///<summary> application correlation identifier </summary>
string CorrelationId { get; set; }
///<summary> destination to reply to </summary>
string ReplyTo { get; set; }
///<summary> message expiration specification </summary>
string Expiration { get; set; }
///<summary> application message identifier </summary>
string MessageId { get; set; }
///<summary> message timestamp </summary>
AmqpTimestamp Timestamp { get; set; }
///<summary> message type name </summary>
string Type { get; set; }
///<summary> creating user id </summary>
string UserId { get; set; }
///<summary> creating application id </summary>
string AppId { get; set; }
///<summary> intra-cluster routing identifier </summary>
string ClusterId { get; set; }
///<summary> Clear the ContentType property. </summary>
void ClearContentType();
///<summary> Clear the ContentEncoding property. </summary>
void ClearContentEncoding();
///<summary> Clear the Headers property. </summary>
void ClearHeaders();
///<summary> Clear the DeliveryMode property. </summary>
void ClearDeliveryMode();
///<summary> Clear the Priority property. </summary>
void ClearPriority();
///<summary> Clear the CorrelationId property. </summary>
void ClearCorrelationId();
///<summary> Clear the ReplyTo property. </summary>
void ClearReplyTo();
///<summary> Clear the Expiration property. </summary>
void ClearExpiration();
///<summary> Clear the MessageId property. </summary>
void ClearMessageId();
///<summary> Clear the Timestamp property. </summary>
void ClearTimestamp();
///<summary> Clear the Type property. </summary>
void ClearType();
///<summary> Clear the UserId property. </summary>
void ClearUserId();
///<summary> Clear the AppId property. </summary>
void ClearAppId();
///<summary> Clear the ClusterId property. </summary>
void ClearClusterId();
///<summary>Convenience property; parses ReplyTo property
///using PublicationAddress.Parse, and serializes it using
///PublicationAddress.ToString. Returns null if ReplyTo property
///cannot be parsed by PublicationAddress.Parse.</summary>
PublicationAddress ReplyToAddress { get; set; }
///<summary>Sets DeliveryMode to either persistent (2) or non-persistent (1).</summary>
///<remarks>
///<para>
///The numbers 1 and 2 for delivery mode are "magic" in that
///they appear in the AMQP 0-8 and 0-9 specifications as part
///of the definition of the DeliveryMode Basic-class property,
///without being defined as named constants.
///</para>
///<para>
///Calling this method causes DeliveryMode to take on a
///value. In order to reset DeliveryMode to the default empty
///condition, call ClearDeliveryMode.
///</para>
///</remarks>
void SetPersistent(bool persistent);
}
}
@@ -0,0 +1,225 @@
// 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): ______________________________________.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using RabbitMQ.Client.Events;
namespace RabbitMQ.Client
{
///<summary>Main interface to an AMQP connection.</summary>
///<remarks>
///<para>
/// Instances of IConnection are used to create fresh
/// sessions/channels. The ConnectionFactory class is used to
/// construct IConnection instances. Please see the documentation
/// for ConnectionFactory for an example of usage. Alternatively,
/// an API tutorial can be found in the User Guide.
///</para>
///<para>
/// Extends the IDisposable interface, so that the "using"
/// statement can be used to scope the lifetime of a channel when
/// appropriate.
///</para>
///</remarks>
public interface IConnection: IDisposable
{
///<summary>Raised when the connection is destroyed.</summary>
///<remarks>
/// If the connection is already destroyed at the time an
/// event handler is added to this event, the event handler
/// will be fired immediately.
///</remarks>
event ConnectionShutdownEventHandler ConnectionShutdown;
///<summary>Signalled when an exception occurs in a callback
///invoked by the connection.</summary>
///<remarks>
///This event is signalled when a ConnectionShutdown handler
///throws an exception. If, in future, more events appear on
///IConnection, then this event will be signalled whenever one
///of those event handlers throws an exception, as well.
///</remarks>
event CallbackExceptionEventHandler CallbackException;
///<summary>Retrieve the endpoint this connection is connected
///to.</summary>
AmqpTcpEndpoint Endpoint { get; }
///<summary>The IProtocol this connection is using to
///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 number of channels this connection
///supports (0 if unlimited).</summary>
ushort ChannelMax { get; }
///<summary>The maximum frame size this connection supports (0
///if unlimited).</summary>
uint FrameMax { get; }
///<summary>The current heartbeat setting for this connection
///(0 for disabled), in seconds.</summary>
ushort Heartbeat { 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
///and ready for use.</summary>
AmqpTcpEndpoint[] KnownHosts { get; }
///<summary>Returns null if the connection is still in a state
///where it can be used, or the cause of its closure
///otherwise.</summary>
///<remarks>
///<para>
/// Applications should use the ConnectionShutdown event to
/// avoid race conditions. The scenario to avoid is checking
/// CloseReason, seeing it is null (meaning the IConnection
/// was available for use at the time of the check), and
/// interpreting this mistakenly as a guarantee that the
/// IConnection will remain usable for a time. Instead, the
/// operation of interest should simply be attempted: if the
/// IConnection is not in a usable state, an exception will be
/// thrown (most likely OperationInterruptedException, but may
/// vary depending on the particular operation being
/// attempted).
///</para>
///</remarks>
ShutdownEventArgs CloseReason { get; }
///<summary>Returns true if the connection is still in a state
///where it can be used. Identical to checking if CloseReason
///== null.</summary>
bool IsOpen { get; }
///<summary>If true, will close the whole connection as soon
///as there are no channels open on it; if false, manual
///connection closure will be required.</summary>
///<remarks>
/// Don't set AutoClose to true before opening the first
/// channel, because the connection will be immediately closed
/// if you do!
///</remarks>
bool AutoClose { get; set; }
///<summary>Create and return a fresh channel, session, and
///model.</summary>
IModel CreateModel();
///<summary>Close this connection and all its channels.</summary>
///<remarks>
///Note that all active channels, sessions, and models will be
///closed if this method is called. It will wait for the in-progress
///close operation to complete. This method will not return to the caller
///until the shutdown is complete. If the connection is already closed
///(or closing), then this method will throw AlreadyClosedException.
///It can also throw IOException when socket was closed unexpectedly.
///</remarks>
void Close();
///<summary>Close this connection and all its channels
///and wait with a timeout for all the in-progress close operations
///to complete.
///</summary>
///<remarks>
///Note that all active channels, sessions, and models will be
///closed if this method is called. It will wait for the in-progress
///close operation to complete with a timeout. If the connection is
///already closed (or closing), then this method will throw
///AlreadyClosedException.
///It can also throw IOException when socket was closed unexpectedly.
///If timeout is reached and the close operations haven't finished,
///then socket is forced to close.
///<para>
///To wait infinitely for the close operations to complete use
///Timeout.Infinite
///</para>
///</remarks>
void Close(int timeout);
///<summary>Abort this connection and all its channels.</summary>
///<remarks>
///Note that all active channels, sessions, and models will be
///closed if this method is called.
///In comparison to normal Close() method, Abort() will not throw
///AlreadyClosedException or IOException during closing connection.
///This method waits infinitely for the in-progress close operation
///to complete.
///</remarks>
void Abort();
///<summary>
///Abort this connection and all its channels and wait with a
///timeout for all the in-progress close operations to complete.
///.</summary>
///<remarks>
///This method, behaves in a similar way as method Abort() with the
///only difference that it explictly specifies the timeout given
///for all the in-progress close operations to complete.
///If timeout is reached and the close operations haven't finished,
///then socket is forced to close.
///<para>
///To wait infinitely for the close operations to complete use
///Timeout.Infinite
///</para>
///</remarks>
void Abort(int timeout);
///<summary>Returns the list of ShutdownReportEntry objects that
///contain information about any errors reported while closing the
///connection in the order they appeared</summary>
IList ShutdownReport { get; }
}
}
@@ -0,0 +1,62 @@
// 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>A decoded AMQP content header frame.</summary>
public interface IContentHeader
{
///<summary>Retrieve the AMQP class ID of this content header.</summary>
int ProtocolClassId { get; }
///<summary>Retrieve the AMQP class name of this content header.</summary>
string ProtocolClassName { get; }
}
}
Loaded 100 of 234 files, more files were not shown because too many files have changed in this diff. Show more