none
AdapterException Crashes BizTalk Host RRS feed

  • Question

  • Hi,

     

    I'm currently building a JD Edwards Outbound LOB adapter and I have followed the examples and guides and when I encounter an unexpected error I throw the AdapterException indicating the issue.  However, when I do this it crashes the BizTalk host with the following error:

     

    Faulting application btsntsvc.exe, version 3.6.1404.0, stamp 4674b0a4, faulting module kernel32.dll, version 5.1.2600.3119, stamp 46239bd5, debug? 0, fault address 0x00012a5b.

     

     

    Can someone provide guidance on what I need to do when an error occurs?  I don't want to crash the BizTalk host everytime an error occurs, do I just log it to the event log.  The way other 'BizTalk' COM+ adapters work is they raise MOM type alerts and never crash the host, is this how the new LOB Adapters will work?

     

    John

    Sunday, December 30, 2007 10:57 PM

Answers

  • Hmm .. I dont think that is possible. I think that all messages logged by WCF-Custom will end up having the same source and other properties ..
    Friday, January 4, 2008 11:13 AM

All replies

  • Are you trying to build  JD Edwards Outbound LOB adapter using WCF LOB Adapter SDK?

    Thursday, January 3, 2008 11:46 AM
  • Hi Saritha,

     

    Yes I'm using the WCF LOB Adapter SDK, this seems to work fine but with limited documentation 'specific' to BizTalk alot of my development is hit and miss.  I'm assuming that exceptions should be handled in a classic Microsoft (MOF) way by logging the exception to the event log and the tracer and do not under any circumstances throw the AdapterException because this crashes the host.

     

    Is this correct or is there a 'microsoft' way of doing this?

     

    Thanks

     

    John

    Thursday, January 3, 2008 2:58 PM
  • Hi!
    You should be fine throwing any exception. I assume you are using the WCF-Custom Adapter to plug-in your WCF LOB ASDK based Adapter with BizTalk, right? From which function are you throwing the exception which causes BizTalk to crash? Does it crash no matter where you throw your exception from? For example, IOutboundHandler::Execute()?
    Mustansir
    Friday, January 4, 2008 4:53 AM
  • Hi Mustansir,

     

    Yes I'm using the I'm throwing the "WCF-Custom Adapter to plug-in your WCF LOB ASDK based Adapter with BizTalk" adapter exception that causes the biztalk host to crash is in the inbound handler in an event handler.  I'm using a similar pattern to the Echo file receive sample.  Whereby I'm using a file monitor to poll for new files in a location.  In the event handler I'm throwing the adapterException that is causes the host to crash here is a snippet of code, if you change Echo sample you will see the behaviour:

     

    private void FileMonitor_Created(object sender, FileSystemEventArgs e)

    {

    //System.Diagnostics.Debugger.Launch();

    //System.Diagnostics.Debug.Write("File Created Event");

    lock (inboundQueueSynchronizationLock)

    {

    if (e.ChangeType == WatcherChangeTypes.Created)

    {

       throw new AdapterException("Example exception");

    }

    #endregion

    }

     

    Thanks

     

    John

    Friday, January 4, 2008 7:47 AM
  • Ok, the problem is that the FileMonitor_Created() event occurs in a separate thread. On the call stack for that thread, if you throw an exception, there is no code which can catch it. The .NET behavior is that any unhandled exception will crash the process.

    What you should do is, if you want to throw an exception from FileMonitor_Created(), dont throw it, but instead store it in some local variable. Then, in the TryReceive() function, throw the exception from there. The WCF ServiceHost will catch that exception, and let the WCF-Custom Adapter know, and then that error message will appear in the Event Log.
    Friday, January 4, 2008 8:22 AM
  •  

    Hi Mustansir,

     

    Great answer I will try this now but from your explanation it will fix the issue. 

     

    thanks for your help

     

    John

    Friday, January 4, 2008 9:21 AM
  • Hi Mustansir,

     

    Using your method it doesn't crash the BizTalk host.  I have a question about throwing the adapterexception.  This seems to be pointless because the error isn't logged?  Can you advise on the best practices around throwing these exceptions and getting them logged like out of the box adapters.  For example with the BizTalk file adapter is the file is locked an error is logged to the event log explaining the error.

     

    John

     

    Friday, January 4, 2008 9:47 AM
  • Are you throwing the exception from TryReceive()? I just verified that if I do so, the message ends up in the Event Log ..
    Friday, January 4, 2008 9:56 AM
  • Hi Mustansir,

     

    Yes your correct it does throw this and logs the exception to the event log as below.  Is there any way to control the event id, event source and text that is logged to the event source?  Basically I would like to package up the errors into a MOM pack so I want individual errors to be recognised.

     

    thanks

     

    John

     

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

     

    Event Type: Warning
    Event Source: BizTalk Server 2006
    Event Category: BizTalk Server 2006
    Event ID: 5740
    Date:  1/4/2008
    Time:  10:40:50 AM
    User:  N/A
    Computer: WINXP2006
    Description:
    The adapter "WCF-Custom" raised an error message. Details "Microsoft.ServiceModel.Channels.Common.AdapterException: Test exception
       at Microsoft.ServiceModel.Channels.Common.Design.AdapterAsyncResult.End()
       at Microsoft.ServiceModel.Channels.Common.Channels.AdapterReplyChannel.EndTryReceiveRequest(IAsyncResult result, RequestContext& requestContext)
       at System.ServiceModel.Dispatcher.ReplyChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
       at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)".

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

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

     

     

    Friday, January 4, 2008 10:45 AM
  • Hmm .. I dont think that is possible. I think that all messages logged by WCF-Custom will end up having the same source and other properties ..
    Friday, January 4, 2008 11:13 AM