Quantcast
Channel: SQL Service Broker forum
Viewing all 461 articles
Browse latest View live

Service Broker and linked server stored procedures

$
0
0

Dear netters,

I have a stored procedure LoadData that is responsible for loading data from one table to another. Procedure calls for logging of errors/instrumentation regardless of whether the load is successful or not. To implement this type of logging, we defined a linked server (loopback onto the same SQL server 2012, on which the main procedure is running).

EXEC master.dbo.sp_addlinkedserver @server = N'loopback', @srvproduct=N' ', @provider=N'SQLNCLI', @datasrc=N'DEV', @catalog=N'test'

Here is the section of the LoadData stored proc that initiates an instrumentation call:

	exec loopback..dbo.LogProcedureStart	   @i_ProcedureName		= @v_ProcedureName	  ,@o_id				= @v_LogFk output	;

Procedure works fine. We run it many times in sequence, for different source tables, and wanted to experiment with performance when running it in parallel instead. We implemented a service broker to handle asynchronous procedure executions. Using an example from Asynchronous Procedure

We got the sample procedure executing fine, but when we went to switch it for the LoadData procedure, the proc simply does not get called (or something is off). The call shows as "CONVERSING" in the queue, and nothing is happening.

Pulling sections of code showed that when "loopback.." is used, LoadData stored procedure does not work. When "loopback.." is removed, all is fine.

Given that we do need the logging/instrumentation to be in place regardless of whether the stored procedure is executed asynchronously or not, what can be done to resolve this issue?

Thank you in advance!

--Alex


Log files full of service broker errors, but it works OK

$
0
0

We have a C# web application that is using SQL dependency to expire cached query data. Although everything is working okay we are seeing a lot of errors being generated particularly in our production environment.

The first error messages is this:

Service Broker needs to access the master key in the database 'SubscriberManager'. Error code:32. The master key has to exist and the service master key encryption is required.

It shows up in both the server event log and the SQL server log files. I believe the actual content of the messages something of a red herring as I have created a database master key.

I have also tried

  • Recreating both the service master key and the database master key.
  • Made sure the database owner is sa.
  • Made sure the user account has permissions to create services, queues, procedures and subscribe query notifications
  • Made sure the broker is enabled

I have seen other people with similar errors whilst researching the issue but the error code almost always seems to be 25 or 26 not 32. I have been unable to find anything that tells me what these error codes mean so I'm not sure of the significance.

Also I am seeing a lot of errors like this:

The query notification dialog on conversation handle '{2FA2445B-1667-E311-943C-02C798B618C6}.' closed due to the following error: '-8490Cannot find the remote service 'SqlQueryNotificationService-7303d251-1eb2-4f3a-9e08-d5d17c28b6cf' because it does not exist.'.

I understand that a certain number of these are normal due to the way that SqlDependency.Stop doesn't clean everything up in the database, but we are seeing thousands of these on one of our production servers.

What is frustrating as we have been using SQL notifications for several years now without issue so something must have changed in either our application or the server setups to cause this but at this point I have no idea what.

The applications are .net 4.0 MVC and WCF running on Windows 2012 servers calling SQL 2012 servers also running on Windows 2012.

service broke message classification

$
0
0

Hello,
 
I have a service broker application working on a set of servers. I can send message to and from several remote servers without a hitch, but attempting to create a testing environment on virtual servers ran into a problem with service broker.

This setup has four servers, where two of the four work as expected. The two that don't work simply queue up messages in sys.transmission_queue with no error information.

When I run a trace against either machine with all the service broker events checked I only get the following information:

The message could not be delivered because it could not be classified. Enable broker message classification trace to see the reason for the failure.
Could not forward the message because forwarding is disabled in this SQL Server instance.

with an occational Broker:Remote Message Acknowledgement several times with no detail. I'm not sure if this event is supposed to have no text data.

It's true I have not enabled test forwarding, but I don't typically see this on a good message transmission.

This is using NT authentication to send messages and I've verified the correct username is being used.
However this is error complains of message classification. The SB configuration is as it should be on the working environment.

What classification is this error referring?

thanks for looking over this post,
john

Error 28069: Unexpected session key when encrypting a dialog message

$
0
0
We are using sql server 2008 R2 enterprise version. Our sql service broker is having the issue with the error 28069 ("Unexpected session key when encrypting a dialog message"). I tried to find the solutions or fix suggestions online, but I could not get any helpful information. Any solutions or suggestions? Thanks.

A Fan of SSIS, SSRS and SSAS

DB mail not working SQL 2016

$
0
0
I have tried until I'm totally stumped!  I can't seemed to get the DBMail to work on my SQL2016 server.  When I look @ sysmail_log I see several emails but all of them are sent_status:0.  I think I have everything setup properly, but something's not working  apparently.  I also see NO entries in the Database Mail log.

This message was dropped because it could not be dispatched on time

$
0
0

Recently. my service broker audit system is displaying the following messages in Profiler "This message was dropped because it could not be dispatched on time.'. My understanding is that this particular issue was fixed in SP2 CU4. The server in question is SQL Server 2005 at version number 9.0.4226. I believe this is SP3 CU4. Anyone else having this issue and how to fix it?


PM

The database generates the messages but it doesn't send them

$
0
0

Hi, I'm actually working with a DB from where I work and I need to get notified in my project when someone makes a change into one table of this DB. I had to enable the service broker because it was disabled and now it generates all the messages, but in my c# project doesn't happen anything.

The problem is in the db because I tried to fire the same table in a different db it works fine. I Have to enable something else besides the service broker?

I think that this DB was build in sql server 2008R2 if this helps to solve the problem.

An entity of type service cannot be owned by a role, a group, or by principals mapped to certificates or asymmetric keys.

$
0
0

I'm using SQL Server 2008 R2 and a WCF service in Visual Studio 2010. I am trying to set up a SQL Dependency to detect changes in the database, and I have set up a queue and service. I keep getting the above error when running the service, though. 

I already have the service set to AUTHORIZATION [dbo], and I have tried logging in as a regular user (I usually log in as dbo) but so far nothing has worked. 

I have looked around a lot and have not been able to find anything helpful. Any help would be much appreciated!


Service Broker where Source DB is a different SQL Version than the Target DB

$
0
0
We are moving to SQL 2016 servers.  Are there any known issues, other than not using features specific to the higher version of SQL Server whereby I should be concerned about configuring a "Source" Service Broker on SQL 2016 communicating with a "Target" Broker on SQL 2008 R2 ?

The statement 'SEND' is not supported with natively compiled modules. 

$
0
0

Hi all

We encountered the following errors while interacting with SSB from within native DML trigger:

Msg 10794, Level 16, State 98, Procedure usp_My_Test, Line 20
The statement 'BEGIN DIALOG' is not supported with natively compiled modules.
Msg 10794, Level 16, State 98, Procedure usp_My_Test, Line 20
The statement 'SEND' is not supported with natively compiled modules. 


Any help would be greatly appreciated!


Service broker generating orphaned sqlnotification procedures ,queues,services

$
0
0
I am new to service broker,
I have implemented the process ,It is working fine, performing the intended  task as expected 
but it is generating unwanted SqlQueryNotifications Procedures,queues,services.
I have gone through the below link http://rusanu.com/2006/04/06/fire-and-forget-good-for-the-military-but-not-for-service-broker-conversations/
verified the fire and forget issue in my requestactivation and targetactivation procedures,I have properly ended the convesations 
in source and target ,Still i can see these below notifications ,
So Can anyone help me to understand when service broker generates unwanted notifications.

ex:Procedure:
CREATE PROCEDURE [dbo].[SqlQueryNotificationStoredProcedure-10d6e9c9-4250-48ec-bf4c-2e42883c5105] 
AS BEGIN BEGIN TRANSACTION; RECEIVE TOP(0) conversation_handle FROM [SqlQueryNotificationService-10d6e9c9-4250-48ec-bf4c-2e42883c5105];
 IF (SELECT COUNT(*) FROM [SqlQueryNotificationService-10d6e9c9-4250-48ec-bf4c-2e42883c5105] 
WHERE message_type_name = 'http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer') > 0 
BEGIN if ((SELECT COUNT(*) FROM sys.services WHERE name = 'SqlQueryNotificationService-10d6e9c9-4250-48ec-bf4c-2e42883c5105') > 0)  
 DROP SERVICE [SqlQueryNotificationService-10d6e9c9-4250-48ec-bf4c-2e42883c5105]; if (OBJECT_ID('SqlQueryNotificationService-10d6e9c9-4250-48ec-bf4c-2e42883c5105', 'SQ') IS NOT NULL) 
  DROP QUEUE [SqlQueryNotificationService-10d6e9c9-4250-48ec-bf4c-2e42883c5105]; DROP PROCEDURE [SqlQueryNotificationStoredProcedure-10d6e9c9-4250-48ec-bf4c-2e42883c5105]; 
END COMMIT TRANSACTION; END

 QUEUE:

ALTER QUEUE [dbo].[SqlQueryNotificationService-10d6e9c9-4250-48ec-bf4c-2e42883c5105] WITH STATUS = ON ,
 RETENTION = OFF , 
ACTIVATION (  STATUS = ON , PROCEDURE_NAME = [dbo].[SqlQueryNotificationStoredProcedure-10d6e9c9-4250-48ec-bf4c-2e42883c5105] , MAX_QUEUE_READERS = 1 , EXECUTE AS OWNER  ), POISON_MESSAGE_HANDLING (STATUS = ON) 
GO


Service:
ALTER SERVICE [SqlQueryNotificationService-10d6e9c9-4250-48ec-bf4c-2e42883c5105]  
ON QUEUE [dbo].[SqlQueryNotificationService-10d6e9c9-4250-48ec-bf4c-2e42883c5105] 


EDIT:

I am able to drop these  unwanted procedure,services,queues not facing any permission issue. 

Thanks in advance

Service Broker messages expiration

$
0
0

Hi,

We had plenty of messages in "sys.transmission_queue" on Source server while service broker had communication issues with destination server for couple months. Queue was cleaned up once communication was restored. But we miss some data on destination server.

If conversation between source and destination servers is not successful, will we loose messages on source server after some time?

Is there any expiration period for messages on source server?

Thanks

Performance waits

$
0
0

Can anyone tell me if this is an issue. See screenshot.


Alan


Service Broker connecting to random server.

$
0
0

I have one route in sys.routes, it is a mirrored route SERVER A and SERVER B. 
problem i have is, when running profiler I see BROKER:CONNECTION Connection attempt failed with error: '10061(No connection could be made because the target machine actively refused it.)'. and in object_name, its trying to connect to SERVER C

SERVER C WAS part of an older route that has been deleted.

Why is service broker still trying to connect to a server which is not part of the route?

Database mail queue stays INACTIVE

$
0
0

Hello

I tried for hours to get my notifications working, without success, on SQL Server 2008R2 Web Edition 64b

I send mail with the test :

USE msdb

GO

EXEC sp_send_dbmail @profile_name='ARRIERE',@recipients='mai@mail.tld',

@subject='Bonjour ',@body='Congrates Database Mail Received By you Successfully.'


But this mail seems to be never sent.

With:

EXEC msdb.dbo.sysmail_help_queue_sp @queue_type = 'mail';

The queue state is always INACTIVE, and length is growing everytime I send a email.

I tried to restart the mail system some times :


EXEC msdb.dbo.sysmail_stop_sp;
EXEC msdb.dbo.sysmail_start_sp;

The states goes RECEIVE OCURRING, but after some seconds and without intervention, it goes back to INACTIVE.

I tried to rester SQL Agent, SQL Server, the server himself, but no luck.

The broker is activated (SELECT is_broker_enabled FROM sys.databases WHERE name = 'msdb' ;)

I disabled every firewall, antivirus and others (by the way, I can do "telnet smtp.domain.tld 25" and send a mail with telnet.

With

SELECT * FROM msdb.dbo.sysmail_allitems;

I see all my mails with state "unsent".

Nothing logged in Event Viewer, SQL Events, and in sysmail_event_log I only get "Activation successful".

I configured the local IIS SMTP as a relay as said here : http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/f9744284-a9b6-4bfb-81b9-c4833f282ad0 

I cleaned the mails with:

DECLARE @GETDATE datetime
SET @GETDATE = GETDATE()
EXECUTE msdb.dbo.sysmail_delete_mailitems_sp @sent_before = @GETDATE;
GO

=> Nothing more.

Can I do something more?

Thans for your help.

Regards



SQL DB Mail - Error While sending email. in sql 2012

$
0
0

HI,

I am trying to send db mail from one of the server and end up with error. the same is shown below . 

Error Message :

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2016-09-15T13:45:59). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated).
)

but , with the same mail server name and email address configured in the DB mail from other servers in same network / domain is working fine, facing issues only with this one server. 

Checked even the status of the DB mail with below Query , which shows as STARTED. 

EXEC msdb.dbo.sysmail_help_status_sp;

When i execute the sysmail_help_queue_sp, i see inactive in the column "state", is that the problem ? but i am not

seeing that as problem, If yes, please help me to mark it in right status mode.

else please do le tme know the right way to clear the same


hemadri


RECEIVE vs RECEIVE TOP(1)

$
0
0

 

In working through some examples, sometimes I will see this pattern for receiving messages: What is the purpose of the "nested" WAITFOR (RECEIVE? What is this actually doing? Is it receiving the same message in both RECEIVE?

 

WAITFOR(

      RECEIVE @dh = [conversation_handle],

            @message_type = [message_type_name],

            @message_body =CAST([message_body] ASNVARCHAR(4000))

      FROM [Queue]), TIMEOUT 1000;

WHILE @dh ISNOTNULL

BEGIN

      IF @message_type = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'

      BEGIN

            RAISERROR(N'Received error %s from service [Target]', 10, 1, @message_body)WITHLOG;

      END

      ENDCONVERSATION @dh;

      COMMIT;

      SELECT @dh =NULL;

      BEGINTRANSACTION;

      WAITFOR(

            RECEIVE @dh = [conversation_handle],

                  @message_type = [message_type_name],

                  @message_body =CAST([message_body] ASNVARCHAR(4000))

            FROM [Queue]), TIMEOUT 1000;

END

COMMIT;

 

Other times I will see this pattern for receiving messages: Why do a RECEIVE TOP(1) instead of just a RECEIVE?

 

WAITFOR

(RECEIVETOP(1)

@conversationHandle =conversation_handle,

@messageTypeName = message_type_name,

@messageBody = message_body

FROM [Queue]),TIMEOUT 1000;

 

And other times I will see this pattern for receiving messages: What is the purpose of RECEIVING into an in-memory table when you can just process the message directly?

 

WAITFOR

(RECEIVE

queuing_order

,

conversation_handle,

message_type_name

,

message_body

FROM [Queue]

INTO @tableMessages),TIMEOUT 1000;

IF(@@ROWCOUNT= 0)

BEGIN

COMMIT;

BREAK;

END

 

What is the difference between the three approaches from an architectural and performance perspective? I need to process messages as fast as possible and I'm not sure why or when each should be used. Also, does the timeout have any impact on how FAST messages will be processed, or is it exactly what it says - a timeout - if a message is not found within the period then the procedure will break?

Random mail lost with Database mail and non-Microsoft SMTP servers

$
0
0

The following facts was tested and reproduced on 3 completely different environments and with SQL 2005, 2008, 2008R2, 2012 and 2016.


  • When DB mail send email to Postfix(2.10.1 and 3.1.2) SMTP servers report several  errors  “lost connection after CONNECT” and a percentage of them will result in email lost.
  • When DB mail send email to a non-Microsoft email relay software(http://emailrelay.sourceforge.net/) installed on a Windows server will report events ID 1002 “winsock select error: 10053“.
  • A packet capture shows a specific behavior from DBmail that didn’t exist with other systems . DBmail initiate one or multiple  TCP connections depending of the number of mail to send then in a matter of micro or millisecond forsome of those TCP connections, it send a FIN/ACK  then a RST/ACK, which is interpreted as a lost connection from Postfix and the majority of SMTP daemons.  Those TCP connections  that didn’t have a FIN/ACK complete normally. 
  • When DBMail is talking to a Microsoft SMTP, it begins the same way including the FIN/ACK for some of the TCP connections but the SMTP conversation will continue under a different TCP source port and are followed by the sequence number. So Microsoft SMTP do not drop the whole SMTP connection when the initial TCP connection is dropped.
  • So for some SMTP conversation, the source port changes during the conversation usually just after the 220 Welcome message which cause a lost connection for the majority of the SMTP services.
  • SQL Database mail didn’t see any errors even when mails are lost.

I was always on the assumption that the SMTP protocol is a single TCP connection by design as described in RFC 821.

Right now the only work around we found was to configured DBmail to send emails to an IIS SMTP service which relay to our main Postfix server. We would like to get rid of the middle man if possible.

Can the EXE behind DBmail (Databasemail.exe) be replaced by something else more standard in term of SMTP conversation ?


Any help or suggestion are welcome?

Send Recive Data

$
0
0

I've been reviewing things I've found on the web for SQL sending and receiving data over SQL. I'm curious how that works. So does SQL broadcast the back to everyone or just a specific machine? Not sure how do the receivers know what to listen for on the application side? For example:

I built a chat room and I use SQL as my point of storage for the messages. How will SQL know to send message A to computer B and send Message B to Computer A?

SQL 2014 Service Broker Issue

$
0
0

We are running a sql 2014 on windows 2012 r2 on aws.   A remote c# service application connects to a database sitting on this server and performs messaging using service broker.  After a long period of inactivity, the connections timeout.   Subsequently, after clearing the queue, the service connects successfully to the sql server.  Could it be that connection timeout breaks the queue?  In any case, any help is appreciated.

Thanks in advance

Viewing all 461 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>