Friday, March 1, 2013

BizTalk Notification Receive Location channel Error

 Resolution: Use Different Hosts for SQL Notification receive location in SAME APPLICATION.

http://seroter.wordpress.com/2009/01/12/query-notification-capability-in-wcf-sql-adapter/
http://www.codeproject.com/Articles/144344/Query-Notification-using-SqlDependency-and-SqlCach
http://social.msdn.microsoft.com/Forums/en-ZA/biztalkgeneral/thread/6a0628c3-4e8b-4a39-960f-2de83914fd6c




System.InvalidOperationException: The ChannelDispatcher at 'mssql://Database1/repository/Profiles?InboundId=ERPAccountsID' with contract(s) '"IOneWayAsyncTxn"' is unable to open its IChannelListener. ---> System.InvalidOperationException: SqlDependency does not support calling Start() with different connection strings having the same server, user, and database in the same app domain.

Log Name:      Application
Source:        BizTalk Server
Date:          3/1/2013 2:03:05 PM
Event ID:      5644
Task Category: BizTalk Server
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      xxxxxx.xxx.local
Description:
The Messaging Engine failed to add a receive location "rloc_NotificationERPAccounts" with URL "mssql://Database1/repository/Profiles?InboundId=ERPAccountsID" to the adapter "WCF-Custom". Reason: "System.InvalidOperationException: The ChannelDispatcher at 'mssql://Database1/repository/Profiles?InboundId=ERPAccountsID' with contract(s) '"IOneWayAsyncTxn"' is unable to open its IChannelListener. ---> System.InvalidOperationException: SqlDependency does not support calling Start() with different connection strings having the same server, user, and database in the same app domain.
   at System.Data.SqlClient.SqlDependency.Start(String connectionString, String queue, Boolean useDefaults)
   at Microsoft.Adapters.Sql.SqlAdapterInboundHandler.StartListener(String[] actions, TimeSpan timeout)
   at Microsoft.ServiceModel.Channels.Common.Channels.AdapterChannelListener`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   --- End of inner exception stack trace ---
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint.Enable()
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint..ctor(BizTalkEndpointContext endpointContext, IBTTransportProxy transportProxy, ControlledTermination control)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiver`2.AddReceiveEndpoint(String url, IPropertyBag adapterConfig, IPropertyBag bizTalkConfig)".
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="BizTalk Server" />
    <EventID Qualifiers="49344">5644</EventID>
    <Level>2</Level>
    <Task>1</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2013-03-01T19:03:05.000000000Z" />
    <EventRecordID>1819748</EventRecordID>
    <Channel>Application</Channel>
    <Computer>xxxxxx.xxx.local</Computer>
    <Security />
  </System>
  <EventData>
    <Data>rloc_NotificationERPAccounts</Data>
    <Data>mssql://Database1/repository/Profiles?InboundId=ERPAccountsID</Data>
    <Data>WCF-Custom</Data>
    <Data>System.InvalidOperationException: The ChannelDispatcher at 'mssql://Database1/repository/Profiles?InboundId=ERPAccountsID' with contract(s) '"IOneWayAsyncTxn"' is unable to open its IChannelListener. ---&gt; System.InvalidOperationException: SqlDependency does not support calling Start() with different connection strings having the same server, user, and database in the same app domain.
   at System.Data.SqlClient.SqlDependency.Start(String connectionString, String queue, Boolean useDefaults)
   at Microsoft.Adapters.Sql.SqlAdapterInboundHandler.StartListener(String[] actions, TimeSpan timeout)
   at Microsoft.ServiceModel.Channels.Common.Channels.AdapterChannelListener`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   --- End of inner exception stack trace ---
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint.Enable()
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint..ctor(BizTalkEndpointContext endpointContext, IBTTransportProxy transportProxy, ControlledTermination control)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiver`2.AddReceiveEndpoint(String url, IPropertyBag adapterConfig, IPropertyBag bizTalkConfig)</Data>
  </EventData>
</Event>

BizTalkNotification Receive Location NotificationStatement from SQL query to Stored Procedure


Resolution:
http://www.codeproject.com/Articles/12335/Using-SqlDependency-for-data-change-events
Update: Thanks to DylanTheDeveloper for finding this resource describing valid queries: Special Considerations When Using Query Notifications. Also, using SET NOCOUNT ON in your stored procedure will invalidate it for usage in Query Notifications.
http://msdn.microsoft.com/en-us/library/aewzkxxh.aspx


The Messaging Engine failed to add a receive location "rloc_sqlNotificationOrgProfiles" with URL "mssql://Database1/Repository/Profiles?InboundId=OrgProfileNotification" to the adapter "WCF-Custom". Reason: "Microsoft.ServiceModel.Channels.Common.TargetSystemException: The notification callback returned an error. Info=Invalid. Source=Statement. Type=Subscribe.
   at Microsoft.Adapters.Sql.SqlAdapterInboundHandler.StartListener(String[] actions, TimeSpan timeout)
   at Microsoft.ServiceModel.Channels.Common.Channels.AdapterChannelListener`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint.Enable()
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint..ctor(BizTalkEndpointContext endpointContext, IBTTransportProxy transportProxy, ControlledTermination control)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiver`2.AddReceiveEndpoint(String url, IPropertyBag adapterConfig, IPropertyBag bizTalkConfig)".


Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="BizTalk Server" />
    <EventID Qualifiers="49344">5644</EventID>
    <Level>2</Level>
    <Task>1</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2013-02-28T19:14:14.000000000Z" />
    <EventRecordID>1817702</EventRecordID>
    <Channel>Application</Channel>
    <Computer>xxxxx.xxxx.local</Computer>
    <Security />
  </System>
  <EventData>
    <Data>rloc_sqlNotificationOrgProfiles</Data>
    <Data>mssql://Database1/Repository/Profiles?InboundId=OrgProfileNotification</Data>
    <Data>WCF-Custom</Data>
    <Data>Microsoft.ServiceModel.Channels.Common.TargetSystemException: The notification callback returned an error. Info=Invalid. Source=Statement. Type=Subscribe.
   at Microsoft.Adapters.Sql.SqlAdapterInboundHandler.StartListener(String[] actions, TimeSpan timeout)
   at Microsoft.ServiceModel.Channels.Common.Channels.AdapterChannelListener`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint.Enable()
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiveEndpoint..ctor(BizTalkEndpointContext endpointContext, IBTTransportProxy transportProxy, ControlledTermination control)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfReceiver`2.AddReceiveEndpoint(String url, IPropertyBag adapterConfig, IPropertyBag bizTalkConfig)</Data>
  </EventData>
</Event>