Vad*_*bak 7 wcf message-queue rabbitmq
我正在尝试编写一个适用于rabbitMQ绑定的wcf服务.我能够成功创建服务器和客户端,并让客户端通过队列向服务器发送消息.我对2个问题很困惑.
服务一旦关闭,队列就会被删除.有没有办法配置wcf和rabbitMQ,以便队列是持久的?这样,如果我的服务器崩溃,我不必担心丢失数据.
我似乎无法控制队列的名称.当我运行时,rabbitmqctl.bat list_queues
我看到队列被调用amq.gen-3IgZD30XvTEQWNRsezSUUA==
.有没有办法控制队列的名称?
小智 5
我遇到了和你一样的问题,我做的是编辑rabbitMQDotNetClient的源代码.
文件:RabbitMQInputChannel.cs
public override void Open(TimeSpan timeout)
{
if (State != CommunicationState.Created && State != CommunicationState.Closed)
throw new InvalidOperationException(string.Format("Cannot open the channel from the {0} state.", base.State));
OnOpening();
#if VERBOSE
DebugHelper.Start();
#endif
//Create a queue for messages destined to this service, bind it to the service URI routing key
#if USE_DEFINED_QUEUE_NAMES
//here we create a queue that uses the name given in the service address in the wcf binding.
//if the address in the web.config is: soap.amq:///QueueName
//the name of the queue will be: QueueName
//LVV
string queue = m_model.QueueDeclare(base.LocalAddress.Uri.PathAndQuery, true, false, false, null);
#else
string queue = m_model.QueueDeclare();
#endif
m_model.QueueBind(queue, Exchange, base.LocalAddress.Uri.PathAndQuery, null);
//Listen to the queue
m_messageQueue = new QueueingBasicConsumer(m_model);
m_model.BasicConsume(queue, false, m_messageQueue);
#if VERBOSE
DebugHelper.Stop(" ## In.Channel.Open {{\n\tAddress={1}, \n\tTime={0}ms}}.", LocalAddress.Uri.PathAndQuery);
#endif
OnOpened();
}
Run Code Online (Sandbox Code Playgroud)
使用标志USE_DEFINED_QUEUE_NAMES进行编译.这将创建一个队列名称,其名称与app.config或web.config文件中的名称一致.如果您希望队列的行为与我正在创建的队列不同,您可以随时更改QueueDeclare(...)上的队列选项.干杯!
归档时间: |
|
查看次数: |
4622 次 |
最近记录: |