Taking babysteps into Ruby on Rails land

It’s been real quiet here because I’ve been rather busy at work and the re-enactment season kicked off. I’ve also started a little project for my own which will be based on Ruby on Rails. I have no experience with it what so ever.

I followed the steps on the offical site, please note that you need super user privileges so begin each command with sudo. While everything was installing I stumbled upon this article on the Apple site, which I’m now following to understand and learn the language and the framework. It’s a year old but seems up to date so far. They also specify the sudo command so you’re ok with my first tip ;).

This week on my screen #7

Updated to BE 1.5

Just a small post to see if everything is still up and running, only the lightbox extenstion is having a small design issue. Apart from that everything went smooth. For those using MS SQL 2000 as backend, you can just use the upgrade script that comes with the 1.5 release.

Mono 2.4 and MonoDevelop 2.0 on OSX

I installed Mono and MonoDevelop again this week but found out rather quickly that not much has changed in MonoDevelop since the last time I used it. MD went 2.0 recently while Mono is now 2.4.

I probably should have guessed that all the problems I ran into using MD were still not resolved because of the red letters on their site discouraging using MonoDevelop on the Mac. On the forums however I found out that in the next version a lot of improvements should make it into the Mac distribution.

Mono is closing in on .Net, it was good to see that a lot of the c# language enhancements as well as new .NET features have made it into the platform. Including automatic properties, lambdas, etc. Linq is said to be supported as well but I was unable to write even a simple query. I never got the select statement to work. Could be me though.

What I did find interesting was how you can create native looking applications for almost every platform while using the same Mono core of your application. I really want to try that out! On the Mono site you get linked to Cocoa# for OSX but that project seems to be rather silent though a user made a recent contribution. I did like the way on how you could use the existing development tools available, xCode and Interface builder so you would not need to learn another application. There’s a video demonstrating the approach.

A more active project, with the latest version released in March, is Monobjc which seems to have the same goal as Cocoa#. I’ll probably try this one out first. Anyone with some Objective-C and Cocoa experience will recognize the way it works in this tutorial. Though at first glance you can’t use xCode to write your c#.

Oh yeah last time I checked you can use Spring.Net with Mono too.

WCF ChannelManagement drop 3

A new version is available, with two modes of channel pooling.

The ‘FixedPool’ mode is based on the SimplePool which you can find in the Spring.Pooling library. Meaning that at any given time there can be a maximum of x amount of channels. Where x equals the SimplePool’s size. So if the size of your pool is 5 and you request a 6th channel while the previous 5 are still busy doing their business you’ll get a blocking thread until one of the previous five is returned to the pool. This is good for when you want to limit the connectivity to your server, but don’t forget that it will block the calling thread when you request more channels than there are available.

The other pool mode is ‘VariablePool’. This is a pool that grows and shrinks depending on the load. So if you request 6 channels you’ll get 6 channels which will be available for future requests when returned to the pool. Channels which are no longer usable will be removed and new ones will be created when needed.

I spend most of the time trying to find a good away around my dependency on ChannelFactory. Since that class has a method ‘CreateChannel’ which takes no arguments and the factory can be configured using the endpoint name in your system.servicemodel section. The interface which the class implements doesn’t have this. The classes which populate a channelfactory from the app.config are marked internal and so you can’t use them.

The only solution I found that worked pretty ok was a wrapper interface which exposes the CreateChannel method, it helped me to test the code without a channelfactory instance.

I did a lot of renaming in the codebase but on the consuming end not much has changed.

A ‘SingleAction’ operating channel is still the easiest to configure.

<object id=“MyService” type=“WCFChannelManager.ChannelManagerFactoryObject, Perponcher.WCFChannelManager”>
	<property name=“ChannelType” expression=“T(Server.IService1, Common)/>
	<property name=“EndpointConfigurationName” value=“MyEndpoint”/>
</object>

Creating a fixed pool is one extra line.

<object id=“MyService” type=“WCFChannelManager.ChannelManagerFactoryObject, Perponcher.WCFChannelManager”>
	<property name=“ChannelType” expression=“T(Server.IService1, Common)/>
	<property name=“EndpointConfigurationName” value=“MyEndpoint”/>
	<property name=“ChannelManagementMode” value=“FixedPool”/>
</object>

A variable pool means just another value as ChannelManagementMode.

<object id=“MyService” type=“WCFChannelManager.ChannelManagerFactoryObject, Perponcher.WCFChannelManager”>
	<property name=“ChannelType” expression=“T(Server.IService1, Common)/>
	<property name=“EndpointConfigurationName” value=“MyEndpoint”/>
	<property name=“ChannelManagementMode” value=“VariablePool”/>
</object>

If you want to use your own channel manager, you can use the ProductTemplate to hook everything up. The sample below illustrates this, here the variable pool is configured via the template instead of using the ChannelManagementMode property of the FactoryObject.

<object id="MyService" type="WCFChannelManager.ChannelManagerFactoryObject, Perponcher.WCFChannelManager">
	<property name="ChannelType" expression="T(Server.IService1, Common)"/>
	<property name="EndpointConfigurationName" value="MyEndpoint"/>
	<property name="ProductTemplate">
	<object>
		<property name="ChannelManager">
			<object type="WCFChannelManager.ChannelPoolManager&lt;Server.IService1>, Perponcher.WCFChannelManager">
				<constructor-arg value="MyEndpoint"/>
				<constructor-arg>
					<object type="WCFChannelManager.AutoSizePoolFactory, Perponcher.WCFChannelManager"/>
				</constructor-arg>
			</object>
		</property>
	</object>
	</property>
</object>

The same approach can be used to configure the channelfactory for i.e. passing credentials.

<object id="MyService" type="WCFChannelManager.ChannelManagerFactoryObject, Perponcher.WCFChannelManager">
	<property name="ChannelType" expression="T(Server.IService1, Common)"/>
	<property name="EndpointConfigurationName" value="MyEndpoint"/>
	<property name="ChannelManagementMode" value="VariablePool"/>
	<property name="ProductTemplate">
		<object>
			<property name="ChannelManager.ChannelFactory.Credentials.UserName.UserName" value="username"/>
			<property name="ChannelManager.ChannelFactory.Credentials.UserName.Password" value="password"/>
		</object>
	</property>
</object>

That’s it for now. Future additions will include:

  • setting the pool size of a fixed sized pool via the FactoryObject, for now the default of 5 is used
  • extend or add a new pool based on the SimplePool. At the moment closed or faulted channels are not removed from that implementation, meaning that when your 5 channels are closed the pool will raise an exception.

WCFChannelManager_drop3.zip (1.16 mb)

Series: