Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Some fixes to have RabbitBrokerAdmin working as a service on Windows #22

Open
wants to merge 3 commits into from

1 participant

@simoneb

!Not tested!

Added the ability to pass the cookie but not the node name. I couldn't get it to work in any way using the .erlang.cookie file. Although I copied the same file everywhere (user directories of pretty much all users on my machine, c:\Windows, ...), I couldn't figure out what the two nodes were picking up, apparently two different ones. I fixed it by setting the cookie explicitly on both nodes.

Using the same hostname as self node also for the peer connection, as by default the OtpSelf class if hostname is not passed (which before this fix wasn't) tries to figure out the hostname and doesn't convert it to upper case (which RabbitBrokerAdmin does for the connection to self), thus introducing the chance for peer and self to have hostnames which differ in casing, which in turn appears to prevent them from talking to each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 8, 2012
  1. @simoneb
  2. @simoneb

    Ignored some files

    simoneb authored
Commits on Jan 10, 2012
  1. @simoneb
This page is out of date. Refresh to see the latest.
View
3  .gitignore
@@ -45,7 +45,8 @@
/_ReSharper.Spring.Messaging.Amqp.2008/
/_ReSharper.Spring.Messaging.Amqp.2010/
/bin/
-*.csproj.user
/_ReSharper.Spring.Messaging.Amqp.2010-40/
/package/
/buildlog.txt
+*.user
+*.suo
View
26 src/Spring.Erlang/Connection/SimpleConnectionFactory.cs
@@ -148,17 +148,27 @@ public void AfterPropertiesSet()
this.logger.Debug("Creating OtpSelf with node name = [" + selfNodeNameToUse + "]");
}
- try
- {
+ try
+ {
+ selfNodeNameToUse = selfNodeNameToUse.Trim();
+
+ if(!string.IsNullOrWhiteSpace(peerNodeName))
+ {
+ var peerNodeNameParts = peerNodeName.Split('@');
+
+ if (peerNodeNameParts.Length == 2)
+ selfNodeNameToUse += "@" + peerNodeNameParts[1];
+ }
+
if (StringUtils.HasText(this.cookie))
- {
- this.otpSelf = new OtpSelf(selfNodeNameToUse.Trim(), this.cookie);
+ {
+ this.otpSelf = new OtpSelf(selfNodeNameToUse, this.cookie);
}
else
- {
- this.otpSelf = new OtpSelf(selfNodeNameToUse.Trim());
- }
- }
+ {
+ this.otpSelf = new OtpSelf(selfNodeNameToUse);
+ }
+ }
catch (IOException e)
{
throw new OtpIOException(e);
View
8 src/Spring.Messaging.Amqp.Rabbit.Admin/Admin/IRabbitBrokerOperations.cs
@@ -91,7 +91,7 @@ public interface IRabbitBrokerOperations
/// <param name="vhostPath">The vhost path.</param>
/// <returns>The value.</returns>
/// <remarks></remarks>
- int AddVhost(string vhostPath);
+ void AddVhost(string vhostPath);
/// <summary>
/// Deletes the vhost.
@@ -99,7 +99,7 @@ public interface IRabbitBrokerOperations
/// <param name="vhostPath">The vhost path.</param>
/// <returns>The value.</returns>
/// <remarks></remarks>
- int DeleteVhost(string vhostPath);
+ void DeleteVhost(string vhostPath);
// permissions
@@ -111,7 +111,7 @@ public interface IRabbitBrokerOperations
/// <param name="read">The read.</param>
/// <param name="write">The write.</param>
/// <remarks></remarks>
- void SetPermissions(string username, Regex configure, Regex read, Regex write);
+ void SetPermissions(string username, string configure, string read, string write);
/// <summary>
/// Sets the permissions.
@@ -122,7 +122,7 @@ public interface IRabbitBrokerOperations
/// <param name="write">The write.</param>
/// <param name="vhostPath">The vhost path.</param>
/// <remarks></remarks>
- void SetPermissions(string username, Regex configure, Regex read, Regex write, string vhostPath);
+ void SetPermissions(string username, string configure, string read, string write, string vhostPath);
/// <summary>
/// Clears the permissions.
View
45 src/Spring.Messaging.Amqp.Rabbit.Admin/Admin/RabbitBrokerAdmin.cs
@@ -146,28 +146,11 @@ private static string GetDefaultNodeName()
/// <summary>
/// Initializes a new instance of the <see cref="T:Spring.Messaging.Amqp.Rabbit.Admin.RabbitBrokerAdmin"/> class.
- /// </summary>
- public RabbitBrokerAdmin() : this(DEFAULT_NODE_NAME)
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="T:Spring.Messaging.Amqp.Rabbit.Admin.RabbitBrokerAdmin"/> class.
- /// Create an instance by supplying the erlang node name (e.g. "rabbit@myserver"), or simply the hostname (if the
- /// alive name is "rabbit").
- /// </summary>
- /// <param name="nodeName">The node name or hostname to use.</param>
- public RabbitBrokerAdmin(string nodeName) : this(nodeName, null)
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="T:Spring.Messaging.Amqp.Rabbit.Admin.RabbitBrokerAdmin"/> class.
/// Create an instance by supplying the erlang node name and cookie (unique string).
/// </summary>
/// <param name="nodeName">The node name or hostname to use.</param>
/// <param name="cookie">The cookie value to use.</param>
- public RabbitBrokerAdmin(string nodeName, string cookie) : this(nodeName, DEFAULT_PORT, cookie)
+ public RabbitBrokerAdmin(string nodeName = null, string cookie = null) : this(nodeName ?? DEFAULT_NODE_NAME, DEFAULT_PORT, cookie)
{
}
@@ -359,10 +342,9 @@ public List<string> ListUsers()
/// </summary>
/// <param name="vhostPath">The vhost path.</param>
/// <returns>The value.</returns>
- public int AddVhost(string vhostPath)
- {
- // TODO Auto-generated method stub
- return 0;
+ public void AddVhost(string vhostPath)
+ {
+ this.ExecuteAndConvertRpc<object>("rabbit_vhost", "add", this.GetBytes(vhostPath));
}
/// <summary>
@@ -370,10 +352,9 @@ public int AddVhost(string vhostPath)
/// </summary>
/// <param name="vhostPath">The vhost path.</param>
/// <returns>The value.</returns>
- public int DeleteVhost(string vhostPath)
- {
- // TODO Auto-generated method stub
- return 0;
+ public void DeleteVhost(string vhostPath)
+ {
+ this.ExecuteAndConvertRpc<object>("rabbit_vhost", "delete", this.GetBytes(vhostPath));
}
/// <summary>
@@ -383,9 +364,9 @@ public int DeleteVhost(string vhostPath)
/// <param name="configure">The configure.</param>
/// <param name="read">The read.</param>
/// <param name="write">The write.</param>
- public void SetPermissions(string username, Regex configure, Regex read, Regex write)
- {
- // TODO Auto-generated method stub
+ public void SetPermissions(string username, string configure, string read, string write)
+ {
+ this.ExecuteAndConvertRpc<object>("rabbit_auth_backend_internal", "set_permissions", this.GetBytes(username), DEFAULT_VHOST, this.GetBytes(configure), this.GetBytes(read), this.GetBytes(write));
}
/// <summary>
@@ -396,9 +377,9 @@ public void SetPermissions(string username, Regex configure, Regex read, Regex w
/// <param name="read">The read.</param>
/// <param name="write">The write.</param>
/// <param name="vhostPath">The vhost path.</param>
- public void SetPermissions(string username, Regex configure, Regex read, Regex write, string vhostPath)
- {
- // TODO Auto-generated method stub
+ public void SetPermissions(string username, string configure, string read, string write, string vhostPath)
+ {
+ this.ExecuteAndConvertRpc<object>("rabbit_auth_backend_internal", "set_permissions", this.GetBytes(username), this.GetBytes(vhostPath), this.GetBytes(configure), this.GetBytes(read), this.GetBytes(write));
}
/// <summary>
Something went wrong with that request. Please try again.