RabbitMQ Web界面 - 在队列读取之前不显示队列?

时间:2018-04-04 15:48:21

标签: rabbitmq

我有一个Powershell,它向Rabbit-MQ发送消息。我从BizTalk中看到了同样的东西。在从该队列中至少检索一次消息之前,新的队列名称不会显示在Web界面上。这是正常的过程吗?我不明白为什么一旦数据写入它就不会出现。

类似地,我似乎注意到我不能将记录存储在队列中,直到它被读取一次。我用路由密钥发送到交换机。如果我编写程序并在那里发送5条消息,则队列不会显示在RabbitMQ中。但是,一旦我创建了一个程序来读取/侦听该队列,从那时起它就会显示出消息的数量。

示例Powershell代码:

Import-Module PSRabbitMQ

Set-RabbitMQConfig -ComputerName localhost 

$User = "myuser"
#The second command uses the ConvertTo-SecureString cmdlet to create a secure string from a plain text password. The command uses the *AsPlainText* parameter to indicate that the string is plain text and the *Force* parameter to confirm that you understand the risks of using plain text.
$PWord = ConvertTo-SecureString -String "mypassword" -AsPlainText -Force

#The third command uses the New-Object cmdlet to create a **PSCredential** object from the values in the $User and $PWord variables.
$CredRabbit = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PWord 


#Set some common parameters we will always use:
$Params = @{
        Credential = $CredRabbit
    }
$Exchange = "MyExchange"
$RoutingKey = "NealTest3"
$showDate = Get-Date -DisplayHint Date

$numMessagesPerRun = 5 
for ($j=1; $j -le $numMessagesPerRun; $j++) 
{
  $message = "Hello at date/time= $showDate " + $j 
  Write-Host "Message = $message" 
  Send-RabbitMQMessage -Exchange $Exchange -Key $RoutingKey -InputObject $message -vhost base -Persistent @Params
}

$showDate = Get-Date -DisplayHint Date
Write-Host "Ended $showDate" 

我的队列:当我做的时候NealTest3不会出现" rabbitmqctl list_queues -p base"直到我运行另一个Powershell来消耗该队列中至少一条消息。

第二个程序的代码读取队列(省略相同的登录信息):

Start-RabbitMqListener -Exchange $Exchange `
                       -Key $QueueName `
                       -QueueName $QueueName `
                        -AutoDelete $false `
                       -vhost base `
                       @Params | % { 
    #$req = $_ | ConvertFrom-Json
    $req = $_ 
    $counter = $counter + 1 
    Write-Host $counter + " " + $req
    }

根据list_queues,它读取了我放在那里的5条消息,即使理论上的队列不存在。

0 个答案:

没有答案