channel rabbitmq 配置_RabbitMQ (Channel参数篇)

Channel

1:方法ExchangeDeclare

void ExchangeDeclare(string exchange, string type, bool durable, bool autoDelete, IDictionary arguments);

参数:

1.1:exchange:交换机的名称

1.2:Type:交换机的类型(direct,fanout,topic)

1.3:durable:如果为true的话,服务器重启后该Exchange保留。(尽设置此项,不能保证重启后消息还在)

1.4:autoDelete:如果为true的话,当没有消费者的时候,Exchange自动删除。

1.5:argments:交换机的属性参数

2:方法BasicQos

void BasicQos(uint prefetchSize, ushort prefetchCount, bool global);

参数:

2.1:prefetchsize:prefetchSize maximum amount of content (measured in  octets) that the server will deliver, 0 if unlimited。

2.2:prefetchCount:prefetchCount maximum number of messages that the server will deliver, 0 if unlimited。一次推给一个消费者的消息数不会超过设置的数。一单超过。消费者将阻塞,一直等到有消息确认ACK

2.3:global:global true if the settings should be applied to the entire channel rather than each consumer。如果设置为true,则上面的设置会应用于整个Channel,而不是单个的消费者。

3:方法BasicPublish

void BasicPublish(string exchange, string routingKey, bool mandatory, IBasicProperties basicProperties, byte[] body);

3.1:exchange:交换机的名称。

3.2:routingKey:路由键(# 代表匹配0个或者多个单词,*代表匹配一个单词)。

3.3:mandatory:如果设置为true,如果交换机根据交换机类型和routeKey无法找到一个符合条件的Queue,那么会调用Basic.Return方法将消息返还给生产者。如果设置为false,出现上述情形momBroker会直接将消息扔掉。

3.4:basicProperties:基本属性:deliveryMode,0:不持久化 1:持久化 (消息的持久化),配合channel(durable=true),queue(durable)可以实现,即使服务器挂掉,消息仍然存在。

3.5:body:指的是传输的数据。

4:方法BasicAck

void BasicAck(ulong deliveryTag, bool multiple);

4.1:deliveryTag:消息的Tag。

4.2:multiple:如果设置为true,则将小于tag的消息一次性Ack。

5:方法BasicNack

void BasicNack(ulong deliveryTag, bool multiple, bool requeue);

5.1:deliveryTag:消息的Tag。

5.2:multiple:如果设置为true,则将小于tag的消息一次性NAck。

5.3:requeue:如果设置为true,则被Nack的信息重新入队列。

6:方法BasicReject

void BasicReject(ulong deliveryTag, bool requeue);

6.1:deliveryTag:消息的Tag。

6.2:requeue:如果设置为true,则被拒绝的信息重新入队列。

7:方法BasicConsume

string BasicConsume(string queue, bool noAck, string consumerTag, IDictionary arguments, IBasicConsumer consumer);

剩下的有时间再写吧。。。。。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值