{"id":16480920,"url":"https://github.com/ramblingcookiemonster/psrabbitmq","last_synced_at":"2025-08-01T10:36:10.215Z","repository":{"id":34112605,"uuid":"37942190","full_name":"RamblingCookieMonster/PSRabbitMq","owner":"RamblingCookieMonster","description":"PowerShell module to send and receive messages from a RabbitMq server","archived":false,"fork":false,"pushed_at":"2020-12-16T14:38:03.000Z","size":704,"stargazers_count":47,"open_issues_count":4,"forks_count":29,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-03T18:22:42.981Z","etag":null,"topics":["amqp","message","message-bus","powershell","powershell-modules","queue","queueing","rabbitmq","rabbitmq-server"],"latest_commit_sha":null,"homepage":"http://ramblingcookiemonster.github.io/RabbitMQ-Intro/","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RamblingCookieMonster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-23T20:08:42.000Z","updated_at":"2024-10-16T15:15:53.000Z","dependencies_parsed_at":"2022-07-31T11:08:08.204Z","dependency_job_id":null,"html_url":"https://github.com/RamblingCookieMonster/PSRabbitMq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RamblingCookieMonster/PSRabbitMq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RamblingCookieMonster%2FPSRabbitMq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RamblingCookieMonster%2FPSRabbitMq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RamblingCookieMonster%2FPSRabbitMq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RamblingCookieMonster%2FPSRabbitMq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RamblingCookieMonster","download_url":"https://codeload.github.com/RamblingCookieMonster/PSRabbitMq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RamblingCookieMonster%2FPSRabbitMq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268207631,"owners_count":24213018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amqp","message","message-bus","powershell","powershell-modules","queue","queueing","rabbitmq","rabbitmq-server"],"created_at":"2024-10-11T13:05:46.126Z","updated_at":"2025-08-01T10:36:10.161Z","avatar_url":"https://github.com/RamblingCookieMonster.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"PSRabbitMQ\n=============\n\nPowerShell module to send and receive messages from a RabbitMQ server.\n\nAll credit to @gpduck, all blame for butchering to @ramblingcookiemonster.\n\n### Functionality\n\nSend and receive messages through a RabbitMQ server:\n\n![Send and receive](/Media/SendAndReceive.png)\n\nListen for RabbitMQ messages until you break execution:\n\n![Listener gif](/Media/Listener.gif)\n\n### Instructions\n\n#### Prerequisites\n\n* A working RabbitMQ server\n* More details at the [PowerShell and RabbitMQ post](http://ramblingcookiemonster.github.io/RabbitMQ-Intro/)\n\n#### Managing RabbitMQ with RabbitMQTools\n\n[RabbitMQTools](https://github.com/RamblingCookieMonster/RabbitMQTools/) is a separate module for managing RabbitMQ over the REST API. It was originally written by @mariuszwojcik, with [slight modifications](https://github.com/mariuszwojcik/RabbitMQTools/issues/1) from @ramblingcookiemonster.\n\nSkip this section if you're just interested in using PSRabbitMQ to send and receive messages.\n\n```PowerShell\n# Install the module\n    Install-Module RabbitMQTools\n\n# No PowerShellGet module?\n    # Download RabbitMQTools\n    # https://github.com/RamblingCookieMonster/RabbitMQTools/archive/master.zip\n    # Unblock the archive\n    # Copy the RabbitMQTools module to one of your module paths ($env:PSModulePath -split \";\")\n\n#Import the module\n    Import-Module RabbitMQTools -force\n\n#Get commands from the module\n    Get-Command -module RabbitMQTools\n\n#Get help for a command\n    Get-Help Get-RabbitMQOverview\n\n#Define some credentials.  You need an account on RabbitMQ server before we can do this\n    $credRabbit = Get-Credential\n \n#Convenience - tab completion support for BaseUri\n    Register-RabbitMQServer -BaseUri \"https://rabbitmq.contoso.com:15671\"\n \n#I don't want to keep typing those common parameters... we'll splat them\n    $Params = @{\n        BaseUri = \"https://rabbitmq.contoso.com:15671\"\n        Credential = $credRabbit\n    }\n \n#Can you hit the server?\n    Get-RabbitMQOverview @params\n \n#This shows how to create an Exchange and a Queue\n#Think of the Exchange as the Blue USPS boxes, and a queue as the individual mailboxes the Exchanges route messages to\n    $ExchangeName = \"TestFanExc\"\n    $QueueName = 'TestQueue'\n \n#Create an exchange\n    Add-RabbitMQExchange @params -name $ExchangeName -Type fanout -Durable -VirtualHost /\n \n#Create a queue for the exchange - / is a vhost initialized with install\n    Add-RabbitMQQueue @params -Name $QueueName -Durable -VirtualHost /\n \n#Bind them\n    Add-RabbitMQQueueBinding @params -ExchangeName $ExchangeName -Name $QueueName -VirtualHost / -RoutingKey TestQueue\n \n#Add a message to the exchange\n    $message = [pscustomobject]@{samaccountname='cmonster';home='\\\\server\\cmonster$'} | ConvertTo-Json\n    Add-RabbitMQMessage @params -VirtualHost / -ExchangeName $ExchangeName -RoutingKey TestQueue -Payload $Message\n \n#View your changes:\n    Get-RabbitMQExchange @params\n    Get-RabbitMQQueue @params\n    Get-RabbitMQQueueBinding @params -Name $QueueName\n \n#View the message we added:\n    Get-RabbitMQMessage @params -VirtualHost / -Name $QueueName\n    \u003c#\n \n        # = the number in the queue\n        Queue = name of the queue\n        R = whether we've read it (blank when you first read it, * if something has read it)\n        Payload = your content.  JSON is helpful here.\n \n              # Queue                R Payload\n            --- -----                - -------\n              1 TestQueue            * {...\n    #\u003e\n \n#View the payload for the message we added:\n    Get-RabbitMQMessage @params -VirtualHost / -Name $QueueName | Select -ExpandProperty Payload\n\n    \u003c#\n        JSON output:\n\n        {\n            \"samaccountname\":  \"cmonster\",\n            \"home\":  \"\\\\\\\\server\\\\cmonster$\"\n        }\n    #\u003e\n\n#Example processing the message\n    $Incoming = Get-RabbitMQMessage @params -VirtualHost / -Name $QueueName -count 1 -Remove\n    $IncomingData = $Incoming.payload | ConvertFrom-Json\n    #If something fails, add the message back, or handle with other logic...\n\n    #It's gone\n    Get-RabbitMQMessage @params -VirtualHost / -Name $QueueName -count 1\n \n    #We have our original data back...\n    $IncomingData\n \n    #There are better ways to handle this, illustrative purposes only : )\n \n#Remove the Queue\n    Remove-RabbitMQQueue @params -Name $QueueName -VirtualHost /\n \n#Remove the Exchange\n    Remove-RabbitMQExchange @params -ExchangeName $ExchangeName -VirtualHost /\n \n#Verify that the queueu and Exchange are gone:\n    Get-RabbitMQExchange @params\n    Get-RabbitMQQueue @params\n\n```\n\n#### PSRabbitMQ\n\nThis is a module for sending and receiving messages using a RabbitMQ server and the .NET client library. Originally written by CD, slight modification by @ramblingcookiemonster.\n\n```powershell\n# Install the module\n    Install-Module PSRabbitMQ\n\n# No PowerShellGet module?\n    # Download PSRabbitMQ\n    # https://github.com/RamblingCookieMonster/PSRabbitMQ/archive/master.zip\n    # Unblock the archiveiles\n    # Copy the PSRabbitMQ module folder to one of your module paths ($env:PSModulePath -split \";\")\n\n#Import the module\n    Import-Module PSRabbitMQ\n\n#List commands in PSRabbitMQ\n    Get-Command -Module PSRabbitMQ\n\n#Get help for a function in PSRabbitMQ\n    Get-Help Send-RabbitMQMessage -Full\n\n#Define a default RabbitMQ server and get a credential to use\n    Set-RabbitMQConfig -ComputerName rabbitmq.contoso.com\n    $CredRabbit = Get-Credential\n\n#Set some common parameters we will always use:\n    $Params = @{\n        Credential = $CredRabbit\n        Ssl = 'Tls12' #I'm using SSL... omit this if you aren't\n    }\n\n#Assumes an exchange and bound queue set up per RabbitMQTools example:\n    #$ExchangeName = \"TestFanExc\"\n    #$QueueName = 'TestQueue'\n\n#Start waiting for a RabbitMQ message for 120 seconds\n    $Incoming = Wait-RabbitMQMessage -Exchange TestFanExc -Key 'TestQueue' -QueueName TestQueue -Timeout 120 @Params\n\n#Open a new PowerShell Window import PSRabbitMQ, and send a persistent message\n    Send-RabbitMQMessage -Exchange TestFanExc -Key 'TestQueue' -InputObject \"Hello!\" -Persistent @Params\n\n#Send an arbitrary object\n    $SomeObject = [pscustomobject]@{\n        Some='Random'\n        Data = $(Get-Date)\n    }\n\n    Send-RabbitMQMessage -Exchange TestFanExc -Key 'TestQueue' -InputObject $SomeObject -Persistent -Depth 2 @Params\n\n        \u003c#\n            # InputObject is serialized when sent,\n            # deserialized on the receiving end.\n            # No need for messing with JSON\n\n            Some   Data\n            ----   ----\n            Random 6/24/2015 4:24:51 PM\n        #\u003e\n```\n\n### Initial changes\n\nTemporary section to document changes since reciept of code. Will retire this eventually and rely on git commits.\n\n* 2015/6/23\n  * Added option for SSL connections\n  * Added option for authentication\n  * Created public New-RabbitMQConnectionFactory function to simplify handling the new options\n  * Created Add-RabbitMQConnCred private function to extract username/password from cred and add to factory\n  * Created New-RabbitMQSslOption private function to simplify setting SSL options.\n    * Note: the CertPath/CertPhrase/AcceptablePolicyErrors aren't specified by any calls to the function. Have not tested these.\n  * Renamed private parse function to ConvertFrom-RabbitMQDelivery, made it public. Allows parsing from Register-RabbitMQEvent.\n  * Wasn't sure how these were being used. Added handling for specifying an existing queue name and associated details (e.g. durable)\n  * Converted timeouts to seconds\n  * Added a LoopInterval (seconds) parameter for dequeue timeout\n  * Added comment based help\n  * Made asinine changes to formatting and organization. Sorry!\n  * Wrote no new tests. Sorry!\n\n* 2015/6/24\n  * Replaced client dll with latest bits\n  * Resolved issue with credential handling due to dll changes\n  * Added config handling for computername (get/set rabbitmqconfig) on appropriate functions\n  * Added persistent option for sending messages\n\n### Notes\n\nI don't know what messaging is and I'm terrible with code. Apologies for ugly, inefficient, or broken stuff : )\n\nTODO:\n\n * Break down functions a bit more. For example, offer functions to handle acknowledgements. I might retrieve a message requireing acknowledgement, and only send the ack down the line if my code meets certain criteria.\n\nReferences:\n\n* [RabbitMQ .NET Client references](http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v3.5.3/rabbitmq-dotnet-client-3.5.3-client-htmldoc/html/)\n* [RabbitMQ .NET / C# API Guide](http://www.rabbitmq.com/dotnet-api-guide.html)\n* [RabbitMQ Management API](https://raw.githack.com/rabbitmq/rabbitmq-management/rabbitmq_v3_5_3/priv/www/api/index.html)\n* [Accompanying blog post on RabbitMQ and PowerShell](http://ramblingcookiemonster.github.io/RabbitMQ-Intro/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framblingcookiemonster%2Fpsrabbitmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framblingcookiemonster%2Fpsrabbitmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framblingcookiemonster%2Fpsrabbitmq/lists"}