This project is read-only.

Subscribe Message based on Content Filter

Feb 27, 2011 at 4:59 PM

The Simple Service Bus is a nice architecture for a Sub/Pub system over multible application placed on differend computer.

I habe a application (on PC1) that reveice data from a serial port connected witch a RS-485 bus. Over the bus send multible devices data. Every device have a deviceaddress.
The application receice the message from the serial port, create a message type an publish the message via simpe service bus. I will use MSMQ.

Message Sample:







At different computer (PC2, PC3), i have application that consume data from the devices connected on PC1.

The application make a Subscription for the DeviceMessageReceiveType. But i will filter the subscription based on content (Sender Device Address - <DeviceAddress>) in the Message.

Sample: PC2 receive only Message from Strang 02 and Devices 05,03,04. PC3 receive only Messages from Strang 01 an Devices 01,02,09

public class DeviceMessageReceiveTyp
        public Int32 StrangAddress { get; set; }
        public Int32 DeviceAdress { get; set; }
        public string DeviceData { get; set; }
//Create the endpoint
            var epBuilder = new EndpointBuilder<MessagingEndpoint, MsmqTransport>();
            //Minimum configuration for endpoint operation
            _endpoint = epBuilder.CreateEndpoint(/*pass IoC wrapper if desired*/);
            epBuilder.Metadata.EndpointID = "DeviceController";
            epBuilder.Metadata.ReturnAddress = "StrangController";

            epBuilder.MessageTypes.RegisterMessageType(typeof(DeviceMessageReceiveTyp), "ConfiglessClient");

            epBuilder.MessageFilters.RegisterMessageFilter((typeof(DeviceMessageReceiveTyp), ???predicate???, SimpleServiceBus.Bus.Pipeline.PipelineDirection.Receive);

How must i create the predicate expresson or filter?

Plase can you help me with a source sample?


Thanks, and best regards

Marek from Switzerland

Feb 28, 2011 at 4:42 AM

I haven't done anything with filters, but check the samples and/or unit tests, they may point you in the right direction.