locked
send mail from Scope exception block using orchestration biztalk2010. RRS feed

  • Question

  • my orchestration using scope transaction type is  none . in exception block, i constracted one mesage and set following properties to send mail dynamically

    msgEnvelop.Attachments =msgSalesOrder;
    msgEnvelop(SMTP.From)=System.Configuration.ConfigurationSettings.AppSettings.Get("From");
    msgEnvelop(SMTP.SMTPHost)=System.Configuration.ConfigurationSettings.AppSettings.Get("SMTPHost");
    msgEnvelop(SMTP.SMTPAuthenticate)=0;
    msgEnvelop(SMTP.Subject)="Customer not found";
    //msgEnvelop(SMTP.EmailBodyText)=Ex.Message;
    msgEnvelop(SMTP.EmailBodyTextCharset)="utf-8";
    Port_OrderException(Microsoft.XLANGs.BaseTypes.Address)="mailto:krishna.chokkapu@valtech.co.in";

    msgsales order is input message.

    once build application showing eror is unconstracted message.

    Note: same thing working outside of exception block.

    please help me any one




    Monday, January 23, 2012 9:36 AM

Answers

  • Kishore,
    Do something like this:
    Put your orchestration logic in the Try/Catch scope.
    Then declare an Exception message on the orchestration level like this (of type XmlDocument):
     
    The 'publischException' shape should send your Exception message to the message box (direct bound)
    Then you can create an orchestration that subcribes to these error messages and does the error handling (e.g. sending notifications, writing to custom logs, ...)
    If you want to make it even better promote the 'ErrorType' property as shown below (and because you are in an orchestration also initiaze it in a correlation set to have it promoted, we will use it for routing later on)
    ExceptionMsg(ErrorReport.ErrorType) = "FailedMessage";
    
    If you do the last, then you handle both orchestration errors and messaging errors (if you enable 'routing for failed messages on your ports) in exactly the same way!
    It is a very basic exception handling pattern but is easy to implement...

    If this post answers your quenstion, please mark it as such. If this post is helpful, click 'Vote as helpful'.
    Thursday, January 26, 2012 6:43 PM
  • The msgEnvelop is counstructed. But what about msgSalesOrder? Check if the msgSalesOrder is counstructed outside the scope. It can be counstructed inside but before exception is fired. I'd suggest to move its construction outside of the scope. Or, at last, check the existence of it before using.
    Leonid Ganeline [BizTalk MVP] BizTalk and 0MQ (ZeroMQ)
    Friday, January 27, 2012 5:33 PM
    Moderator

All replies

  • 0

    my orchestration using scope transaction type is  none . in exception block, i constracted one mesage and set following properties to send mail dynamically

    msgEnvelop.Attachments =msgSalesOrder;
    msgEnvelop(SMTP.From)=System.Configuration.ConfigurationSettings.AppSettings.Get("From");
    msgEnvelop(SMTP.SMTPHost)=System.Configuration.ConfigurationSettings.AppSettings.Get("SMTPHost");
    msgEnvelop(SMTP.SMTPAuthenticate)=0;
    msgEnvelop(SMTP.Subject)="Customer not found";
    //msgEnvelop(SMTP.EmailBodyText)=Ex.Message;
    msgEnvelop(SMTP.EmailBodyTextCharset)="utf-8";
    Port_OrderException(Microsoft.XLANGs.BaseTypes.Address)="mailto:krishna.chokkapu@valtech.co.in";

    msgsales order is input message.

    once build application showing eror is unconstracted message.

    Note: same thing working outside of exception block.

    please help me any one
    Monday, January 23, 2012 9:54 AM
  • Where is the msgEnvelop contructed?

    It should be contructed either before entering the scope (since we don't know when the error will occur), or at the beginning of your exception block.

     

    Morten la Cour

    Monday, January 23, 2012 10:35 AM
  • msgEnvelop constructed in exception block of scope.
    Monday, January 23, 2012 10:37 AM
  • Kishore,

    This is probably due to the scope of the message you are using. Is it declare outside the scope? Try that...

    As a general note: did you think to create a 'error message' type and subscribing to that type in a another orchestration that performs the notification in case of an error? In that way the logic to send notifications in case of an exception is separate and can be reused across orchestrations.


    If this post answers your quenstion, please mark it as such. If this post is helpful, click 'Vote as helpful'.
    Monday, January 23, 2012 10:40 AM
  • I am using these message under Messages folder of orchestration view and using one orchestration only.
    Monday, January 23, 2012 10:44 AM
  • Ok, check these things:

    Is your code in a 'message assignment' shape that is on it's turn inside a 'construct message' shape?

    Make sure the message you are constructing is checked in the 'Message Constructed' property of the construct shape.


    If this post answers your quenstion, please mark it as such. If this post is helpful, click 'Vote as helpful'.
    Monday, January 23, 2012 10:51 AM
  • As a general note: did you think to create a 'error message' type and subscribing to that type in a another orchestration that performs the notification in case of an error? In that way the logic to send notifications in case of an exception is separate and can be reused across orchestrations.

    you said above. could u send any sample for that

    Tuesday, January 24, 2012 6:59 AM
  • I want to send mail when ever error occurs. so i was constructed message at exception block of scope in biztalk2010 orchestration. this scope transaction type is none. that time it showing unconstructed message error. any body having sample regarding this. that is very helpful for me

     




    Tuesday, January 24, 2012 9:29 AM
  • Kishore,
    Do something like this:
    Put your orchestration logic in the Try/Catch scope.
    Then declare an Exception message on the orchestration level like this (of type XmlDocument):
     
    The 'publischException' shape should send your Exception message to the message box (direct bound)
    Then you can create an orchestration that subcribes to these error messages and does the error handling (e.g. sending notifications, writing to custom logs, ...)
    If you want to make it even better promote the 'ErrorType' property as shown below (and because you are in an orchestration also initiaze it in a correlation set to have it promoted, we will use it for routing later on)
    ExceptionMsg(ErrorReport.ErrorType) = "FailedMessage";
    
    If you do the last, then you handle both orchestration errors and messaging errors (if you enable 'routing for failed messages on your ports) in exactly the same way!
    It is a very basic exception handling pattern but is easy to implement...

    If this post answers your quenstion, please mark it as such. If this post is helpful, click 'Vote as helpful'.
    Thursday, January 26, 2012 6:43 PM
  • The msgEnvelop is counstructed. But what about msgSalesOrder? Check if the msgSalesOrder is counstructed outside the scope. It can be counstructed inside but before exception is fired. I'd suggest to move its construction outside of the scope. Or, at last, check the existence of it before using.
    Leonid Ganeline [BizTalk MVP] BizTalk and 0MQ (ZeroMQ)
    Friday, January 27, 2012 5:33 PM
    Moderator