Sajay

Life, The Universe and Everything Distributed.

July, 2010

Posts
  • Sajay

    Fixed Ideologies and Message exchange patterns

    • 0 Comments

    I had never thought that I would actually write about a topic like this but sometimes you want to organize your thoughts and have an opinion on things. Being in the performance team for WCF has got me used to a plethora of message exchange patters which we lovingly refer to as MEP. There exists a broad spectrum of coding and implementation styles which we see day in an day out. There are those that are extreme and elaborate and overwhelmingly flexible and also those that are so convoluted and rigid that its almost close to assembly.

    Its good to know know what message exchange patterns would be most suited for his or her needs. I think its an overkill to adopt a strategy where your application will force itself to use only a single message exchange patter. For example an ideology like “We will do only rest style request reply throughout our system” The number of layers we need to add in order to align ourselves with a philosophy like this would probably outweigh the benefits that it provides, specifically in scenarios that aren’t suited for patterns like these.

    There is a really nice article on MSDN listing out 6 message exchange patters http://msdn.microsoft.com/en-us/library/aa751829.aspx To quickly reiterate they are Datagram/Request-Reply/Duplex and 3 of these with sessions on top.  You can think of a session like a logical abstraction to say that the message is a part of a conversation. This has nothing to do with asp.net sessions and it is a way for WCF to correlate messages.

    My experience it is generally more helpful to classify your problem and see what pattern really helps your issue and then slap on the contracts and protocols rather than fixing on the protocol/MEP and then forming a solution around that. I choose not to be an advocate of any particular style but I am against protocol fanatics who are inflexible and who believe that there are a fixed set of choices for certain types of scenario.

    Systems are organic and so its hard to freeze implementations. The fact is patterns are similar too. Today you might be ok with TCP but there is nothing stopping you from switching to queues. As the system grows and there would be solutions you put in place to facilitate this kind of a change. Layers get added and MEPs also change.

    If you have any questions on how to make a choice I would gladly try to help out.

  • Sajay

    How to change the IdleTimeout/LeaseTimeout on NetTcpBinding?

    • 0 Comments

    To modify properties that are not exposed on the standard binding we can create a CustomBinding from the provided standard binding. We can then find the element required on the particular CustomBinding and tweak it. Another option would be to just hand craft the full standard binding if you know exactly how to stack up the elements. Here is an example to how to tweek the IdleTimeout.

    private static CustomBinding GetIdleBinding(int mins)
    {
        NetTcpBinding tcpBinding = new NetTcpBinding();
        CustomBinding customBinding = new CustomBinding(tcpBinding);
        TcpTransportBindingElement transport = customBinding.Elements.Find();
        transport.ConnectionPoolSettings.IdleTimeout = TimeSpan.FromMinutes(mins);
        return customBinding;
    }
    

  • Sajay

    Errorlevel and Findstr

    • 0 Comments

    ErrorLevel is not %ERRORLEVEL% . This is probably the first one you should read.

    Next is the usage of the ERRORLEVEL statement. http://support.microsoft.com/kb/69576

     

    The following table shows the effect of statement when writing your batch scriipt.

    Statement Algebraic Equivalent.
    IF ERRORLEVEL 5 ... IF E = 5 OR E > 5 THEN ...
    IF NOT ERRORLEVEL 6 IF E < 6 THEN ...

    Here is a sample using findstr and error level. Findstr returns 0 if it successfully finds any occurrence.

    findstr -sip Failed log.txt > NULL
    IF NOT ERRORLEVEL 1 ( 
        echo Found.
    ) else (
        echo Not Found.
    )
Page 1 of 1 (3 items)