Feeds:
Posts
Comments

Here  are my first interactions with the NSerivce Bus (NSB)

==================================================

NSB – Setup

==================================================

  1. Downloaded the code (www.nservicebus.com)
  2. Without looking into the code – I clicked the RunMeFirst.bat file
    This configured DTC, MSMQ and relevant performance counters on my machine (required a system restart)
    Here is how my console looked like:
    I ran it through the command prompt to visualize any errors if reported
  3. Open the pub-sub sample located under
    Location: …\.net 4.0\samples\PubSub\PubSub.sln
    Solution Structure:

 The solution sample consists of four projects. Lets look into these projects and find out the workings of a publish and subcribe model in the NSB.

==================================================

Project: MyMessages

==================================================

This is the project where I define all my contracts. The important thing to note is that all messages in NServiceBus must ultimately inherit from the IMessage interface. This class defines two message types

  1. IEvent: Interface that subscribes to IMessage
  2. EventMessage: Classes that implements the above interface  (IEvent)

IMessage is an NSB type interface. It is a marker interface to indicate that a class is a message suitable for transmission and handling by an NServiceBus

Note: I added the SequenceNo field to IEvent class sample to track down messages by an integer field- for simplicity purposes

The above fields would be populated by the publisher and fed into the NSB, where the subscriber would receive the message and handle it.

==================================================

Project: MyPublisher

==================================================

The project has the following files in it:

The MyPublisher project (a console application) runs as a process that will be publishing messages. Project properties screen shot is as follows:

 

This project consists of three classes (described as follows). I’ll start by covering the theory bits ..

    1. EndPointConfig: Inherits from  two interfaces (boiler plate code)
      a.     IConfigureThisEndpoint: Indicates that the implementing class will specify configuration.
      b.     AsA_Publisher: Indicates this endpoint is a publisher.  The provided sample file does not implement both interfaces (blank)
       
    2. ServerEndpoint: Implements IWantToRunAtStartup and contains an interface for IBus
      a.     IWantToRunAtStartup: Implementers will be invoked when the endpoint starts up. Dependency injection is provided for these types. 
               It implements two methods for the interface
              i.     Run(): Method called at startup. This is where the MyMessage type is populated.
              ii.     Stop(): Method called on shutdown.                
      IBus: Defines a bus to be used with NServiceBus. (Whatever that means!!) .
    3. SubscriptionAuthorizer: Inherits from a single interface (boiler plate code)
      a.      IAuthorizeSubscriptions: Implementer will be called by the infrastructure in order to authorize subscribe and unsubscribe requests from other endpoints. Infrastructure automatically registers one implementing type in the container as a singleton.               
      It implements two methods for the interface
                     i.     AuthorizeSubscribe():Return true if the client endpoint is to be allowed to subscribe to the given message type
                     ii.     AuthorizeUnsubscribe():Return true if the client endpoint is to be allowed to unsubscribe to the given message type The provided sample class returns true for both methods 
      … and two configuration files
    4. App.Config: Contains two sections
      a.      MsmqTransportConfig: Used to configure the MSMQ parameters. Has the following key properties:
      → InputQueue: The name of the queue on the local machine from which this process will be receiving messages
       → ErrorQueue: The name of the queue to which messages will be transferred if they could not be processed successfully b.      UnicastBusConfig: (This config section can be ignored) Used to configure the bus (more control on configuration). This is the place where you need to tell the Bus what messages you will be allowing for the current process and what endpoint queue you will be using. Providing you have MSMQ installed on your machine NServiceBuscreates this queue for you. → MessageEndpointMappings: Contains the mappings from message types (or groups of them) to endpoints
      and has the following key properties in MessageEndpointMappings section:
                → Messages: A string defining the message assembly, or single message type
                → Endpoint: The queue on which messages are destined towards (format: queue@machine) 
      This tells NServiceBus that all messages in the MyMessages assembly should be routed to the queue called MyPublisherInputQueueon the local machine.Comment: I “think”, the unicastBusConfig would be required if multiple data contracts are being used by the publisher. This would explicitly direct message types from a specific type (a contract) to the destined queue. If not, this section can be ignored.
    5. NServiceBus.Host.exe.config  (This config section can be ignored)

Contains one keyvalue pair in the appsettings section.

&amp;lt;appSettings&amp;gt;<br />
&amp;lt;add key=&amp;quot;EndpointConfigurationType&amp;quot; value=&amp;quot;MyPublisher.EndpointConfig, MyPublisher&amp;quot;/<br />
&amp;lt;/appSettings&amp;gt;

where: → EndpointConfigurationType = Used to determine the assembly type of the publisher. Should only be used if you don't want NSB to scan your assemblies OR if you have multiple configurations and want NSB to load a specific one. You can probably remove "EndpointConfigurationType" from  your config.
Value:
MyPublisher.EndpointConfig = Namespace.TypeName,
MyPublisher   = AssemblyName

 ***************************************************************

Project: MyPublisher

¦→ Publishing a msg to the bus

***************************************************************

Let’s look at publishing a message into the bus. I don’t have any queue created on my local machine and would expect the NSB to create two queues

  1. MyPublisherInputQueue
  2. error

 Once I start a new instance of the project (MyPublisher→Debug → Start new instance), I see three queues created by the bus :)

Results:

I wasn’t expecting the “mypublisher.endpointconfig_v1.0.0.0_subscription” queue. This queue was created by NSB to manage publishers and subscribers.

An important thing to note here is that the publisher won’t push any message to the queue unless there are relevant subscriptions registered (i.e relevant entries in the mypublisher.endpointconfig_v1.0.0.0_subscription queue). As soon as the relevant subscriber comes on board, the previously sent message by the publisher is matched – an entry created in the endpoint queue and THEN the message is delivered to the subscriber queue.

Lets understand the subscribers to proceed further

==================================================

Project: Subscriber2

==================================================

This project includes a reference to MyMessages project.

The project consists of three classes

  1. EndPointConfig: Inherits from  two interfaces (boiler plate code)
    a.      IConfigureThisEndpoint: Indicates that the implementing class will specify configuration.
    b.      
    AsA_Server: Indicates this endpoint is a server.
    c.      IWantCustomInitialization: If you want to specify your own container or serializer, implement this interface on the class which implements IConfigureThisEndpoint. Implementors will be invoked before the endpoint starts upIt implements one method for initializing the serializer and the UnicastBus
            i.      Init(): Perform initialization logic.

    public void Init()<br />
    {  <br />
    NServiceBus.Configure.With()<br />
    // just to show we can mix and match containers      <br />
    .CastleWindsorBuilder()       <br />
    .XmlSerializer()<br />
      .UnicastBus()<br />
    // just to show we can mix and match containers<br />
    .DoNotAutoSubscribe();   <br />
    }

    For more info on Castle Windsor: Click here, and here

  2. Subscriber2Endpoint
    It implements two methods to manage subscriptions manually
                        i.  Run(): Method called at startup.
    Code:
    public void Run()   {<br />
                Bus.Subscribe&amp;lt;IEvent&amp;gt;();        }

    We’re subcribing to all IEvent messages from the MyMessages project.

                      ii.  Stop(): Method called on shutdown. (Contains

    Bus.Unsubscribe&amp;lt;IEvent&amp;gt;();

  3. EventMessageHandler
     This class handles for the subscribed IEvent event (step 2 above).
    Code:
    public void Handle(IEvent message) {<br />
           Console.WriteLine(&amp;quot;Subscriber 2 received IEvent with SeqNo &amp;quot;+ message.SequenceNo); }<br />
    

    I’m printing out the Sequence Number property that was previously populated by the Publisher.

  4. App.Config
    Similarly to the publisher, the subscriber contains configuration for its receive location. It contains the input queue from which it would receive its messsages (Subscriber2InputQueue).
    Key point: In addition to the MSMQ Transport Config above, the subscriber should send a message to the publisher indicating its desire to subscribe. The only way the subscriber can do this, if they know the publisher’s endpoint.


    Therefore, we add the UnicastBusConfig entry to tell the publisher, that the subscriber is interested in messages from MyMessages, that arrive on the publisher’s endpoint “
    MyPublisherInputQueue

 

==================================================

The Workings: Publish and Subscribe

==================================================

 As I started the MyPublisher project, I noticed the creation of three queues as expected (and previously described above). Similarly, as I started my subscriber, I received an error indicating that the Subscriber2InputQueue hasn’t been created. All these queues were automatically created by the NSB. 

 

Publisher: As I bring up the publisher (Debug → New Instance) and hit the enter key, a message gets sent to the NSB (nothing gets written to any queue – yet). Because there are no awaiting subscribers – the message does not get written to our queue. A message would only reach the queue from a publisher, if there are subscribers registered against it.

Subscriber: As I bring up the subscriber (Debug → New Instance), a subscription (queue message) is created on an intermediary queue called “mypublisher.endpointconfig_v1.0.0.0_subscription”. This was created by the NSB. Once I examine the contents of the queue it appears as follows:

This reads out as, “All endpoint subscriptions for mypublisher  (1) are listed as follows  – under (2). All messages of type (3) that are published by (1) would be deliverd to (2)

In plain terms, it simply means all messages of type MyMessage.IEvent, would be delivered to the Subscriber2InputQueue queue. An interesting point to note is that  – if we create this subscription manually, there would be no need to configure the UnicastBusConfig for the subscriber !! – food for thought :) . Adding onto it, what if you could maintain all these configurations inside a database (also possible) :)

Finally, as I hit the enter key – messages from the publisher are being delivered to the subscriber as expected.

Points of consideration:
The Server process publishes messages by looking through messages in the ‘subscriptions’ queue. The server attempts to match the message type it is currently sending with a subscriber that’s interested in the message.  If the server finds a subscriber, it publishes the message to the subscriber’s queue – otherwise, it ignores the message and continues to the next message. (Ref: Click here)

==================================================

Conclusion

==================================================

Conclusion: My first take on the NSB have found it to be light-weight communicator between .NET endpoints. By endpoints I  mean two .NET interfaces – be it applications, webservices, etc. It is not a replacement for a powerhouse like BizTalk in anyway – but could gel well together with it. NSB can appear as the communication layer between applications, where BizTalk would act as a subscriber communicating with LOB systems and complementing the NSB where it could not meet the requirements.

The NSB falls short on so many grounds, with things like:

→ Rules or content based (XPATH/Context,etc) based communication/routing between publishers and subscribers

→  Configuration of error queues and rules around them within the arrangement of our architecture (Standard way to handle exceptions and rules around the types of exceptions)

→ Replay messages (hitting everything in one exception queue might not be beneficial enough??)

→  Message transformations between subscribers and publishers. What if the message formats between a subscriber and publisher are not compatible?

→ Tracking performance and monitoring services and gathering statistics to track bottlenecks.

→… and many more..

The discussion on NSB vs BizTalk is a long story. The discussion is actually more around capabilities versus distributed communication. I would probably look to write a seperate post to discuss that. For now, all this post aimed at - was a crash course on the pub-sub pattern using the NSB :) Happy coding ..

 

Not sure if this scenario would ever be required, but for flexibility purposes here is a nice solution to pass in untyped messages into the BizTalk Rules Engine

Location: Click here

Often we’d like to know the cause of a dehydrated port. I’ve captured the scenario into the following picture (telling a thousand words)

Warning:
===================

EventId: 5740

The adapter “SQL” raised an error message. Details “HRESULT=”0x80040e10″ Description=”Procedure or function ‘bts_Insertxxx expects parameter ‘@xxxId’, which was not supplied.”".

===================

In this case, the dehydration occurs coz the SQL adapter is expecting an ID parameter that wasn’t returned by the stored procedure.

Happy coding :)

Following on from my previous post around the select itinerary component, here are a few screen shot to explain the artifacts:

1. Select the ItinerarySelectReceivePassThrough
This is regarless of the incoming adapter. I’ve used the SOAP adapter (i know its lame!!)..

2. Configure the pipeline components
This contains two components, where, the first is being used to make a decision on the itinerary. The second is used as a dispatcher into the message box (setting properties, config etc)

The resolver string can have mulitple variation.  In this case, the choices are using out-of-the-box one, i.e ITINERARY and BRI. The fact key being used is Resolver.Itinerary

Samples (STATIC resolvers): Uses fixed itinerary
Itinerary 1:
ITINERARY:\\name=CustomConfiguredDB;
===================================

Itinerary 2:
ITINERARY:\\name=AnotherCustom;
===================================

Samples (Resolve the itinerary by using the BRE):
Itinerary 3:
BRI:\\policy=MyCompany.RulesStore.SetA;version=1.0;useMsg=True;

version = Version number on the policy (default would be 1.0)
useMsg = Passes the incoming message to rules engine to make a decision

===================================

Happy coding :)


While deploying my applicaiton into a locked out enviornment (DR), I ran into an SSO problem (as initially thought).  We were using Microsoft’s Application Configuration utility to manage key value in the SSO.

As part of our deployment, we ran into the following problem – with a warning in the event viewer:
======

 SSO – Error creating the application

 Event Type: Warning
Event Source: ENTSSO
Event Category: Enterprise Single Sign-On
Event ID: 10536

Description:
SSO AUDIT
Function: GetConfigInfo (ConfigProperties)
Tracking ID: 764c4b7c-4164-434c-b023-0f8c1f6213bf

Error Code: 0xC0002A04, The application does not exist.

======
As I initially thought this to be an SSO problem, the reality was that our “locked-out” enviornment was pointing to the incorrect SSO database !!

In the Enterprise SSO Admin application, it was connecting to the production  SSO database, not to the actual one (DR). Everything else was point to the DR SSO database. This must be a carry over from when we have the BizTalk environment’s linked for transaction logging. When we reconfigiured SSO to point to it’s own database the SSO Admin tool kept pointing to Production.

Solution: Right click on the root node in the SSO Admin and select the correct SSO Server name.

Problem solved :)

An interesting question would be : How does the SSO Application Configuration tool determine which SSO database to connect to ?

For the life of me, I’m not sure I deleted databaseS related with SQL reporting services (on my dev box). And now, I would like to recreate them.

Solution:

  1. Navigate to Start → Programs → SQL Server 2008 R2 → Configuration Tools → Reporting Services Configuration Manager
  2. Click Databases → Change Databases

  3. Click Create new report server database, and follow the prompts.. All done :)
    This would create two new databases  – ReportServer and ReportServerTempDB

Happy reporting :)

Found this top post from Sandro where he details out step by step instructions installing BizTalk 2010 – with screen shots :)

Ref: Click here

===============
Installing Sharepoint on Windows 7
===============
However, as I tried to install Sharepoint on my machine, I get the following error (as expected):

To get away with this, I found another post article that helped me skip the dreaded box, and continue installing Sharepoint on my dev machine (windows 7) - woohoo :) . This required SQL Server express edition.

Ref: Click here

Happy installing :)

The Microsoft Home

Looking at the Microsoft home video – my initial reaction is :  clunky, over-explained, littered with instructions, and coupled with the repeated insistence that everything is “really cool”.

1. The Conductive charging plate- Text clutter and littered with intructions

2. TV Display:  Music albums collection – very cluttered

3. Digital wallpaper (Themes being applied on the whole room) .. that is cool

The digital wallpaper is surely the favourite on my list.

Itinerary Selector Component

Ok – A bit of theory here. So, you need a way to attach an itinerary to an incoming message using the ESB. The ESB Itinerary Selector component gives you this capability. It is placed in the receive pipeline and has three properties (ref: MSDN):

1)     IgnoreErrorKey: This property defines whether, if an error is returned by the resolver, the message should be processed without the itinerary (when set to True) or suspended

2)     ItineraryFactKey: This represents the key in the dictionary returned by the resolver that contains the actual XML of the Itinerary selected. Generally, Resolver.Itinerary, unless a custom resolver is used

3)     ResolverConnectionString: Figures out the itinerary that should be attached to the incoming message. This is a resolver connection string that contains name-value pairs that a resolver can use to select and/or look-up an itinerary. This in turn executes either the Static or Business Rules resolver, which provides an itinerary name (and version number). The ESB Itinerary Selector component then uses this name and version information to load the requested itinerary from the Itinerary Database

Sample ResolverConnectionString

  •  ITINERARY:\\name=myHardCodedItineraryName;
  • BRI:\\policy=MyPolicy;version=1.1;useMsg=False;

When useMsg is set to False, the BRI resolver submits the message’s context properties into the rules engine to determine which itinerary to use. If you want to use content from the body of the message to make these decisions, then you would need to set the useMsg property to True. This instructs the BRI resolver to submit the message body as well as the context properties into the invoked policy.

Using the BRI resolver

This requires the usage of the ESB.Itinerary vocabulary, which would set the name and version of the itinerary that we want to use. This vocabulary provides two core functions called Set Itinerary Name and Set Itinerary Version. You use these functions in the Actions section of a rule to define which itinerary you want to use

None the less – its fantastic :)

The beauty about BizTalk is around the adapters.  Here I’d like to explain how to configure the Websphere MQ to receive data.

Here is how my BizTalk receive location looks like:

The ones marked in yellow above are the properties I’ve changed. In my previous post about there were questions about confguring these values by navigating into the MQ server.

Open up your MQ Server and here is how you get them.

1)    Channel Name: Queue Manager –> Advanced –> Channels

Pick the default channel with the channel status as “running”.

2)  Connection Name:

It’s the combination of the machine name and the

  1. Queue
  2. Queue ManagerHappy configuring :)

Older Posts »

Follow

Get every new post delivered to your Inbox.