Byte Client/Server for SpringFramework.NET

Investigating using springframework.net for a project, I decided to create a quick sample of how to pass byte arrays around in a client server model. Reviewing the Spring.NmsQuickStart helped me create a sample that just passes byte arrays from a client to the server. One starting point was to get ActiveMQ running on the system, downloading the latest at the time ActiveMQ 5.5.0 Release. Unpack and launch the activemq service

The administration console can be viewed from a web url http://localhost:8161/admin


The project’s layout has a server, client, and shared data component.


The objects that get passed between the client and server are located in ByteServer.Common. This is a very simply defined byte array object.

A bat file located in the Data folder called generate-classes.bat is used to create the C# code from DataBlob.xsd.


The Converters folder holds some general utility classes that help with converting and resolving type objects from xml.


For the server component the sample is laid out as follows. Config data containing the configuration data for the spring framework. Handlers for handling and routing messages to the correct locations within the application. Services for defining the service interfaces. Gateways for sending service data out.


A good general start is to define and implement the service interfaces before moving onto anything else. The sample defines a single call that the client can make that returns a response.


Actual implementation of this interface is bind by the spring framework configuration data in ServiceStubs.xml


Screen clipping taken: 4/2/2011 10:06 PM

Handlers.xml is the configuration data that binds the service object to a handler object which then gets configured as a MesssageListenerAdapter in the Messaging.xml configuration.



The MessageListenerAdapter is then assigned a destination “APP.DATA.BLOB.REQUEST” to consume messages that are passed on that pipe.


The client application is very similar except we need a Gateway to get our messages from the client to the server and receive the return objects from the server. Config folder contains the spring framework configurations. Handlers contains the functions that handle returns from the server. Gateways contain the object that can communicate directly with the message broker for sending messages. Controller would be the objects that could be used in a MVC fashion in application development.


The trickiest thing I found about using spring framework for .net was getting the configuration data correct. Besides that the data transferred is great, very fast and persistence works great in AciveMQ. Here is ByteServer.zip project, the springframework.net project need to be included or referenced.

About these ads

About financecoding
I enjoy coding in dart.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: