RamblingCookieMonster / PSRabbitMq

PowerShell module to send and receive messages from a RabbitMq server
http://ramblingcookiemonster.github.io/RabbitMQ-Intro/
MIT License
47 stars 29 forks source link

Possible to connect to vhosts besides / ? #3

Closed baxter19 closed 8 years ago

baxter19 commented 8 years ago

I have an exchange that is only accessible via a custom vhost. When I try to use the Send-RabbitMqMessage module to publish a message I get an error that the specified endpoint was not available.

The RabbitMQ logs shows the following error:

{amqp_error,access_refused, "access to vhost '/' refused for user 'mytest'", 'connection.open'}}

Is there any way to tell the Send-RabbitMQMessage module to connect to an alternate vhost?

baxter19 commented 8 years ago

Looks like it is possible to set this via the VirtualHost property

$vhostProp = [RabbitMQ.Client.ConnectionFactory].GetProperty("VirtualHost") $vhostProp.SetValue($Factory, "myvhost")

I believe I have this working by hard coding the value inside of New-RabbitMQConnectionFactory. If we were to add an optional -VHost parameter that could be passed through from the Send-RabbitMQMessage function I think we could expose this to callers.

RamblingCookieMonster commented 8 years ago

Makes sense to me - Adding this to the list, but feel free to submit a pull request if you'd like it integrated sooner!