CAVEAT: I am not a PS guru, in fact i am a complete n00b, combine that with my 101 knowledge of MSMQ and this is probably a disaster; you have been warned.
#Beginning of MassTransitSetup.ps1#
param(
[string] $nameofQ, [string]$username
)
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Messaging")
function CreatePrivateMSMQQueue {
param ( [string]$queuename = $(throw "Please specify the queue name!"),
[string]$user)
if ([System.Messaging.MessageQueue]::Exists($queuename))
{
write-host "$queuename already exists"
}
else
{
$newQueue = [System.Messaging.MessageQueue]::Create($queuename)
if ([System.Messaging.MessageQueue]::Exists($queuename))
{
write-host "$queuename has been created"
$newQueue.Label = $queuename
#Default to everyone if no user is specified
if([string]::IsNullOrEmpty($user)){$user = "Everyone"}
write-host "Setting permissions for user : $user"
$newQueue.SetPermissions(
$user,
[System.Messaging.MessageQueueAccessRights] "ReceiveMessage, PeekMessage, GetQueueProperties, GetQueuePermissions")
}
else
{
write-host "$queuename could not be created!!!"
}
}
}
function CreateDefaultMassTransitQueues{
param ( [string]$user)
$deaultqueues = ".\private$\mt_client", ".\private$\mt_server", ".\private$\mt_server1", ".\private$\mt_subscriptions"
foreach($i in $deaultqueues)
{
CreatePrivateMSMQQueue $i $user
}
}
#Begining of script
if([string]::IsNullOrEmpty($nameofQ))
{
CreateDefaultMassTransitQueues $username
}
else
{
CreatePrivateMSMQQueue $nameofQ $username
}
For more info on MassTransit see the google code home page and be sure to check out the wiki on how to set up the starbucks sample. If you are running the starbucks sample set the queues in the scripts above to:
$deaultqueues = ".\private$\mt_client",
".\private$\mt_server",
".\private$\mt_server1",
".\private$\mt_subscriptions",
".\private$\mt_subscription_ui",
".\private$\mt_health",
".\private$\mt_timeout"
No comments:
Post a Comment