簡體   English   中英

如何使用Powershell 2.0將消息發布到ActiveMQ隊列?

[英]How can I post a message to an ActiveMQ queue using Powershell 2.0?

我試圖將消息(“ mymessage”)發布到ActiveMQ隊列(“ myqueue”)。 在Powershell v3 +中,使用Invoke-WebRequest非常簡單。 不幸的是,我堅持使用v2。 據我所知,這是我需要在v2中復制的Powershell v3中的代碼:

$uri = "http://ACTIVEMQ-SERVER:8161/admin/sendMessage.action"

$r = Invoke-WebRequest http://ACTIVEMQ-SERVER:8161/admin/send.jsp -SessionVariable amq

$form = $r.Forms[0]

$form.fields["JMSDestination"] = "myqueue"
$form.fields["JMSPersistent"] = "true"
$form.fields["JMSText"] = "mymessage"

$r = Invoke-WebRequest -Uri $uri -WebSession $amq -Method Post -Body $form.Fields

我當前的嘗試如下所示:

$uri1 = [System.Uri]'http://ACTIVEMQ-SERVER:8161/admin/sendMessage.action'
$uri2 = [System.Uri]'http://ACTIVEMQ-SERVER:8161/admin/send.jsp'

$password = ConvertTo-SecureString 'mypassword' -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential('myusername',$password)

$request = [System.Net.WebRequest]::Create($uri2)
$request.method = "GET"
$request.Credentials = $credential

如您所見,我沒有取得太大進展。 我對Powershell非常陌生,尤其是它的.NET方面。 任何幫助將不勝感激。

我知道問這個問題已經很久了,但是您看過這個嗎?

nms或.NET消息傳遞API庫應該正常工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM