Friday, April 25, 2014

When You Really, Really Want to Drop a SQL Server Database

I just discovered some things about dropping databases in SQL Server. Firstly, if you really want to first get rid of all connected users, this works:


However, when I then drop the offline database, the MDF and LDF files still hang around. I don't think this is officially documented behavior, at least I don't see it on any Microsoft site. Here's the final version I am now using to drop tables with extreme prejudice:


Wednesday, January 08, 2014

Neuron ESB and RabbitMQ

I want to make a disclaimer up front - I am currently working for the company that created Neuron ESB, Neudesic. That being said, I genuinely enjoy the product.

Since 2005, most of my time as a developer / consultant has been spent working with Microsoft BizTalk. Microsoft introduced the ESB Guidance (now referred to as the ESB Toolkit) to BizTalk 2006 R2. This introduced capabilities which allowed BizTalk to function as an Enterprise Service Bus. However, I have sometimes found it to be very difficult to get that ESB to do what I want.

I have spend much of the last two years working with an Enterprise Service Bus called Neuron ESB. While no product is perfect, I find that getting it to do what I want generally takes much less work than I was used to, and I'm very happy about that. When I started with Neuron, it supported 4 basic internal transports - Peer, TCP, MSMQ, and Named Pipes. Starting with Neuron ESB 3.0, it now has an additional transport, RabbitMQ. This allows durable, guaranteed, and reliable messaging. The same capabilities are available through MSMQ, but I'm pleased to have an alternative, particularly since RabbitMQ is open source.

The most difficult part of my experience with RabbitMQ was getting it installed properly. Apparently the installer for Neuron ESB can handle that for you automatically (if I had read the manual beforehand I would have known that). In any case, here's what I did to install it.

I first tried to download RabbitMQ and install it. It runs on top of Erlang, so I saw a warning to install Erlang first.

I downloaded Erlang from here. When I first tried to run the Erlang install, it complained about the installed version of the Visual C++ Redistributable. Once I uninstalled the latest versions of it (both 32 and 64 bit versions, although I'm not sure if both were necessary), the Erlang install ran without complaint. After that, the RabbitMQ install also ran through without complaint.

In Neuron, every messaging application you want to create should start with a topic. The topic defines the transport, QoS (Quality of Service), and auditing parameters. So I created a topic and chose RabbitMQ as the transport. To do that, I clicked on Messaging at the bottom left of the window, which navigates to the Messaging area of the application. Then I clicked Topics on the left hand side, and then New on the upper right frame:
To test the topic that uses RabbitMQ - I needed to create a publisher to send messages using the topic, and a subscriber to receive messages. The publisher is an abstract representation of a real world entity (SQL, CRM, C# app) which will be the message source, and the subscriber is an abstract representation of the receiver of the message. Here's what the publisher looks like in Neuron. To create the publisher, I clicked Publishers on the left and then clicked New on the upper right frame. Then I clicked the Edit Subscriptions button to add the ability to publish to the topic.

Creating a subscriber is equally trivial, click on Subscribers, create a new one, and then Edit Subscriptions to allow the subscriber to receive messages with the desired topic. Both publishers and subscribers are Partys in Neuron, and it is possible for a Party to be both a publisher and a subscriber.

After creating the publisher and the subscriber, two queues have now been created in RabbitMQ. To see them, click Deployment on the lower left, followed by RabbitMQ on the left navigation.

Actually testing this scenario highlights one place where Neuron really shines - an easy to use test client is provided which will allow sending messages through the system without needing to connect to any of the resources that will be used in the live environment. We'll need two instances of the test client, one to represent each role (publisher and subscriber). Click the Tools menu all the way at the top of the Neuron ESB Explorer window, then choose 2 Test Clients. In each client, use the drop down menu to choose the Party Id for each test client, and then click Connect. One client should be the publisher party, and the other the subscriber. If you use the Send tab on the publisher client to type and send a message, it will show up on the Receive tab of the subscriber client.

To get more of a sense of how all of how the queuing transport works, I recommend trying other scenarios. For example, try disconnecting the subscriber client temporarily, and then sending a message using the publisher. You will notice that the next time you connect the subscriber, it receives the queued message. Also, try connecting multiple clients as subscribers. When a message is sent, only one client will get the message. That's because all of the subscribers are pulling the message from the same queue, and once it's empty, no one else will see it.

You can download an evaluation version of Neuron ESB here.

Tuesday, September 10, 2013

Extension Method for DB Reader

I was doing some quick and dirty data access for a demo program the other day. I was annoyed by having to call reader.IsDbNull() every time a DB field was a nullable simple type. My buddy Milenko and I created the following to make things look a little neater:

public static class ExtensionMethods
    public static T? GetNullableValue(this IDataRecord reader, string fieldName) where  T: struct
        int ordinal = reader.GetOrdinal(fieldName);
        if (reader.IsDBNull(ordinal))
             return null;
        return (T)reader.GetValue(ordinal);

Friday, March 29, 2013

Node.js on Windows Azure - Issue With WebMatrix

I am going through some of the node.js material on Pluralsight. I am currently working on the Node in Windows and Azure modules.

I'm pretty sure that I went through the steps as described in the vids for getting WebMatrix working for an Azure website. I was able to create and publish a working node.js website to Azure, but I couldn't get it run locally (the browser showed a 500 error). I tried running the Etw.bat file that comes with iisnode, and I saw the following:

First, a whole bunch of events that said iisnode scheduled a retry of a named pipe connection to the node.exe process", followed by the event iisnode was unable to establish named pipe connection to the node.exe process. Finally, I saw iisnode request processing failed for reasons unrecognized by iisnode.

The page that showed the 500 error recommended that I make sure that the app pool user had permissions to the folders where the website was, C:\Users\Steve.Harclerode\Documents\My Web Sites. So I made sure that IIS APPPOOL\DefaultAppPool had full permissions, but I saw the same error. I even tried giving full permissions to Everyone for the folder, but that also failed.

I copied the app to a folder under a currently running iisnode application, and I was able to run it from there just by browsing to it from IIS. Unfortunately, that folder is under C:\Program Files, and I couldn't save files there unless I logged in as admin

What finally worked was to choose Add Application under IIS and select the original folder. Honestly, I'm not sure why this worked, since WebMatrix runs the program using another port, in my case 34581. I'm hoping wiser minds than mine will comment on this blog. :-)

Friday, March 22, 2013

BizTalk is Alive!

I have heard (or read) several people claiming that "BizTalk is dead." Microsoft seems to disagree though, they just released BizTalk 2013 to MSDN. I hear through the grapevine that it will be generally available April 1.

Wednesday, March 20, 2013

SharePoint 2013 Configuration Error

I don't normally just post links, but this one saved my butt for a single server installation of SharePoint 2013. The error message I saw was "The SDDL string contains an invalid sid or a sid that cannot be translated.". I saw the error while I was running the configuration wizard.

Monday, April 02, 2012

Neuron ESB

Lately I've been learning how to use an ESB that my company (Neudesic) created. I'm really liking it, it seems very intuitive and easy to use. It has a bit of overlap with BizTalk functionality, but I think that both of them together make a great team. I'm not very fond of the BizTalk ESB Toolkit, so I'm glad to find something I like better.

The product is called Neuron ESB. I don't have time to go into detail at the moment (deadlines, you know!), but I plan to write more later. You can click on the link for more details.