Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AMQReceiver" /> class.
 /// </summary>
 /// <param name="connectionFactory">The connection factory.</param>
 /// <param name="connectionSettings">The connection settings.</param>
 /// <param name="destination">The destination.</param>
 public AMQReceiver(IAMQConnectionFactory connectionFactory, AMQConnectionSettings connectionSettings, AMQDestinationSettings destination) : base(connectionFactory, connectionSettings)
 {
     Mode = ConsumerMode.OnNoMessage_Timeout;
     _timeoutException = new TimeoutException();
     _destination      = destination;
     _consumer         = null;
 }
        /// <summary>
        /// Gets the destination settings.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public AMQDestinationSettings GetDestinationSettings(string name)
        {
            var attributes = GetAttributes("destinationSettings", name);

            var destination = new AMQDestinationSettings(attributes["name"], attributes["path"])
            {
                Path         = StringHelper.FullTrim(StringHelper.IfNullOrEmptyUseDefault(attributes["path"], string.Empty)),
                Selector     = StringHelper.IfNullOrEmptyUseDefault(attributes["selector"], null),
                SubscriberId = StringHelper.IfNullOrEmptyUseDefault(attributes["subscriberId"], null),
                Durable      = StringHelper.IfNullOrEmptyUseDefault(attributes["durable"], "false") == "true",

                DeliveryMode = MsgDeliveryMode.Persistent,
                AckMode      = AcknowledgementMode.AutoAcknowledge
            };

            var             deliveryMode    = StringHelper.IfNullOrEmptyUseDefault(attributes["deliveryMode"], "persistent");
            MsgDeliveryMode msgDeliveryMode = MsgDeliveryMode.Persistent;

            Enum.TryParse(deliveryMode, true, out msgDeliveryMode);
            destination.DeliveryMode = msgDeliveryMode;

            var ackMode = StringHelper.IfNullOrEmptyUseDefault(attributes["ackMode"], "autoacknowledge");
            AcknowledgementMode msgAckMode = AcknowledgementMode.AutoAcknowledge;

            Enum.TryParse(ackMode, true, out msgAckMode);
            destination.AckMode = msgAckMode;

            return(destination);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AMQObjectPool" /> class.
 /// </summary>
 /// <param name="factory">The factory.</param>
 /// <param name="instanceType">Type of the instance.</param>
 /// <param name="connection">The connection.</param>
 /// <param name="destination">The destination.</param>
 /// <param name="maxGrowSize">Maximum size of the grow.</param>
 public AMQObjectPoolAsync(
     IAMQSenderReceiverFactory factory,
     Type instanceType,
     AMQConnectionSettings connection,
     AMQDestinationSettings destination,
     int maxGrowSize) : base(0, maxGrowSize)
 {
     _factory      = factory;
     _instanceType = instanceType;
     _connection   = connection;
     _destination  = destination;
 }
        static AMQConfigurationManager CreateConfigurationManager()
        {
            var connectionSettings = new AMQConnectionSettings
            {
                Name             = "defaultConnection",
                Username         = "******",
                Password         = "******",
                Uri              = "tcp://localhost:61616?tcpNoDelay=true,tcp://localhost:61616?tcpNoDelay=true",
                DelayOnReconnect = 1000,
            };

            var destinationSettings = new AMQDestinationSettings("MY_AMQ_TEST", "queue://MY_AMQ_TEST")
            {
                DeliveryMode = MsgDeliveryMode.Persistent,
                Durable      = true,
            };

            return(new AMQConfigurationManager(new[] { connectionSettings }, new[] { destinationSettings }));
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AMQSender" /> class.
 /// </summary>
 /// <param name="connectionFactory">The connection factory.</param>
 /// <param name="connectionSettings">The connection settings.</param>
 /// <param name="destination">The destination.</param>
 public AMQSender(IAMQConnectionFactory connectionFactory, AMQConnectionSettings connectionSettings, AMQDestinationSettings destination) : base(connectionFactory, connectionSettings)
 {
     _destination = destination;
     _producer    = null;
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AMQSenderText" /> class.
 /// </summary>
 /// <param name="connectionFactory">The connection factory.</param>
 /// <param name="connectionSettings">The connection settings.</param>
 /// <param name="destination">The destination.</param>
 public AMQSenderBytes(IAMQConnectionFactory connectionFactory, AMQConnectionSettings connectionSettings, AMQDestinationSettings destination) : base(connectionFactory, connectionSettings, destination)
 {
 }
Example #7
0
 /// <summary>
 /// Creates the bytes.
 /// </summary>
 /// <param name="connectionSettings">The connection settings.</param>
 /// <param name="destinationSettings">The destination settings.</param>
 /// <returns></returns>
 public IAMQSenderBytes CreateBytes(AMQConnectionSettings connectionSettings, AMQDestinationSettings destinationSettings)
 {
     return(new AMQSenderBytes(_connectionFactory, connectionSettings, destinationSettings));
 }
Example #8
0
 /// <summary>
 /// Creates the text.
 /// </summary>
 /// <param name="connectionSettings">The connection settings.</param>
 /// <param name="destinationSettings">The destination settings.</param>
 /// <returns></returns>
 public IAMQSenderText CreateText(AMQConnectionSettings connectionSettings, AMQDestinationSettings destinationSettings)
 {
     return(new AMQSenderText(_connectionFactory, connectionSettings, destinationSettings));
 }
Example #9
0
 /// <summary>
 /// Creates the specified connection settings.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="connection">The connection settings.</param>
 /// <param name="destination">The destination settings.</param>
 /// <returns></returns>
 public T Create <T>(AMQConnectionSettings connection, AMQDestinationSettings destination) where T : IMessageReceiverSender
 {
     return((T)Create(typeof(T), connection, destination));
 }
Example #10
0
        /// <summary>
        /// Creates the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="connection">The connection settings.</param>
        /// <param name="destination">The destination settings.</param>
        /// <returns></returns>
        /// <exception cref="KeyNotFoundException"></exception>
        public IMessageReceiverSender Create(Type type, AMQConnectionSettings connection, AMQDestinationSettings destination)
        {
            if (!_invokers.ContainsKey(type))
            {
                throw new KeyNotFoundException($"The following type: '{type.Name}' is not supported.");
            }

            var invoker = _invokers[type];

            return(invoker(connection, destination));
        }
Example #11
0
 /// <summary>
 /// Creates the specified settings.
 /// </summary>
 /// <param name="connectionSettings">The connection settings.</param>
 /// <param name="destinationSettings">The settings.</param>
 /// <returns></returns>
 public IAMQReceiver Create(AMQConnectionSettings connectionSettings, AMQDestinationSettings destinationSettings)
 {
     return(new AMQReceiver(_connectionFactory, connectionSettings, destinationSettings));
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AMQReceiverText" /> class.
 /// </summary>
 /// <param name="connectionFactory">The connection factory.</param>
 /// <param name="connectionSettings">The connection settings.</param>
 /// <param name="destination">The destination.</param>
 public AMQReceiverText(IAMQConnectionFactory connectionFactory, AMQConnectionSettings connectionSettings, AMQDestinationSettings destination) : base(connectionFactory, connectionSettings, destination)
 {
 }