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

No messages received on Queue after Failover in SQL Always On

$
0
0

We have an Application, which uses Service Broker to receive notifications from the SQL Server.

The application works fine when we don’t have SQL Always On enabled, and when we are interacting with a single DB.

 

However when we have SQL Always On, After we do a failover from on SQL Node1 to another SQL Node2.

We stop getting any notifications from SQL Node2.

(Note: Before we do any failover, we are getting notifications even if SQL Always On is being used.)

 

To get the notifications again we have to again send the service broker contract messages, the wait and receive command for the specific service and queue etc., its equivalent to restarting our service.

 

I looked over the internet, and found this MSDN Article on Service Broker on SQL Always On.

http://msdn.microsoft.com/en-IN/library/hh710058.aspx

I carried out the steps mentioned in this section of above article,

Requirements for a Service in an Availability Group to Receive Remote Messages

For the 4th step mentioned above, Ensure that msdb contains either an AutoCreatedLocal route or a route to the specific service.

The AutoCreatedLocal was present by default, so I did not do anything for 4th step.

 

But still I am not getting any notifications after failover.

 

Can you please suggest on what step(s) I am missing or have not executed correctly, or any additional items which needs to be taken care of.


-Zakir, Let us know if the answer/post helps you :)


Non/late closing conversations without fire and forget

$
0
0

Hello.

I have two Service Broker instances running on different Servers. Both are constructed the same way but only one of them has trouble closing conversations. This problem started to occur on the 16th of October months after the start of the Service Broker.

Both queues are in the same database. Most of the time the conversation close normal but on some days the conversations close late or never. Here is my monitoring of the conversing conversations per day:

10/16: 1

10/24: 1

11/04: 20119

11/05: 24207

11/06: 29848

11/12: 1

11/19: 1

11/27: 1

On the 28th of November in the morning I saw 10748 open conversation for the 27th but the number was decreasing down to one open conversation. As you can see on days where the problem occurs at least one open conversation remains.

I do not understand why this happens. The only difference between the two Service Broker instances is the reliability of the network over which a webservice is called on the receiving end of the Service Broker. Can this unreliability cause conversations to remain open or close late?

Here an example for a conversation which remains open:

conversation_handle	conversation_id	is_initiator	service_contract_id	conversation_group_id	service_id	lifetime	state	state_desc	far_service	far_broker_instance	principal_id	far_principal_id	outbound_session_key_identifier	inbound_session_key_identifier	security_timestamp	dialog_timer	send_sequence	last_send_tran_id	end_dialog_sequence	receive_sequence	receive_sequence_frag	system_sequence	first_out_of_order_sequence	last_out_of_order_sequence	last_out_of_order_frag	is_system	priority
EB108673-573A-E411-A731-2C44FD81E734	09AB4E1D-3EEF-4CAA-8358-85B50CCEE472	1	65536	EC108673-573A-E411-A731-2C44FD81E734	65536	2082-09-30 11:47:31.377	CO	CONVERSING	//SAPReceiverService	A3869A41-8F7C-4C13-B378-C5FA0DA7492E	1	-1	00000000-0000-0000-0000-000000000000	00000000-0000-0000-0000-000000000000	1900-01-01 00:00:00.000	1900-01-01 00:00:00.000	1	0x29CB4D000000	-1	0	0	0	-1	0	0	0	5
4E7F19AB-AE65-E411-A731-2C44FD81E734	01EA85EB-A3A8-41CE-BDC0-85B5261553D3	0	65536	4D7F19AB-AE65-E411-A731-2C44FD81E734	65538	2082-11-24 15:27:35.827	CO	CONVERSING	//SAPSenderService	A3869A41-8F7C-4C13-B378-C5FA0DA7492E	1	1	00000000-0000-0000-0000-000000000000	00000000-0000-0000-0000-000000000000	2014-11-06 12:46:36.540	1900-01-01 00:00:00.000	0	0x000000000000	-1	1	0	0	-1	0	0	0	5


Thanks in advance

Susanne

Get the Count of query Notifications on Sql broker

$
0
0

Hi,

We have SQL broker running, would like to check the number of notifications every 1 hour send by SQL broker, any idea on SQL query to find the number of notifications in queue by SQL Broker.

- Nav 


Naveen| Press Yes if the post is useful.

SQL Server Service Broker and Tibco

$
0
0

Hi
Has anybody any experience of using SQL Service Broker (SQL 2014) to receive messages from aTibco Rendezvous?

Regards

Listening to change in a row of a table a and update a table in a diferent Database

$
0
0

i want to update a table using values from a different database table. how to i do it in SQl 2012

Any alternative to messaging other than SQL Service Broker.

$
0
0
Any alternative to messaging other than SQL Service Broker?

Naveen| Press Yes if the post is useful.

sys.dm_broker_queue_monitors - what means status DROPPED?

$
0
0

Hello! I'm trying to understand service broker errors that i have in log:

An error occurred in dialog transmission: Error: 9655, State: 3.

Error: 9736, Severity: 16, State: 0.

Can't find any information in the BOL and internet at ALL

Now, i'm trying to understand sys.dm_broker_queue_monitors that have many rows with DROPPED status, but there are no description of this status in the BOL. Can someone help me to find relative information?

Thanks!

P.S. Service Broker is the worst thing due a badest documentation!


Konstantin Knyazev

Service Broker Filling Tempdb

$
0
0

I have SB setup as a fire and forget setup. I have identified that SB is the cause of my TEMPDB growing out of control. It allocates many pages but never deallocates any. The initiator ends the conversation straight away, while the target ends with cleanup, I have no conversations hanging around in the sys.conversations_endpoints table but I never see the conversation move to the CD status they always remain in the DI DISCONNECTED_INBOUND status.

Question 1 is this the cause of TEMPDB filling up.

Question 2 should the allocated pages in TEMPDB clear out when with cleanup is executed.

I know both are bad but that is the way it is setup.


Reg Service broker Issue

$
0
0

HI,

I have a Requirement that If a table gets changed that has to be initimated to Application ,So I used Sqldependency concept in my DB server  by enabling Service broker .

That seems to be working ,But I see some thing weird like some open transactions is always running in my DB.

I did use dbcc opentran() to check the open transaction .The spid's are like 31s or 16s.That 's'word is appeneded to every spid.

--Dbcc opentran()  output

---------------------

Oldest active transaction:
    SPID (server process ID): 16s
    UID (user ID) : -1
    Name          : user_transaction
    LSN           : (4024663:5472:281)
    Start time    : Dec 10 2014 11:22:49:860AM
    SID           : 0x01

if i try to check the profiler to find out what is running .its shows as

(@p2 int)BEGIN CONVERSATION TIMER ('f6b1ab5e-0a6b-e411-a336-24b6fdd23090') TIMEOUT = 120; 
WAITFOR(RECEIVE TOP (1) message_type_name, conversation_handle, cast(message_body AS XML) as message_body 
from [SqlQueryNotificationService-061e2080-cd43-4dad-990b-50dacd3cb2d5]), TIMEOUT @p2;

Also the windows log error logs in the evetvwr thorws an error everysecond 

The activated proc '[dbo].[SqlQueryNotificationStoredProcedure-9a9cb9f7-138a-4097-92ad-bf294f808773]' running on queue 'LycaMoney_FR_Devteam.dbo.SqlQueryNotificationService-9a9cb9f7-138a-4097-92ad-bf294f808773' output the following:  'The user does not have permission to perform this action.'

These kind of activities making my DB slow and tables inaccessible..

PLease advice me to get rid of these.

SQL server service broker

$
0
0

Hi All,

I have requirement to implement SQL server service broker in SQL server 2008, please guide me for that, how and why we use for that, then have any other option to achieve. 

Please give any good stuff to learn service broker.

Thanks,

Jai.

Message between databases on the same server is not working.... The message is stuck in the initiator's transmission_queue...

$
0
0

I get the following error in the transmission_queue for the message:

The target service name could not be found. Ensure that the service name is specified correctly and/or the routing information has been supplied.

The tutorial works fine: Completing a Conversation Between Databases

The only difference that I can see is that the initiator shares a queue that is related to a service that sends/receives messages with a database on a remote server instance. Do I need to create a separate queue for this?

Thanks.


Scott Mitchell

How to use Service Broker, where and when we gonna use it.

$
0
0

Hi all,


I have task to implement SQL service broker for some insert statement, am bit confused where i start and how to implement like it may in Database or Server side(ASP.Net- c#), some where.

What the main advantage of using SQL Service broker?

Thanks,

Jai.

Snapshot isolation in combination with service broker

$
0
0

Hi all,

I'm currently using the service broker in combination with snapshot isolation on the database.

The notification request is executed under read commited isolation. The code looks like this:

SqlDependency dependency = new SqlDependency(command, null, 0);
dependency.OnChange += eventHandler;

using (SqlConnection conn = new SqlConnection(connectionString))
{
   using (SqlTransaction tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
   {
      command.Transaction = tran;
      command.ExecuteNonQuery();
      tran.Commit();
   }
}

The request is successfully created and works fine at the first glance.

Now here is my problem:

I created a notification request that should monitor two objects. The query (executed under read committed) looks something like this:

SELECT Id, DataVersion FROM dbo.MyObjects WHERE Id = 1 OR Id = 2 

Afterwards I delete both objects in separate nested transactions. Both of them are running under snapshot isolation. It looks something like this:

using (SqlConnection conn1 = new SqlConnection(connectionString))
{
	conn1.Open();

	using (SqlTransaction tran1 = connection1.BeginTransaction(IsolationLevel.Snapshot))
	{
		using (SqlConnection conn2 = new SqlConnection(connectionString))
		{
			conn2.Open();

			using (SqlTransaction tran2 = conn2.BeginTransaction(IsolationLevel.Snapshot))
			{
				SqlCommand command2 = conn2.CreateCommand();
				command2.Transaction = tran2;
				command2.CommandText = "DELETE FROM MyObjects WHERE Id = 2";
				command2.ExecuteNonQuery();
				tran2.Commit();
			}
		}

		SqlCommand command1 = conn1.CreateCommand();
		command1.CommandText = "DELETE FROM MyObjects WHERE Id = 1";
		command1.Transaction = tran1;
		command1.ExecuteNonQuery();
		tran1.Commit(); //-> Conflict exception
	}
}

A conflict exception is raised during the commit of last transaction. The conflict seems to occur in the table "sys.query_notifcations_xxxxxxxxx". This is the exact message:

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: Snapshot isolation transaction aborted due to update conflict. You cannot use snapshot isolation to access table 'sys.query_notification_45295271' directly or indirectly in database 'MyDatabase' to update, delete, or insert the row that has been modified or deleted by another transaction. Retry the transaction or change the isolation level for the update/delete statement.

Is there any restriction for the service broker that prohibits the usage of snapshot isolation.

Thanks in advance.

How to ignore service broker option for database deployment on always on server

$
0
0

We have setup service broker on our always on database. However, when we are trying to deploy database (sqlproj), deployment script tries to disable broker and fails, as database is part of always on group. When I checked where Disable broker call is being made from, found that the setting is in sqlproj properties. I don’t find any option to ignore broker settings. How can I ignore service broker options in my project, so it never tries to alter whatever broker settings are present on the database?

 below is the error that I am receiving during deployment:

Error SQL72014: .Net SqlClient Data Provider: Msg 1468, Level 16, State 1, Line 5 The operation cannot be performed on database "DBName" because it is involved in a database mirroring session or an availability group. Some operations are not allowed on a database that is participating in a database mirroring session or in an availability group.

Error SQL72045: Script execution error.  The executed script:

IF EXISTS (SELECT 1

FROM   [master].[dbo].[sysdatabases]

WHERE  [name] = N'$(DatabaseName)')

   BEGIN

ALTER DATABASE [$(DatabaseName)]

SET DISABLE_BROKER

WITH ROLLBACK IMMEDIATE;

   END


SQL broker Issue

$
0
0
  • SQL broker started lock time out error at 1:20 AM.
  • Failed to allocate page at 03:25 AM.
  • Insufficent memory occured at 3:25 am onwards(log atatched).
  • SQL shutdown at around 3:40 am.

SQL Log Links

https://www.dropbox.com/s/ruo9ye2u711b9o9/sql%20Log.log?dl=0

https://www.dropbox.com/s/a8bvtna1swtt8fo/sql%20Log_Full.log?dl=0


Nav


Naveen| Press Yes if the post is useful.


SQL dependency

$
0
0

Sir

I am testing a Vb.net application to have SQL dependency with SQL server database. Infact I copied the sample code given in MSDN and only changed the database connection string.

I am getting the connection but the dependency_OnChange event gets fired repeatedly as in a loop.

The args e.Type is "Subscribe"

and e.info is Invalid.

I checked the SQL statement for the format but could not find any mistake.

Private Function GetConnectionString() As String Return "Server=OPS-TMIT\SQLEXPRESS;Database=FlightStatus;Integrated Security=true;" & _"User ID=;Password=;Trusted_Connection=True;Encrypt=False;" & _"Connection Timeout=30;Pooling=False;" End Function

Private Function GetSQL() As String Return "Select [FlightStatus].[dbo].[Data].[Auto], " & _"[FlightStatus].[dbo].[Data].[Arr Date] " & _"FROM [FlightStatus].[dbo].[Data] " & _"WHERE ([FlightStatus].[dbo].[Data].[Arr Date] = @Date1 );" End Function

Private Sub dependency_OnChange( _ ByVal sender As Object, ByVal e As SqlNotificationEventArgs) Dim someType = e.Type Dim someInfo = e.Info Dim someScource = e.Source ' This event will occur on a thread pool thread. ' It is illegal to update the UI from a worker thread ' The following code checks to see if it is safe ' update the UI. Dim i As ISynchronizeInvoke = CType(Me, ISynchronizeInvoke) ' If InvokeRequired returns True, the code ' is executing on a worker thread. If i.InvokeRequired Then ' Create a delegate to perform the thread switch Dim tempDelegate As New OnChangeEventHandler( _ AddressOf dependency_OnChange) Dim args() As Object = {sender, e} ' Marshal the data from the worker thread ' to the UI thread. i.BeginInvoke(tempDelegate, args) Return End If ' Remove the handler since it's only good ' for a single notification Dim dependency As SqlDependency = _ CType(sender, SqlDependency) RemoveHandler dependency.OnChange, _ AddressOf dependency_OnChange ' At this point, the code is executing on the ' UI thread, so it is safe to update the UI. changeCount += 1 ' Add information from the event arguments to the list box ' for debugging purposes only. ' Reload the dataset that's bound to the grid. GetData() End Sub Private Sub GetData()

' Empty the dataset so that there is only ' one batch worth of data displayed. dtSet.Clear() ' Make sure the command object does not already have ' a notification object associated with it. command.Notification = Nothing ' Create and bind the SqlDependency object ' to the command object. Dim dependency As New SqlDependency(command) AddHandler dependency.OnChange, AddressOf dependency_OnChange Using adapter As New SqlDataAdapter(command) adapter.Fill(dtSet, tableName) Me.DataGridView1.DataSource = dtSet Me.DataGridView1.DataMember = tableName End Using End Sub Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Try ' Remove any existing dependency connection, then create a new one. SqlDependency.Stop(GetConnectionString()) SqlDependency.Start(GetConnectionString()) If connection Is Nothing Then connection = New SqlConnection(GetConnectionString()) End If If command Is Nothing Then ' GetSQL is a local procedure that returns ' a paramaterized SQL string. You might want ' to use a stored procedure in your application. command = New SqlCommand(GetSQL(), connection) Dim prm As New SqlParameter("@Date1", SqlDbType.DateTime2) prm.Direction = ParameterDirection.Input prm.DbType = DbType.DateTime2 prm.Value = "2013-11-18 00:00:00" command.Parameters.Add(prm) End If If dtSet Is Nothing Then dtSet = New DataSet() End If GetData() Catch ex As Exception MsgBox(ex.Message) End Try End Sub



Please advice where I have gone wrong !!


Manoj

ENABLE_BROKER Master Database

$
0
0

Is enable broker in the master database supported by MS and is there any documentation, or is not even possible?

I have a 3rd party software vendor who is adamant I need to enable this!

Thanks

Adam

DBMail

$
0
0

Hi,

DB mail is configured in my SQL Server 2014.

The mail that goes to the users has the sender as SQL Alert< mai@xxx.com>

I need the sender to come as SomeName< xxxmai@xxx.com> and not asSQL Alert< xxxmai@xxx.com>.

How can this be done.

Thanks..

Link Server Desconnected every 3min

$
0
0

Hi All,

i Install 2 SQL server in two different Machine. both are running in my LAN.

for my application requirement i link 2 machine SQL Server to my first Server. Everything is working fine when my application is running continually. But if i not doing any thing in application after 3 or 4 min it showing Server 5 Error.

when i try Test Connection is showing Connection Successful after that every thing working fine but this process i do every 3 min.

is there any solution which successfully connected forever?

Thank!

Hitesh Patel

Granted or revoked privilege RECEIVE is not compatible with object

$
0
0

Hi,

I am enabling SQL dependency in my database.

So far I have 

USE MASTER

ALTER DATABASE SMT_Web_API_Admin SET NEW_BROKER WITH ROLLBACK IMMEDIATE

Running 

SELECT name, is_broker_enabled FROM sys.databases  WHERE name = 'SMT_Web_API_Admin'

Gets: 1

Next I have ran this against both master and SMT_Web_API_Admin

GRANT SUBSCRIBE QUERY NOTIFICATIONS TO SMT_Web_API_User

When I try running 

GRANT RECEIVE ON [Users] TO SMT_Web_API_User

Granted or revoked privilege RECEIVE is not compatible with object

I did this process once before but it was a while ago and can't remember how to do it. I know last time I got the table AspNet_SqlCacheTablesForChangeNotification which must get added when the failing SQL executes.

Please help if you can.

Thanks, 

Dave.


Viewing all 461 articles
Browse latest View live


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