Created
March 27, 2012 23:55
Revisions
-
ramiro83 created this gist
Mar 27, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ Import-Module "PATH_TO_Microsoft.ServiceBus.dll" #Create the required credentials $tokenProvider = [Microsoft.ServiceBus.TokenProvider]::CreateSharedSecretTokenProvider("owner", "YOUR_ISSUERSECRET") $namespaceUri = [Microsoft.ServiceBus.ServiceBusEnvironment]::CreateServiceUri("sb", "YOUR_NAMESPACE", ""); $namespaceManager = New-Object Microsoft.ServiceBus.NamespaceManager $namespaceUri,$tokenProvider #Create a queue $queue = $namespaceManager.CreateQueue("MyPowershellQueue"); #Create a message factory $factory = [Microsoft.ServiceBus.Messaging.MessagingFactory]::Create($namespaceUri, $tokenProvider) #Create a sender (with ReceiveAndDelete mode) and send a few messages $sender = $factory.CreateMessageSender($queue.Path) #Send a few messages 1..10 | ForEach-Object { $sender.Send("Message from Powershell " + [Guid]::NewGuid()) } #Create a message receiver (with ReceiveAndDelete mode) and receive the messages $receiver = $factory.CreateMessageReceiver($queue.Path, [Microsoft.ServiceBus.Messaging.ReceiveMode]::ReceiveAndDelete) #Receive the messages 1..10 | ForEach-Object { Write-Output "Received " + $receiver.Receive([TimeSpan]::FromSeconds(10))} #Close the factory $factory.Close()