Queue
(कतार) - डिस्क या रैम में एक डेटा संरचना जो संदेशों के लिंक को संग्रहीत करती है और उनकी प्रतियां consumers
(उपभोक्ताओं को) देती है। Queue
यह एक राज्य के साथ एक Erlang प्रक्रिया है (जहां संदेश स्वयं कैश किए जा सकते हैं)। 1 हजार कतारों के बारे में 80Mb पर कब्जा कर सकते हैं।
Binding
(बाइंडिंग) - एक नियम जो एक्सचेंजर को बताता है कि किन कतारों को संदेश प्राप्त करना चाहिए।
विषय - सूची
अस्थायी कतार
यदि पैरामीटर पैरामीटर सेट के साथ कतार बनाई जाती है autoDelete
, तो यह कतार स्वचालित रूप से स्वयं को हटाने की क्षमता प्राप्त करती है । ये कतारें आमतौर पर तब बनाई जाती हैं जब पहला क्लाइंट कनेक्ट होता है और सभी क्लाइंट डिस्कनेक्ट होने पर हटा दिए जाते हैं।
exclusive
, . , /, . exclusive
, autoDelete
.
:
durable
, /. Queue.Delete
.
Highly Available
HA RabbitMQ. , , .
- HA , , HA . - , .
HA .

:
- HA . HA HA RabbitMQ (2-3 )
RPC
. Queue.Declare
, :
RabbitMQ.Client:
channel.QueueDeclare(
queue: "my_queue",
durable: false,
exclusive: false,
autoDelete: false,
arguments: null
);
queue
— , .durable
— true, /exclusive
— true,autoDelete
— true, arguments
— . .
arguments
x-message-ttl
(x-message-time-to-live
) — . x-message-ttl
, , . x-message-ttl
. . . x-message-ttl
, .x-expires
— . . , , Basic.Cancel
. , Basic.Get
. , . , .x-max-length
— . ,

x-max-lenght-bytes
— . ( )x-overflow
— . : drop-head
( ) reject-publish
. drop-head
, . reject-publish
,x-dead-letter-exchange
— exchange, ,x-dead-letter-routing-key
—x-max-priority
— 255 (RabbitMQ 3.5.0 ). , . ,x-queue-mode
— . . . , , ,x-queue-master-locator
— ,x-ha-policy
— HA . all
, . nodes
,x-ha-nodes
— , HA

, RPC
Queue.DeclareOk
. ( Queue.Declare
), Channel.Close
OperationInterruptedException, .
Queue.Declare
. , , , .
Queue.Declare
, Channel.Close
OperationInterruptedException, 403 .
, >= 10 , , GC , , .
Queue
RabbitMQ
guest
(username: guest
password: guest
). , guest
. Queues
Add a new queue
. :

Add queues
, .

. , consumers
, / , .
Binding
RPC
. Queue.Bind
, :
RabbitMQ.Client:
channel.QueueBind(
queue: queueName,
exchange: "my_exchange",
routingKey: "my_key",
arguments: null
);
queue
—exchange
—routingKey
—arguments
—

, RPC
Queue.BindOk
.
Binding
RabbitMQ
guest
(username: guest
password: guest
). , guest
. Queues
my_queue
. bindings
:

Bind
, :

Code
इस खंड में, हम C # कोड का उपयोग करके कतार और बंधन का वर्णन करते हैं, इसलिए यदि हमें लाइब्रेरी विकसित करने की आवश्यकता है। शायद यह धारणा के लिए उपयोगी होगा।
public interface IQueue
{
string Name { get; }
bool IsDurable { get; }
bool IsExclusive { get; }
bool IsAutoDelete { get; }
IDictionary<string, object> Arguments { get; }
}
public class Queue : IQueue
{
public Queue(
string name,
bool isDurable = true,
bool isExclusive = false,
bool isAutoDelete = false,
IDictionary<string, object> arguments = null)
{
Name = name ??
throw new ArgumentNullException(name, $"{name} must not be null");
IsDurable = isDurable;
IsExclusive = isExclusive;
IsAutoDelete = isAutoDelete;
Arguments = arguments ?? new Dictionary<string, object>();
}
public string Name { get; }
public bool IsDurable { get; }
public bool IsExclusive { get; }
public bool IsAutoDelete { get; }
public IDictionary<string, object> Arguments { get; }
}
public static class QueueMode
{
public const string Default = "default";
public const string Lazy = "lazy";
}
public interface IBinding
{
IExchange Exchange { get; }
string RoutingKey { get; }
IDictionary<string, object> Arguments { get; }
}
public class Binding : IBinding
{
public Binding(
IExchange exchange,
string routingKey,
IDictionary<string, object> arguments)
{
Exchange = exchange;
RoutingKey = routingKey;
Arguments = arguments;
}
public IExchange Exchange { get; }
public string RoutingKey { get; }
public IDictionary<string, object> Arguments { get; }
}