The .NETCompute Node sample filters, modifies and transforms messages using code that has been written in C#. You can use the .NETCompute node on Windows brokers to construct output messages and interact with Microsoft .NET Framework (.NET) or Component Object Model (COM) applications.
The sample uses .NETCompute nodes whose code has been written in C# and then built into an assembly (with extension .dll) using Microsoft Visual Studio 2010. WebSphere Message Broker installs Templates into Microsoft Visual Studio which provide a basic Evaluate method structure to which a flow developer can then add their own code. This is a similar concept to the Compute node, JavaCompute node and PHPCompute node. Readers of this sample may not have access to a Microsoft Visual Studio installation, so a prebuilt assembly file is provided. This means that even without Microsoft Visual Studio you can still deploy and run the sample. The topic Preparing for the deployment of the .NETCompute node sample describes where the assembly file is located and how it can be used. The sample also provides the C# source code which you can read about here.
A retail company has several stores at separate locations within a city. The stores complete sale transactions throughout the day. Each transaction results in an XML message being routed to an input queue at a central IT office. The stores are also rolling out a customer loyalty program. For every customer registration on the loyalty program, an XML message in a different format (containing the customer's personal details) is sent to the same input queue. The company has decided to use WebSphere Message Broker to process the messages. The routing and transformations used in the solution demonstrate the capabilities of the .NETCompute node.
The message flow used is:
The messages pass through the message flow as follows:
The sections below include examples of the two different kinds of input test XML messages (SaleEnvelope and LoyaltyProgram). The output messages are included in the Running the sample section.
<SaleEnvelope> <Header> <SaleListCount>1</SaleListCount> </Header> <SaleList> <Invoice><Initial>K</Initial> <Initial>A</Initial> <Surname>Braithwaite</Surname> <Item><Code>00</Code> <Code>01</Code> <Code>02</Code> <Description>Twister</Description> <Category>Games</Category> <Price>00.30</Price> <Quantity>01</Quantity> </Item> <Item> <Code>02</Code> <Code>03</Code> <Code>01</Code> <Description>The Times Newspaper</Description> <Category>Books and Media</Category> <Price>00.20</Price> <Quantity>01</Quantity> </Item> <Balance>00.50</Balance> <Currency>Sterling</Currency> </Invoice> <Invoice> <Initial>T</Initial> <Initial>J</Initial> <Surname>Dunnwin</Surname> <Item> <Code>04</Code> <Code>05</Code> <Code>01</Code> <Description>The Origin of Species</Description> <Category>Books and Media</Category> <Price>22.34</Price> <Quantity>02</Quantity> </Item> <Item> <Code>06</Code> <Code>07</Code> <Code>01</Code> <Description>Microscope</Description> <Category>Miscellaneous</Category> <Price>36.20</Price> <Quantity>01</Quantity> </Item> <Balance>81.84</Balance> <Currency>Euros</Currency> </Invoice> </SaleList> <Trailer> <CompletionTime>12.00.00</CompletionTime> </Trailer> </SaleEnvelope>
<LoyaltyProgram xmlns:applicant="http://www.example.org/applicant" xmlns:store="http://www.example.org/store"> <applicant:ApplicantDetails> <applicant:FirstName>Ben</applicant:FirstName> <applicant:LastName>Thompson</applicant:LastName> <applicant:HouseNo>1</applicant:HouseNo> <applicant:Street>Happiness Avenue</applicant:Street> <applicant:Town>Grumpyville</applicant:Town> </applicant:ApplicantDetails> <store:StoreDetails> <store:StoreID>001</store:StoreID> </store:StoreDetails> </LoyaltyProgram>
After you have imported and deployed the sample, you can run it by following the instructions in the Running the sample section.