【问题标题】:How can I post a message to an ActiveMQ queue using Powershell 2.0?如何使用 Powershell 2.0 将消息发布到 ActiveMQ 队列?
【发布时间】:2018-04-03 03:40:22
【问题描述】:

我正在尝试将消息(“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 方面。任何帮助将不胜感激。

【问题讨论】:

    标签: powershell activemq powershell-2.0


    【解决方案1】:

    我知道这个问题已经很久没有提出来了,但是你看过this吗?

    nms 或 .NET 消息传递 API 库 should work

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-17
      • 1970-01-01
      • 2017-09-13
      • 1970-01-01
      • 2019-08-22
      • 2020-07-05
      • 2015-05-10
      • 1970-01-01
      相关资源
      最近更新 更多