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

Service Broker Applicatioin

$
0
0

I'm designing an application that will be reading messages from an SQL Queue. This is a requirement. I must use their queue. The problem is how to read their queue. I would like to use it just like an MSMQ but it doesn't look possible. I need to read messages in FIFO order one at a time. To read one at a time I would have to make each message a conversation but then they would not necessarily be in FIFO order. I can use one never ending conversation to maintain order but then I believe I have to read everything in the queue. Not just one message. Has anyone built an application to perform the way I need it to? Is it impossible? Any other suggestions?

Thanks in advance.


Donald Hofferber

↧

PDF Export = System.DllNotFoundException: Unable to load DLL 'T2Embed': Access is denied

$
0
0
Hello,

I am using the ReportViewer over asp.net pages on a web hosting service.  I am generating the reports independently of the 'Sql Reporting Services' windows service.  In fact I have 'Sql Report Services' service turned off.

All export works okay when I test the report in IIS7 on my local machine and in Visual Studio.  After I FTP the web application to the remote web host the report still works but only the Excel exports properly.  The export to PDF or Word generates the error

System.DllNotFoundException: Unable to load DLL 'T2Embed': Access is denied

Other people have had this problem too but their remedy is to run cacls.exe and fidget around with t2embed.dll.  Maybe that will work for a local client machine but that is not something I can do on a web hosts server.  They seem to think the font has security issues and a hotfix may be causing it.  The next thing I will try will be to use a generic font in my report like Arial or Courier but I doubt that will fix it. 

Any clues?
↧
↧

External Activation: Using SQL server service broker from a ASP.NET MVC application

$
0
0

Hello,

I have the following requirement from an asp.net mvc application.

User has the option to print , which will execute a print to different formats. I want to make the print process asynchronous.For that I want to utilize the service broker.

After going through some blogs etc, I have an understanding of how to use it and I wanted to confirm my understanding.

Here it is at a high level:

1: create a request message and send to service broker

2: Use the service broker external activator to call a web api

3: The web api will do the print task and store the printed document to the DB

4: Finish service broker task

5: On UI when the user visits the page again, they will see the option to download the document

Is this a good approach? Any example on how to use external activator with an MVC application?



↧

How to "drainstop" a service broker queue

$
0
0

Is there a way to "drainstop" a service broker queue (i.e., allow messages currently in the queue to be processed, but not allow any new messages to be put in the queue)?

We have an OLTP applicaiton that rebuilds the queues as part of the upgrade, but it won't do that if there are any messages because it would result in missing data. 

Any ideas on how to drainstop it?

↧

SqlDependency losing subscription after upgraded to .NET4.5

$
0
0

My service which uses SqlDependency to receive notification for table changes has been working fine on .NET4. However since I upgraded to .NET4.5, it starts to lose subscription over time, especially where there's a lot of queries from my service to SQL. I'm able to reproduce this and when I go back to .NET4, the problem wasn't there. 

I have checked the timing in my OnChange() function and its takes < 5 seconds to execute and on the last notification which I received, I did re-create another SqlDependency instance to subcribe for further notification. 

When the issue appears, I saw this error in my sql errorlog:

2014-02-26 18:02:02.25 spid40s     The query notification dialog on conversation handle '{D5DFC6C1-4397-E311-9D97-005056854BBF}.' closed due to the following error: '<?xml version="1.0"?><Error xmlns="http://schemas.microsoft.com/SQL/ServiceBroker/Error"><Code>-8470</Code><Description>Remote service has been dropped.</Description></Error>'.

Is there any known issue with SqlDependency on .NET4.5 and SQL Server 2008 R2?

↧
↧

Drop default constraint on a table function

$
0
0

I need to drop some default constraints that appear to be tied to table functions (and not actual tables).  This means when I try the ALTER TABLE DROP CONSTRAINT command it fails with the error, "unable to drop constraint because object is not a table" or something similar.

My question is: how do I drop a constraint on a table function?

↧

Could not start Service Broker for database

$
0
0
Problem:
Could not start Service Broker for database id: 9. A problem is preventing SQL Server from starting Service Broker. Check the SQL Server error log for additional messages.

The windows and application logs do not give me any for information. I have checked the database instance and found that Database ID 9 does not exist in the sys.databases table. Could this be the reason?

How do I resolve it so that SQL Server does not try and start Service broker for a database ID that does not exist?

Any help will be greatly appreciated.

Thanks.
↧

Could not start Service Broker for database id

$
0
0

I am getting this message in the SQL Server error log:

 

Could not start Service Broker for database id: 10. A problem is preventing SQL Server from starting Service Broker. Check the SQL Server error log for additional messages.

 

It appears even when the broker is disabled on the database.  How can I eliminate this error?

 

Thanks!

↧

Behaviour of Service Broker during clustered SQL Server failover

$
0
0

Hi, 

I have 3 instances of SQL Server 2005 hosted on a 3-node cluster, using Polyserve clustering.  Each instance is nominally hosted on its own node in the cluster.

I have configured Service Broker to route messages from INST-A (on NODE-1) to INST-C (on NODE-3), using TCP and a NetBIOS name.  This NetBIOS name obviously uses the machine name of the node, rather than the virtual machine name of the instance.

Under normal conditions, this works, messages sent from INST-A to INST-C are received and processed.

However, should INST-C failover (for example to NODE-1), the route created to INST-C from INST-A is no longer valid; INST-C is now on a different node to that specified in the route.

Service Broker stops, unable to put messages onto the queue on INST-C, so backing them up in sys.transmission_queue on INST-A.  To fix, I have to update the route as appropriate.

We have thousands of messages being sent every minute.  While a delay in sending them during an actual failover is expected, would it not also be expected to recover itself and process any backlog without manual intervention?

Is there something I'm missing in my configuration?  Or do I need to set up some other means to automatically update the route upon failover?  In which case, how can I programmatically determine the node to which it has failed-over?

Configuration scripts:

Target Endpoint:

CREATE ENDPOINT ServiceBrokerTargetEndpoint
STATE = STARTED
AS TCP(LISTENER_PORT = xxxx)
FOR SERVICE_BROKER(AUTHENTICATION = WINDOWS, ENCRYPTION = REQUIRED)

CREATE ROUTE RouteToTargetService
WITH SERVICE_NAME = 'ServiceBrokerTargetService', ADDRESS = 'TCP://INST-C:xxxx'

INST-A and INST-C are both SQL 2005 Enterprise edition.

Thanks for any assistance.

Simon

↧
↧

Closed status sys.conversation_endpoints not being automatically purged

$
0
0
Is there any reason why conversation_endpoints in a Closed status are not automatically purged?  Both the initiator and receiver are issuing END CONVERSATION requests resulting in a Closed status.  However, we have millions of closed endpoints never getting purged from sys.conversation_endpoints.
↧

What is Service Broker is used (or supposed to be used) for?

$
0
0

When Service Broker was introduced in 2005 I tried some simple "Hello World" examples which were supplied in order to demonstrate its ability to send messages from one session to another. I didn't need such a tool and wondered who needs it..
It took me some years to discover its ability to execute stored procedures asynchronously, and I have already implemented it in some systems.
I have asked some of my colleagues about Service Broker, many of them use his asynchronous ability to execute procedures, none is using it to send messages.

My question: I suspect the original intention was to supply a messaging system and the asynchronous execution was only a sub product, but somehow - the sub product became a main product. Is it true? Otherwise - do you know many messaging systems rely on Service Broker?
I ask this question because I don't have any explanation why is it so complex and why I have to create so many objects (message type,  queues, services, contracts etc.) which are essential for messaging and not for asynchronous execution.
Thanks!


El castellano no es mi lengua materna. Discúlpenme por los errores gramaticales, y, si pueden, corríjanme en los comentarios, o por correo electrónico. ¡Muchas gracias! Blog: http://about.me/GeriReshef

↧

Service Broker, I need some help plz!!

$
0
0

Hi,

I have a service that uses sqlnotificationRequest, it works kinda alright, it received messages from sql on a particular table.

Okay, I copied that majority of code for another service and this one does not get any messages, timeouts, insert nothing.

Can somebody please help me out. I will post the script I use to set up the service broker and the sqlnotificationRequest code. Although I think it's on the sql side that the problem is occurring.

so basically I have two users, cdwf_Notification is the account the service will run under in production.

and wwprogramming\programming_restricted for testing.

DECLARE @SPID int
DECLARE Process_Cursor CURSOR FOR
		SELECT sp.spid
		  FROM master..sysprocesses sp
		 INNER JOIN sys.databases sd
			ON sd.database_id = sp.DBID
		 WHERE sd.name = 'CabinetDoor'
		   AND NOT sp.spid = @@spid
	OPEN Process_Cursor
	FETCH NEXT FROM Process_Cursor
	 INTO @SPID
	WHILE @@FETCH_STATUS = 0
	BEGIN
		PRINT 'Killing spid = ' + LTRIM(STR(@SPID))
		EXEC('KILL ' + @SPID )
		FETCH NEXT FROM Process_Cursor
		 INTO @SPID
	END
	CLOSE Process_Cursor
	DEALLOCATE Process_Cursor

USE [master]
GO
IF NOT EXISTS (SELECT name FROM Master.sys.server_principals WHERE name = 'WWPROGRAMMING\Programming_Restricted')
BEGIN
	CREATE LOGIN [WWPROGRAMMING\Programming_Restricted] FROM WINDOWS WITH DEFAULT_DATABASE=[CabinetDoor]

END
GO

USE [CabinetDoor]
IF NOT EXISTS (SELECT name FROM sys.database_principals WHERE name = 'WWPROGRAMMING\Programming_Restricted')
BEGIN
	CREATE USER [WWPROGRAMMING\Programming_Restricted] FOR LOGIN [WWPROGRAMMING\Programming_Restricted]
END
GO


IF NOT EXISTS (SELECT name FROM Master.sys.server_principals WHERE name = 'WWPROGRAMMING\CDWF_NotificationSer')
BEGIN
	CREATE LOGIN [WWPROGRAMMING\CDWF_NotificationSer] FROM WINDOWS WITH DEFAULT_DATABASE=[CabinetDoor]

END
GO
USE [CabinetDoor]
IF NOT EXISTS (SELECT name FROM sys.database_principals WHERE name = 'WWPROGRAMMING\CDWF_NotificationSer')
BEGIN
	CREATE USER [WWPROGRAMMING\CDWF_NotificationSer] FOR LOGIN [WWPROGRAMMING\CDWF_NotificationSer]
END
GO

ALTER DATABASE [CabinetDoor] SET  ENABLE_BROKER WITH NO_WAIT
GO

USE CabinetDoor

CREATE QUEUE WFMessages

CREATE SERVICE WFNotifications
ON QUEUE WFMessages
--([http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification]);

CREATE ROUTE WFRoute
WITH SERVICE_NAME = 'WFNotifications',
	 ADDRESS = 'LOCAL';

GRANT DELETE TO [WWPROGRAMMING\CDWF_NotificationSer]
GO
GRANT EXECUTE TO [WWPROGRAMMING\CDWF_NotificationSer]
GO
GRANT INSERT TO [WWPROGRAMMING\CDWF_NotificationSer]
GO
GRANT SELECT TO [WWPROGRAMMING\CDWF_NotificationSer]
GO
GRANT UPDATE TO [WWPROGRAMMING\CDWF_NotificationSer]
GO


GRANT DELETE TO [WWPROGRAMMING\Programming_Restricted]
GO
GRANT EXECUTE TO [WWPROGRAMMING\Programming_Restricted]
GO
GRANT INSERT TO [WWPROGRAMMING\Programming_Restricted]
GO
GRANT SELECT TO [WWPROGRAMMING\Programming_Restricted]
GO
GRANT UPDATE TO [WWPROGRAMMING\Programming_Restricted]
GO


--Security for Service Broker...
GRANT SUBSCRIBE QUERY NOTIFICATIONS TO [WWPROGRAMMING\CDWF_NotificationSer]
GO
GRANT VIEW DEFINITION TO [WWPROGRAMMING\CDWF_NotificationSer]
GO

GRANT RECEIVE ON [dbo].[WFMessages] TO [WWPROGRAMMING\CDWF_NotificationSer]
GO
GRANT REFERENCES ON [dbo].[WFMessages] TO [WWPROGRAMMING\CDWF_NotificationSer]
GO

GRANT SUBSCRIBE QUERY NOTIFICATIONS TO [WWPROGRAMMING\Programming_Restricted]
GO
GRANT VIEW DEFINITION TO [WWPROGRAMMING\Programming_Restricted]
GO

GRANT RECEIVE ON [dbo].[WFMessages] TO [WWPROGRAMMING\Programming_Restricted]
GO
GRANT REFERENCES ON [dbo].[WFMessages] TO [WWPROGRAMMING\Programming_Restricted]
GO

--May not be required*****************************************************
GRANT SEND ON service::[http://schemas.microsoft.com/SQL/Notifications/QueryNotificationService] TO [WWPROGRAMMING\CDWF_NotificationSer]
GO

GRANT SEND ON service::[http://schemas.microsoft.com/SQL/Notifications/EventNotificationService] TO [WWPROGRAMMING\CDWF_NotificationSer]
GO

GRANT SEND ON service::[http://schemas.microsoft.com/SQL/ServiceBroker/ServiceBroker] TO [WWPROGRAMMING\CDWF_NotificationSer]
GO

GRANT SEND ON service::[http://schemas.microsoft.com/SQL/Notifications/QueryNotificationService] TO [WWPROGRAMMING\Programming_Restricted]
GO

GRANT SEND ON service::[http://schemas.microsoft.com/SQL/Notifications/EventNotificationService] TO [WWPROGRAMMING\Programming_Restricted]
GO

GRANT SEND ON service::[http://schemas.microsoft.com/SQL/ServiceBroker/ServiceBroker] TO [WWPROGRAMMING\Programming_Restricted]
GO
--***********************************************************************

GRANT SEND ON service::[WFNotifications] TO [WWPROGRAMMING\CDWF_NotificationSer]
GO

GRANT RECEIVE ON [dbo].[QueryNotificationErrorsQueue] TO [WWPROGRAMMING\CDWF_NotificationSer]
GO
GRANT REFERENCES ON [dbo].[QueryNotificationErrorsQueue] TO [WWPROGRAMMING\CDWF_NotificationSer]
GO

GRANT SEND ON service::[WFNotifications] TO [WWPROGRAMMING\Programming_Restricted]
GO

GRANT RECEIVE ON [dbo].[QueryNotificationErrorsQueue] TO [WWPROGRAMMING\Programming_Restricted]
GO
GRANT REFERENCES ON [dbo].[QueryNotificationErrorsQueue] TO [WWPROGRAMMING\Programming_Restricted]
GO

--****************************************************************************************************

--REVOKE RECEIVE ON [dbo].[EventNotificationErrorsQueue] TO [WWPROGRAMMING\CDWF_NotificationSer]
--GO
--REVOKE REFERENCES ON [dbo].[EventNotificationErrorsQueue] TO [WWPROGRAMMING\CDWF_NotificationSer]
--GO

--REVOKE RECEIVE ON [dbo].[ServiceBrokerQueue] TO [WWPROGRAMMING\CDWF_NotificationSer]
--GO
--REVOKE REFERENCES ON [dbo].[ServiceBrokerQueue] TO [WWPROGRAMMING\CDWF_NotificationSer]
--GO

--GRANT RECEIVE ON [dbo].[EventNotificationErrorsQueue] TO [WWPROGRAMMING\Programming_Restricted]
--GO
--GRANT REFERENCES ON [dbo].[EventNotificationErrorsQueue] TO [WWPROGRAMMING\Programming_Restricted]
--GO

--GRANT RECEIVE ON [dbo].[ServiceBrokerQueue] TO [WWPROGRAMMING\Programming_Restricted]
--GO
--GRANT REFERENCES ON [dbo].[ServiceBrokerQueue] TO [WWPROGRAMMING\Programming_Restricted]
--GO

Now the SqlNotificationRequest code:

Private m_dependency_options As String = "Service=WFNotifications"
Private m_dependency_SelectText As String = "Notification_Select"
Private m_callback As New AsyncCallback(AddressOf dependency_onchange)

#Region "   setup_connection"

    Private Function setup_connection() As Boolean

        Try
            WriteEntry("In setup_connection")
            'first time through, 
            'keep a class level sqlconnection and sqlcommand object
            m_dependency_conn = New SqlConnection(m_connectionstring)
            m_dependency_cmd = m_dependency_conn.CreateCommand
            m_dependency_cmd.CommandType = CommandType.StoredProcedure
            m_dependency_cmd.CommandText = m_dependency_SelectText
            m_dependency_conn.Open()
            m_dependency_cmd.Notification = Nothing
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function

#End Region

#Region "   init_notificationrequest"

    Private Function init_notificationrequest(options As String) As Boolean
        Try
            If m_dependency_cmd.Notification Is Nothing Then
                Dim request As New SqlNotificationRequest()
                request.UserData = Guid.NewGuid().ToString()
                request.Options = options
                request.Timeout = m_dependency_timeout
                m_dependency_cmd.Notification = request
            End If
            If m_dependency_conn.State = ConnectionState.Open Then
                m_dependency_conn.Close()
            End If
            m_dependency_conn.Open()
            m_dependency_cmd.ExecuteNonQuery()
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function

#End Region

#Region "   configure_dependency_cmd"

    Private Sub configure_dependency_cmd()

        Try
            Using command As New SqlCommand(m_dependencyCommandText, m_dependency_conn)
                If Not m_dependency_conn.State = ConnectionState.Open Then
                    m_dependency_conn.Open()
                End If
                command.CommandTimeout = m_dependency_timeout
                command.BeginExecuteReader(m_callback, command)
            End Using
        Catch ex As Exception
            m_exceptionmsg = String.Format(m_exceptionmsg, ex.Message, ex.InnerException)
            WriteEntry(String.Format("Error In configure_dependency_cmd {0}", ex.Message), EventLogEntryType.Error)
            Throw
        End Try

    End Sub

#End Region

#Region "   dependency_onchange"

    Private Sub dependency_onchange(asynresult As IAsyncResult)

        Try
            WriteEntry("In Dependency_OnChange")
            Dim qn As QueryNotification = QueryNotification.Parse(asynresult)

            WriteEntry(String.Format("{0} : {1}", qn.ToString(), Now.ToString("hh:mm:ss")), EventLogEntryType.Warning)
            If qn.Type = SqlNotificationType.Change Then
                Select Case qn.Source
                    Case SqlNotificationSource.Data
                        Select Case qn.Info
                            Case SqlNotificationInfo.Insert
                                If m_servicehost.State = CommunicationState.Faulted Then
                                    RemoveHandler DirectCast(m_servicehost, ICommunicationObject).Faulted, AddressOf Faulted
                                    m_servicehost = New ServiceHost(New MultiWCFNotificationRequestService(Me), New Uri() {m_serviceuri})
                                    AddHandler DirectCast(m_servicehost, ICommunicationObject).Faulted, AddressOf Faulted
                                    m_servicehost.Open()
                                End If

                                If m_servicehost.State = CommunicationState.Opened Then
                                    Try
                                        'Go ahead and call select, process records
                                        m_servicehost.SingletonInstance.NotifySubscriber(loaddata(m_dependency_cmd))
                                    Catch ex As Exception
                                        WriteEntry(String.Format("dependency_onchange: NotifySubscriber caused an exception. {0}", ex.Message), EventLogEntryType.Error)
                                    End Try
                                End If
                        End Select
                End Select
            End If
            If m_running Then
                If init_notificationrequest(m_dependency_options) Then
                    configure_dependency_cmd()
                End If
            End If
        Catch ex As Exception

        End Try

    End Sub

#End Region


↧

Records stuck in Queues

$
0
0

We are developing an application that will use Service Broker for message delivery. Everything seems to be working correctly, but during development we experienced multiple instances where messages got stuck in either the transmission or receive queues. What could be causing this? If they continue to get stuck in the transmission queue during production, do you have any suggestions for preventing and/or clearing the stuck records in this queue? I added the following code to reprocess the transmission queue but have not gotten any stuck records during testing to verify that the code works.

 

          

SELECT@int_TransQ_Count=COUNT(*)

FROM   sys.transmission_queue


IF@int_TransQ_Count>0


BEGIN;          

DELETE@t_receive;


INSERT@t_receive(

        queuing_order

        ,message_body

       ,conv_handle

        )

SELECT message_sequence_number

      ,message_body

           ,conversation_handle                  

FROM   sys.transmission_queue;

                   

SELECT TOP1@nstr_conversation_handle=CAST([conversation_handle]asnvarchar(128))                  

FROM   [sys].[transmission_queue];

                   

SELECT@nstr_SQLStatement=N'END CONVERSATION '''+@nstr_conversation_handle+                        

''' with cleanup;';          

EXECSPCTR_ADMIN.dbo.sp_executesql@nstr_SQLStatement;

                  

GOTOREPROCESS;                        

END;

↧
↧

Transaction (Process ID 112) was deadlocked on lock resources

$
0
0

i got a error when i run the ssis,how to fix it.

Transaction (Process ID 112) was deadlocked on lock resources with another pr

                               ocess and has been chosen as the deadlock victim

↧

Internal Activation Questions

$
0
0

Hi All,

First time, I setup Internal Activation for two stored procedures. One, inserts one or more records , the other, updates one or more records in the same table. So, I have two initiator, two target queues. It works fine on development so far, but I wonder what types of problems I might encounter when we move it to prod where these two stored procedures are frequently called. We have already experiencing deadlock issues caused by these two stored procedures. Asynchronous execution is my main goal this this implementation.

Q1) Is there a way to use one target queue for both stored procedures to prevent any chance of deadlocks?

Q2) Is there anything I can do to make it more reliable? like one execution error should not stop incoming requests to the queue?

Q3) Tips to improve scalability (high number of execution per second)?

Q4) Can I set RETRY if there is a deadlock?

Here is the partial code of the insert stored procedure;

CREATE PROCEDURE [dbo].[usp_AddInstanceUsers] @UsersXml xml AS BEGIN DECLARE @Handle UNIQUEIDENTIFIER; BEGIN DIALOG CONVERSATION @Handle FROM SERVICE [RecordAddUsersService] TO SERVICE 'AddUsersService' ON CONTRACT [AddUsersContract] WITH ENCRYPTION = OFF; SEND ON CONVERSATION @Handle MESSAGE TYPE [AddUsersXML](@UsersXml); END GO

CREATE PROCEDURE [dbo].[usp_SB_AddInstanceUsers] AS BEGIN

    DECLARE @Handle    UNIQUEIDENTIFIER;
    DECLARE @MessageType SYSNAME;
    DECLARE @UsersXML  XML;

WHILE (1=1)
BEGIN
BEGIN TRANSACTION;
WAITFOR
(RECEIVE TOP (1) 
@Handle = conversation_handle,
@MessageType = message_type_name, 
@UsersXML = message_body
FROM [AddUsersQueue]), TIMEOUT 5000;
IF (@@ROWCOUNT = 0)
BEGIN
 ROLLBACK TRANSACTION;
 BREAK;
END

IF (@MessageType = 'ReqAddUsersXML')
BEGIN

--<INSERT>....

DECLARE @ReplyMsg NVARCHAR(100);
SELECT  @ReplyMsg = N'<ReplyMsg>Message for AddUsers Initiator service.</ReplyMsg>';
SEND ON CONVERSATION @Handle
MESSAGE TYPE [RepAddUsersXML] (@ReplyMsg);
END

ELSE IF @MessageType = N'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
BEGIN
  END CONVERSATION @Handle;
END
ELSE IF @MessageType = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'
BEGIN
  END CONVERSATION @Handle;
END
COMMIT TRANSACTION;

END END GO

CREATE QUEUE   [RecordAddUsersQueue];
CREATE SERVICE [RecordAddUsersService] ON QUEUE [RecordAddUsersQueue];

ALTER QUEUE [AddUsersQueue] WITH ACTIVATION 
(     STATUS = ON,
      MAX_QUEUE_READERS = 1,
      PROCEDURE_NAME = usp_AddInstanceUsers,
      EXECUTE AS OWNER);


Thanks,

Kuzey






↧

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

↧

Access Service Broker Views

$
0
0

Hello,

Going through the various views in to the world of Service Broker, I appear to be able to view records in all of them except sys.transmission_queue. If I run the following query:

select * from sys.transmission_queue

I get no rows returned.

If I run a stored procedure which executes as dbo I see the messages that are stuck.

What permission am I missing? This is a production environment and therefore I cannot have db_owner etc, only db_datareader.

I have looked for permissions on sys.transmission_queue and am unable to find this anywhere. I have also looked for some GRANT message for my login but am also failing to find anything here.

Thanks,


.Net Developer

↧
↧

begin conversation timer (@h) timeout =..

$
0
0

From examples I found concerning begin conversation timer and tried by myself I concluded the following:

  1. In the code which initiate the conversation - it will define the time of delay till the conversation begins.
  2. In the asynchronous procedure activated by the queue - it causes it to be executed in a loop, and define the time between the iterations.

Am I right?
Is there a way to count the iterations and to know (inside the procedure) how many time it has been activated?



↧

The server principal "sa" is not able to access the database under the current security context

$
0
0
I'm working with SQL Server 2012 Express.

I'm using Service Broker to run a stored procedure asynchronously.

The activation procedure has to access another database to execute another stored procedure. This is the code:

CREATE PROCEDURE [dbo].[GetNewCodes]
        @gintNewCodes bigint,    
        @presNewCodes tinyint,
        @levelNewCodes bigint,
        @quantityNewCodes smallint
    AS
        -- Get new codes from INCIC database.
        DECLARE    @return_value int,
                @xmlGenerated xml,
                @xmlString NVARCHAR(MAX)
        SET NOCOUNT ON;
            -- Set that this stored procedure is running
            update dbo.RunningSPs with (serializable) set conf_value = 1
            where sp_name = N'GetNewCodes'
            if @@rowcount = 0
            begin
                insert dbo.RunningSPs(sp_name, conf_value) values (N'GetNewCodes', 1)
            end
        EXEC    @return_value = [INCIC].[dbo].[ReadCodeBuffer]
                @gint = @gintNewCodes,
                @pres = @presNewCodes,
                @level = @levelNewCodes,
                @quantity = @quantityNewCodes,
                @xmlGenerated = @xmlGenerated OUTPUT
        SET @xmlString = cast(@xmlGenerated as nvarchar(max))
        -- Process these new codes on TRZ.
        EXEC dbo.ProcessCodes @XmlString = @xmlString
        -- Update that we are not running this procedure any more.
        update dbo.RunningSPs with (serializable) set conf_value = 0
        where sp_name = N'GetNewCodes'
        if @@rowcount = 0
        begin
            insert dbo.RunningSPs(sp_name, conf_value) values (N'GetNewCodes', 0)
        end

The problem is here: [INCIC].[dbo].[ReadCodeBuffer], and the error message is:

Error: 50000   
Unrecoverable error in procedure GetNewCodes: 916: The server principal "sa" is not able to access the database "INCIC" under the current security context.

I have followed this tutorial to implement Service, queue and activation stored procedure.

How can I fix this problem?
↧

Impact of ALTER DATABASE GPx SET NEW_BROKER WITH ROLLBACK IMMEDIATE in production db

$
0
0

System Configuration :

OS : Windows 2003 latest SP

SQL Server : Standard Edition, SP2

Microsoft SQL Server 2005 - 9.00.3042.00 (Intel X86)

                     Feb  9 2007 22:47:07

                     Copyright (c) 1988-2005 Microsoft Corporation

                     Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 1)

 

DownTime : This is not a 24x7 kind of machine. It can have downtime

 

Reference : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1198044&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1026884&SiteID=1

 

I have been discussing this Service Broker issues in this forum for quite sometimes and sorry to bother u all again… To make things more clearer before implementing in production environment I have few doubts and it should be clarified..


As discussed in the first link we can clear sys.conversation_endpoints  by just giving ALTER
DATABASE GPx SETNEW_BROKERWITH ROLLBACK IMMEDIATE. But my apprehension is that if we run this command on production server and it truncate this table… what will be the impact and overall overhead on the system…  Is it recommended to give this statement on Production Server daily at less traffic times, to clear this table ?… will it have adverse effect.  I repeat I have downtime , I can even shutdown this server daily…

 

I also, just want to know why Microsoft has not looked into this aspects… why the system itself is clearing the expired messages..  What is the thought behind this architecture

 

I have the script to run in batch… but in high-level meetings it is always difficult to convince this architecture/process…   

 

 

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>