Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider extracting System.ServiceModel reliant code into seperate assembly #57

Closed
osudude opened this issue Apr 10, 2015 · 30 comments
Closed

Comments

@osudude
Copy link

osudude commented Apr 10, 2015

Would like to use RabbitMQClient.dll in MSSQL CLR but it is blocked by SQL because of the System.ServiceModel dependency (System.ServiceModel is considered unsafe by SQL).
It would be nice if the rabbit code that relies on System.ServiceModel could be extracted to a separate optional assembly.

@michaelklishin
Copy link
Member

We have heard such requests before. @osudude would you be interested in working on a pull request that does this? Our development process is fairly straightforward and we have a tiny team, so this likely won't be a high priority. But we are open to including this change (for 3.6.0, because I suppose this will break existing apps).

Thank you!

@osudude
Copy link
Author

osudude commented Apr 24, 2015

I'll take a look at it. If not crazy hard, will try to make the change and submit a pull request.
thanks
scott

Date: Fri, 10 Apr 2015 08:09:12 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [rabbitmq-dotnet-client] Consider extracting System.ServiceModel reliant code into seperate assembly (#57)

We have heard such requests before. @osudude would you be interested in working on a pull request that does this? Our development process is fairly straightforward and we have a tiny team, so this likely won't be a high priority. But we are open to including this change (for 3.6.0, because I suppose this will break existing apps).

Thank you!


Reply to this email directly or view it on GitHub.

@osudude
Copy link
Author

osudude commented Apr 25, 2015

@michaelklishin Quick question, I removed the assembly reference to System.ServiceModel from RabbitMQ.Client and surprisingly everything seems to build without error. What code in RabbitMQ.Client actually uses System.ServiceModel?

thanks

@michaelklishin
Copy link
Member

@osudude pretty sure nothing in the client code should depend on ServiceModel: the client is Mono-compatible while ServiceModel is Windows-only.

@osudude
Copy link
Author

osudude commented Apr 25, 2015

So for the windows build of the client assembly it is safe to remove the System.ServiceModel assembly reference? Is there a good unit test I can run to verify nothing is broken or do I just need to go manually try it out?

thanks

@michaelklishin
Copy link
Member

You can run the client test suite. We'll do it to verify your PR anyway :)

On 25/4/2015, at 17:50, osudude [email protected] wrote:

So for the windows build of the client assembly it is safe to remove the System.ServiceModel assembly reference? Is there a good unit test I can run to verify nothing is broken or do I just need to go manually try it out?

thanks


Reply to this email directly or view it on GitHub.

@osudude
Copy link
Author

osudude commented Apr 25, 2015

Installed Rabbit 3.51 and Erlang on my dev box (win2012). Tried the tests inside of Visual Studio 2013 using resharper test runner.

Is there an assumed relationship of test code location to installed rabbit location? I get several errors like the following:

Failure while running cmd.exe /c ""............\rabbitmq-server\scripts\rabbitmqctl.bat" -n rabbit@SMPC2 list_connections -q pid peer_port":
The system cannot find the path specified.

Failure while running cmd.exe /c ""............\rabbitmq-server\scripts\rabbitmqctl.bat" -n rabbit@SMPC2 set_vm_memory_high_watermark 0.4":
The system cannot find the path specified.

waiting on a latch timed out
Expected: True
But was: False

at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args)
at NUnit.Framework.Assert.IsTrue(Boolean condition, String message)
at RabbitMQ.Client.Unit.IntegrationFixture.Wait(ManualResetEvent latch, TimeSpan timeSpan) in Fixtures.cs: line 560
at RabbitMQ.Client.Unit.TestConnectionRecovery.TestDelayedBasicAckNackAfterChannelRecovery(TestBasicConsumer1 cons, ManualResetEvent latch) in TestConnectionRecovery.cs: line 927
at RabbitMQ.Client.Unit.TestConnectionRecovery.TestBasicAckAfterChannelRecovery() in TestConnectionRecovery.cs: line 72

thanks

@michaelklishin
Copy link
Member

You need to run rabbitmq-server from the umbrella, or make sure ../rabbitmq-server/scripts/rabbitqctl can control the running node. See Running Tests.

@osudude
Copy link
Author

osudude commented Apr 25, 2015

Got the umbrella project. Getting new test errors now. Guess I need to build the umbrella? How do you build the umbrella on a Visual Studio 2013 / windows machine?

SetUp : RabbitMQ.Client.Exceptions.BrokerUnreachableException : None of the specified endpoints were reachable
----> RabbitMQ.Client.Exceptions.ConnectFailureException : Connection failed
----> System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it 127.0.0.1:5672
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
at RabbitMQ.Client.ConnectionFactory.CreateConnection() in ConnectionFactory.cs: line 325
at RabbitMQ.Client.Unit.TestConnectionRecovery.CreateAutorecoveringConnection(TimeSpan interval) in TestConnectionRecovery.cs: line 859
at RabbitMQ.Client.Unit.TestConnectionRecovery.CreateAutorecoveringConnection() in TestConnectionRecovery.cs: line 851
at RabbitMQ.Client.Unit.TestConnectionRecovery.Init() in TestConnectionRecovery.cs: line 62
--ConnectFailureException

@michaelklishin
Copy link
Member

You need to start RabbitMQ: make run in the server directory.

On 25/4/2015, at 19:54, osudude [email protected] wrote:

Got the umbrella project. Getting new test errors now. Guess I need to build the umbrella? How do you build the umbrella on a Visual Studio 2013 / windows machine?

SetUp : RabbitMQ.Client.Exceptions.BrokerUnreachableException : None of the specified endpoints were reachable
----> RabbitMQ.Client.Exceptions.ConnectFailureException : Connection failed
----> System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it 127.0.0.1:5672
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
at RabbitMQ.Client.ConnectionFactory.CreateConnection() in ConnectionFactory.cs: line 325
at RabbitMQ.Client.Unit.TestConnectionRecovery.CreateAutorecoveringConnection(TimeSpan interval) in TestConnectionRecovery.cs: line 859
at RabbitMQ.Client.Unit.TestConnectionRecovery.CreateAutorecoveringConnection() in TestConnectionRecovery.cs: line 851
at RabbitMQ.Client.Unit.TestConnectionRecovery.Init() in TestConnectionRecovery.cs: line 62
--ConnectFailureException


Reply to this email directly or view it on GitHub.

@michaelklishin
Copy link
Member

Also, unless you configure the server to enable TLS, provide certificates and key, etc, you will see 5 failures saying that broker on port 5671 is not reachable. Don't worry about it.

@osudude
Copy link
Author

osudude commented Apr 28, 2015

C:\Dev\GitHub\rabbitmq\rabbitmq-public-umbrella [master]>

make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • make run
  • - CategoryInfo          : ObjectNotFound: (make:String) [], CommandNotFoundException
    - FullyQualifiedErrorId : CommandNotFoundException
    
    

Sorry for the nube question, @michaelklishin but where do I get make? Running Win2012 server / VS2013 / Github powershell extension

@michaelklishin
Copy link
Member

@osudude we use Cygwin to provision make, libxslt, python, git, and other tools (not relevant to this sub-project).

Just push your branch somewhere. I'll test it for you.

@osudude
Copy link
Author

osudude commented Apr 30, 2015

Is there a specific branch for Rabbitmq client .NET 3.5?

@osudude
Copy link
Author

osudude commented May 3, 2015

Looks like the .net 3.5 version of rabbitmq-client was 3_4_3.

Looking at the 3_4_3 version of Rabbit client, it appears the dependency on System.ServiceModel is due to the use of SynchronizedCollection. Strange that SynchronizedCollection is in System.ServiceModel as this is a relatively generic class.

@michaelklishin
Copy link
Member

@osudude even more so that most of its public instance methods are not synchronised at all. Thank you for digging this out. Would requiring .NET 4.5 provide an alternative?

@osudude
Copy link
Author

osudude commented May 3, 2015

Eventually, .NET 4.5 will be on the table once we upgrade from SQL2008 to SQL2014. Until then, looks like we are stuck with RabbitMQ 3_4_3. Won't help now, but I did write up a MS Connect issue to move SynchronizedCollection:

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/7803021-consider-moving-synchronizedcollection-t-from-sys

Found another spot where SQL CLR is not happy with RabbitMQ 3_4_3

"RabbitMQ.Client' has a static field 'DefaultAuthMechanisms'. Attributes of static fields in safe assemblies must be marked readonly in Visual C#, ReadOnly in Visual Basic, or initonly in Visual C++ and intermediate language."

Had to modify ConnectionFactory by adding readonly modifier like so:

public static readonly AuthMechanismFactory[] DefaultAuthMechanisms =
new AuthMechanismFactory[] { new PlainMechanismFactory() };

@michaelklishin
Copy link
Member

@osudude feel free to submit small PRs against master. We're all for supporting SQL CLR, even if it'd have to be a newer version.

Should we close this issue and file a new more specific one? As I understand the root problem is in .NET itself.

@osudude
Copy link
Author

osudude commented May 3, 2015

Here is one last change I had to make for SAFE CLR use on Rabbit 3_4_3

"CREATE ASSEMBLY failed because type 'RabbitMQ.Client.Framing.Impl.Connection' in safe assembly 'RabbitMQ.Client' has a static field 'HandshakeTimeout'. Attributes of static fields in safe assemblies must be marked readonly in Visual C#, ReadOnly in Visual Basic, or initonly in Visual C++ and intermediate language."

Had to add readonly modifier to HandshakTimeout in Connection.cs:

public static readonly int HandshakeTimeout = 10000;

@michaelklishin
Copy link
Member

Both of the changes make sense and are something we'd accept ;)

@osudude
Copy link
Author

osudude commented May 3, 2015

You can close this issue if you want. Only had to do 2 things to get Rabbit 3_4_3 up to snuff for SAFE CLR use.

  1. Remove System.ServiceModel dependency.
  2. Mark public static attributes as readonly.

thanks

@michaelklishin
Copy link
Member

@osudude see #85. Thank you for the suggestions. I've removed the System.ServiceModel reference and at least on 4.0+, everything seems to be dandy.

We'd greatly appreciate if you could tell us if we are compatible with SQL CLR in SQL Server 2014 with this change :)

@osudude
Copy link
Author

osudude commented May 3, 2015

Thanks, I am now mucking around with CAS permissions in SQL CLR. Seems like default behavior is to block DNS and external threading access to CLR procs. I'm sure there is a way around it. Just trying to figure out how to make that happen in SQL.

@osudude
Copy link
Author

osudude commented May 3, 2015

@michaelklishin Is RabbitMQ DotNet client strong named?

@michaelklishin
Copy link
Member

@osudude yes, releases are signed with a key. Unoffficial (local) builds are, too, if you provide a key.

@michaelklishin
Copy link
Member

@osudude see Strong Naming on our download page.

@osudude
Copy link
Author

osudude commented May 3, 2015

@michaelklishin Finally got my local modified build of RabbitMQ.Client 3_4_3 to work in SQL targeting .NET 3.51. In SQL, you have to register the RabbitMQ.Client assembly as unsafe or external access because it requires network access and external threading. I still need to try out your latest master build targeting .NET 4.51 in SQL 2014.

@osudude
Copy link
Author

osudude commented May 3, 2015

@michaelklishin Just tried out the master build with your latest changes for SQL2014 CLR. Works great in SQL2014 targeting .NET 4.5 (assuming you register the assemblies with SQL correctly).

thanks

@osudude
Copy link
Author

osudude commented May 3, 2015

@michaelklishin I noticed the assemblyinfo.cs get dynamically swapped out at build time using the version from Local.Props. That's cool. Is this a custom build task that does this?

@michaelklishin
Copy link
Member

@osudude yes, "detokenize". It's based on MSBuild community tasks, specifically TemplateFile.

@dumbbell dumbbell added this to the 3.6.0 milestone May 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants