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

Troubleshooting error : "The conversation handle "XYZ" is not found"

$
0
0

We have a stored proc that generates service broker messages that are later processed / stored for long term via an activation stored proc.

Occasionally, we see the following error when the message sender sp is invoked:

TypeName: System.Data.SqlClient.SqlException, System.Data
Message: The conversation handle "A33AA310-379C-E611-BFAC-00154D09A706" is not found.
Source: .Net SqlClient Data Provider

Here is the message sender TSQL from the sender sp that generates the service broker message.  Not sure what would cause a conversation handle not found error here.

If (@MessageBody IS NOT NULL)
BEGIN
		SET @Handle = NEWID()
		BEGIN DIALOG CONVERSATION @Handle
		FROM SERVICE ImageAuditPublisher
		TO SERVICE 'ImageAuditSubscriber'
		ON CONTRACT [http://schemas.foo.com/contracts/ImageAudit]
		WITH ENCRYPTION = OFF;
		SEND ON CONVERSATION @Handle
		MESSAGE TYPE [http://schemas.foo.com/messages/ImageAudit/Insert](@MessageBody);
		END CONVERSATION @Handle

		print 'ImageAudit message sent!'
		print CONVERT(VARCHAR(MAX), @MessageBody, 1);
END

 What typically causes this type of error?

Microsoft SQL Server 2014 - 12.0.4213.0 (X64) 
Jun  9 2015 12:06:16 
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)


Sql deadlock errors / sys.sysdercv

$
0
0

Every now and then we see sql deadlock errors in our activation sp.  Specifically, the race condition happens on FOTNAudit.sys.sysdercv.   What is sys.sysdercv table used for and how do you prevent deadlocks against it?

<deadlock-list><deadlock victim="process7fab5f1468"><process-list><process id="process7fab5f1468" schedulerid="21" kpid="0" status="background" spid="38" sbid="0" ecid="0" priority="0" trancount="3"><executionStack><frame procname="FOTNAudit.dbo.BatchAuditMessageDequeue" line="117" stmtstart="9800" stmtend="9878" sqlhandle="0x03000d000aa92912b22bf0001aa6000001000000000000000000000000000000000000000000000000000000">
END CONVERSATION @RecvReqDlgHandle;     </frame></executionStack><inputbuf></inputbuf></process><process id="process9436e9c28" taskpriority="20" logused="2492" waitresource="KEY: 13:281474981494784 (3670049cdf92)" waittime="90" ownerId="8602590955" transactionname="Main" lasttranstarted="2016-11-15T08:19:12.293" XDES="0x36178f770" lockMode="U" schedulerid="3" kpid="15320" status="background" spid="38" sbid="0" ecid="0" priority="0" trancount="3"><executionStack><frame procname="FOTNAudit.dbo.BatchAuditMessageDequeue" line="117" stmtstart="9800" stmtend="9878" sqlhandle="0x03000d000aa92912b22bf0001aa6000001000000000000000000000000000000000000000000000000000000">
END CONVERSATION @RecvReqDlgHandle;     </frame></executionStack><inputbuf></inputbuf></process></process-list><resource-list><keylock hobtid="281474981494784" dbid="13" objectname="FOTNAudit.sys.sysdercv" indexname="cl" id="lock21dea7d300" mode="X" associatedObjectId="281474981494784"><owner-list><owner id="process9436e9c28" mode="X"/></owner-list><waiter-list/></keylock><keylock hobtid="281474981494784" dbid="13" objectname="FOTNAudit.sys.sysdercv" indexname="cl" id="lockcdb6f4100" mode="X" associatedObjectId="281474981494784"><owner-list/><waiter-list><waiter id="process9436e9c28" mode="U" requestType="wait"/></waiter-list></keylock></resource-list></deadlock></deadlock-list>

Microsoft SQL Server 2014 (SP1-CU3) (KB3094221) - 12.0.4427.24 (X64) 
Oct 10 2015 17:18:26 
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.3 <X64> (Build 9600: )

How to call Sales Force WSDL from Stored Procedure in SQL server

$
0
0
How to call Sales Force WSDL from Stored Procedure in SQL server

Can I use the Listener name with Always on and Event Notification from a replica ?

$
0
0

I have a question about External Activation and AlwayOn Service broker databases.

I have

Listener

SSBS-1 (Primary)
SSBS-2

I send messages to the Listener which cause Event Notification from the Primary. 

My problem is we don't want to couple our EAService.config to the names of the replicas.

  <NotificationServiceList>
    <NotificationService name="ExternalActivatorService" id="100" enabled="true">
      <Description>Notification service</Description>
      <ConnectionString>
        <!-- All connection string parameters except User Id and Password should be specificed here -->
        <Unencrypted>server=Listener;database=ServiceBroker;Application Name=External Activator;Integrated Security=true;</Unencrypted>
      </ConnectionString>
    </NotificationService>
  </NotificationServiceList>

<ApplicationServiceList>
    <ApplicationService name="myMessageApp" enabled="true">
      <OnNotification>
        <ServerName>SSBS-1</ServerName> We want to use Listener here
        <DatabaseName>ServiceBrokerDatabase</DatabaseName>
        <SchemaName>dbo</SchemaName>
        <QueueName>QueueName</QueueName>
      </OnNotification>
      <LaunchInfo>
        <ImagePath>C:\Program Files (x86)\Location\Some.exe</ImagePath>
        <CmdLineArgs>QueueName</CmdLineArgs>
        <WorkDir>C:\Program Files (x86)\Location\Actisure Services</WorkDir>
      </LaunchInfo>
      <Concurrency min="1" max="4" />
    </ApplicationService> Repeat for SSBS-2
  </ApplicationServiceList>

If we use the Listener as the <ServerName> in EATrace.log we get the following error:-

2016-11-23 14:38:08    EXCEPTION    ERROR = 32, No enabled application monitor is on behalf of queue SSBS-1.ServiceBroker.dbo.QueueName.

Any ideas how this can get the replicas to publish notification so we only need external activator to monitor the Listener?

Email error within Trigger fails with 2 or more triggers attempting to send mail

$
0
0
  • SQL Server 2014 64 bit
  • Issue: Triggers in replicated SQL Server 2014 database (Replicating data from Oracle to SQL Server) fail with message  "The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1. Exception Message: Cannot send mails to mail server. (Mailbox unavailable. The server response was: 5.1.1 User unknown)."

When only 1 trigger is active, send mail is successful. Replication fails immediately when 2nd trigger with email is activated. Trigger with table insert only works fine.

We recently migrated to 2014 server, and had the same processes running on Svr 2008R2 runningReplicate - Attunity for ORA-SQL replication.

What could be causing the issue?

intermittent service broker send blocking issue

$
0
0

We have noticed that we occasionally see long running blocking issues when sending concurrent service broker messages via SP. The blocking was traced back to the following system object : "queue_messages_368720366".

Here is the snippet of tsql send code from our sp that encounters intermittent blocking issues (longer than 30 seconds):

If (@MessageBody IS NOT NULL)
BEGIN
		SET @Handle = NEWID()
		BEGIN DIALOG CONVERSATION @Handle
		FROM SERVICE ImageAuditPublisher
		TO SERVICE 'ImageAuditSubscriber'
		ON CONTRACT [http://schemas.foo.com/contracts/ImageAudit]
		WITH ENCRYPTION = OFF;
		SEND ON CONVERSATION @Handle
		MESSAGE TYPE [http://schemas.foo.com/messages/ImageAudit/Insert](@MessageBody);

END

What would cause "queue_messages_368720366" to experience intermittent blocking issues?  too much load?

Microsoft SQL Server 2014 (SP1-CU3) (KB3094221) - 12.0.4427.24 (X64) 
Oct 10 2015 17:18:26 
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.3 <X64> (Build 9600: )



transmission_queue / Classification has been delayed because the routing information is currently being updated.

$
0
0

We have appx 8 messages stuck in the service broker transmission queue with a status of 'Classification has been delayed because the routing information is currently being updated.'  What causes this error? How do you free these messages from the transmission queue so they process normally?

Microsoft SQL Server 2014 (SP1-CU3) (KB3094221) - 12.0.4427.24 (X64) 
Oct 10 2015 17:18:26 
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.3 <X64> (Build 9600: )

SQL Server Agent Job Custom Notifications

$
0
0

Is there a good way to customize sql agent notifications.  Not a fan of email or pager notifications.  More specifically, we use service broker and hipchat alot.  Would be nice if Service Broker could subscribe to the notifications.  If that is somehow possible we could send a corresponding message to hipchat.

SQL2014


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

Help on Service Broker

$
0
0

Need quick help on service broker. My team will be using service broker for an application and I need to showcase a POC/example or How service broker works in SQL server. Can someone guide where to start with?

Thank you in advance

Business Usage of Service Broker in SQL server

$
0
0
what are the business usage of SB in sql server? 

error when calling SSIS package from internal activation procedure via service borker

$
0
0

Hi application gets an error when SSIS pkg is being executed via procedure which is activated via Service Broker queue.

Application is sending a message to a queue which activates or trigger procedure execution when msg is received in the queue.

Procedure executes ssis pkg. If we run the procedure by itself it works fine, but when its activated via the srive broker queue internally it throws error

The activated proc '[DataFlowControl].[ RunEdwB1SpotRatesExtractProc]' running on queue 'SSISDB.DataFlowControl. RECEIVE_DEST_B1_FXRATE_QUEUE' output the following:  'Cannot execute as the server principal because the principal "AC\SQL14SRVDEV_SVC" does not exist, this type of principal cannot be impersonated, or you do not have permission

AC\SQL14SRVDEV_SVC is the service account to run SQL Server services and as sysadmin role.

If we add execute as login which has sysadmin role procedure execution works fine. What's the best way to achieve what application is trying to do without security risk or providing elevated permissions.

Sample code

create queue DataFlowControl.RECEIVE_DEST_B1_FXRATE_QUEUE;

GO

ALTER QUEUE [DataFlowControl].[RECEIVE_DEST_B1_FXRATE_QUEUE]

WITH

STATUS = ON,

ACTIVATION(

STATUS = ON,

PROCEDURE_NAME = [DataFlowControl].[RunEdwExtractProc],

MAX_QUEUE_READERS = 4,

EXECUTE AS OWNER

);

GO

CREATE procedure

[DataFlowControl].[RunEdwExtractProc]

BEGIN

PRINT'[RunEdwB1SpotRatesExtractProc] started at '+format(getdate(),'yyyy-MM-dd HH:mm:ss')

DECLARE@MessageBodyVARBINARY(MAX),


            @MessageTypeName

SYSNAME,


            @ConversationHandle

UNIQUEIDENTIFIER;


   

WAITFOR(


           

RECEIVETOP(1)


            @MessageTypeName

=message_type_name,


            @MessageBody

=message_body,


            @ConversationHandle

=[conversation_handle]

           

FROM[DataFlowControl].[RECEIVE_DEST_B1_FXRATE_QUEUE]

           

),TIMEOUT6000;


   

IF(@@ROWCOUNT>0)


   

BEGIN         

       

DECLARE@execution_idBIGINT,


            @ssis_execution_status

BIGINT=1;


       

EXECSSISDB.catalog.create_execution

         

@folder_name =N'EDW'


        

,@project_name='edw_b1_spot_rates_extract'


        

,@package_name='edw_b1_spot_rates_extract.dtsx'


        

,@execution_id=@execution_idoutput                             

       

EXECSSISDB.catalog.start_execution@execution_id  

       

WHILE(@ssis_execution_statusNOTIN(3,4,6,7,9))

         

BEGIN

           

/*The possible values are

            created (1),

            running (2),

            canceled (3),

            failed (4),

            pending (5),

            ended unexpectedly (6),

            succeeded (7),

            stopping (8),

            and completed (9)*/


           

WAITFORDELAY'00:00:01';--Pause for 1 second.


           

--Refresh the status.


           

SET@ssis_execution_status=(


           

SELECT


            [executions]

.[status]

           

FROM


            [SSISDB]

.[catalog].[executions]

           

WHERE


            [executions]

.[execution_id]=@execution_id

           

);


           

         

END


   

END;


END

;



GO

Large Number of entries in msdb.sys.conversation_endpoints for 'SQL/Notifications/ProcessWMIEventProviderNotification/v1.0' - tempDB lock?

$
0
0

Hello. This is my first time asking a question so apologies if I miss some details/protocol.

My question is twofold.

1: I have a large number of entries (200K+) within msdb.sys.conversation_endpoints for the service name 'SQL/Notifications/ProcessWMIEventProviderNotification/v1.0' (see below query) - does this sound correct. From what I understand, Service Broker converstations should be closed after use and cleaned up (deleted) after around 30 min. It would seem strange that there would be over 200K+ active conversations??

SELECT COUNT(conversation_handle)
--SELECT TOP 10 DATEADD(SECOND,-2147483647 ,lifetime) AS MessageDate, *
FROM msdb.sys.conversation_endpoints WITH(NOLOCK)
WHERE far_service = 'SQL/Notifications/ProcessWMIEventProviderNotification/v1.0'
AND state_desc = 'STARTED_OUTBOUND'

2: My second question relates to the first, hense the same thread. Does having such a large number of these open conversations lock pages in the tempDB and if so, is there some performance impact? I have uneven growth with 1 file in the tempdb (I have 8) and it's not possible to grow the other files to match 'tempdev' without increasing the drive space.

Some tech details:

@@Version = Microsoft SQL Server 2008 R2 (SP3) - 10.50.6000.34 (X64)   Aug 19 2014 12:21:34   Copyright (c) Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) 

Instance is clustered

- I have some WMI based alerts configured (failed logins, file growth, deadlocks)

I watched https://www.youtube.com/watch?v=5MGlqCfG1p0, where the speaker indicated Service Broker will hold locks to pages in the TempDB.

Thank you in advance for any help.

Allan

Sql server reboots after errors

$
0
0
I have Microsoft SQL Server 2016
Periodically, about every day reboots Sql Server, in the error log the following errors:

2017-01-21 07:11:17.07 spid16s     FlushCache: cleaned up 21021 bufs with 11707 writes in 190401 ms (avoided 6217 new dirty bufs) for db 60:0
2017-01-21 07:11:17.07 spid16s                 average writes per second:  61.49 writes/sec 
            average throughput:   0.86 MB/sec, I/O saturation: 4913, context switches 6674
2017-01-21 07:11:17.07 spid16s                 last target outstanding: 12480, avgWriteLatency 101

2017-01-21 07:18:43.11 Server      **Dump thread - spid = 0, EC = 0x0000000000000000
2017-01-21 07:18:45.98 Server      ***Stack Dump being sent to O:\MSSQL13.MSSQLSERVER\MSSQL\LOG\SQLDump0023.txt
2017-01-21 07:18:45.98 Server      * *******************************************************************************
2017-01-21 07:18:45.98 Server      *
2017-01-21 07:18:45.98 Server      * BEGIN STACK DUMP:
2017-01-21 07:18:45.98 Server      *   01/21/17 07:18:45 spid 12432
2017-01-21 07:18:45.98 Server      *
2017-01-21 07:18:45.98 Server      * Stalled Resource Monitor
2017-01-21 07:18:45.98 Server      *
2017-01-21 07:18:45.98 Server      * *******************************************************************************
2017-01-21 07:18:45.98 Server      * -------------------------------------------------------------------------------
2017-01-21 07:18:45.98 Server      * Short Stack Dump
2017-01-21 07:21:51.33 Server      Stack Signature for the dump is 0x00000000000002F8

2017-01-21 07:32:04.23 spid16s     FlushCache: cleaned up 11652 bufs with 7801 writes in 126068 ms (avoided 4464 new dirty bufs) for db 60:0
2017-01-21 07:32:04.23 spid16s                 average writes per second:  61.88 writes/sec 
            average throughput:   0.72 MB/sec, I/O saturation: 290, context switches 4661
2017-01-21 07:32:04.23 spid16s                 last target outstanding: 9396, avgWriteLatency 129
2017-01-21 07:33:43.80 Backup      Log was backed up. Database: DMEDSC_akm, creation date(time): 2016/11/26(16:30:04), first LSN: 676996:336:9, last LSN: 677217:28391:1, number of dump devices: 1, device information: (FILE=1, TYPE=DISK: {'\\172.16.16.23\f\BackupKMISDb\TransactionLog\DMEDSC_akm_backup_2017_01_21_070141_4808028.trn'}). This is an informational message only. No user action is required.

After witch Sql Server restarts

Service broker intermitent problems with remote db

$
0
0
I am having an intermitent problem with service broker where the intiator's sys.transmission queue will fill up with outbound messages. I've looked at the transmission queue message status and it is blank on the sender's db. I've profiled the target db and i'm getting a duplicate message error.

When i run select get_transmission_status('93C9FBF6-F951-DE11-9F2F-0022198CADC8') with the conversation handle i get the following message back,
A previously existing connection with the same peer was found after DNS lookup. This connection will be closed. All traffic will be redirected to the previously existing connection. This is an informational message only. No user action is required. State 116.
Now i would assume that it should be restarting the tcp connection between the 2 servers and then sending the ack messages back to the sender without problem but it never does. The only way i've found to fix the problem is to restart the sql server service on the sender's machine which closes and reopens the tcp connection and the messages will continue to process. Does anyone have any suggestions on what I should try to do to prevent this in the future?
http://www.nootz.net

Transaction Count Oddity Within Activated Sprocs

$
0
0

Hello.

As I have been going through various scenarios in preparation of my code, I noticed that if I send a message to a queue with activation, the transaction count inside the sproc, before any code is run, is 2.

It is also 2  after I issue the BEGIN TRANSACTION; to RECEIVE the message(s), and 2 after I COMMIT before existing.  Same thing with XACT_STATE().

Now, the RECEIVE-ing is indeed affected by internal transactions, and a brute ROLLBACK does keep the message in the queue as well as disabling it.  The question is about the coding patterns everywhere - it appears that "if (@@trancount > 0) rollback transaction;" is useless (apart from ensuring the ROLLBACK is not an orphan) since one cannot count on the @@trancount as it is always >1, and would only work if there is NO code in the ELSE section of that "if (@@trancount > 0)".

I tested this by copying the code from the MS Lessons as is: SSSB Lessons(3), and just changed the activated sproc to create a trace:

CREATE or alter PROCEDURE TargetActivProc

...
  insert into dbo.debug_message(msg) values ('trancount='+cast(@@trancount as varchar)+'');


  WHILE (1=1)
  BEGIN
    BEGIN TRANSACTION;
    WAITFOR
    ( RECEIVE TOP(1)

....

    COMMIT TRANSACTION;
    --rollback TRANSACTION;
    insert into dbo.debug_message(msg) values
        ('trancount='+cast(@@trancount as varchar)+''),
      ('after commit...');
  END -- end while()
go

Although everything seems to be working in toy scenarios and I will be proceeding with my designs using SB, I am very uncomfortable with the situation since obviously, I am not understanding something.

Thanks for any help!!!

Rafael



SQL Server Service Broker not woking

$
0
0

Dear All,

I've created one table and SP need to execute to insert the getdate using service broker.

first time it'e working after that Service broker not working in my code. Server broker and trustworthy enabled on my test database.

Service broker need to be work on my same database.

Could any one please review the code and give your valuable feedback.

 

 

---------------------------- New ServiceBroker Creation  ------------------------------------------------

 

---------------------------------------------------- Step 1. Create the SP -------------------------------------------------------

 

CreateTable Test_Service_Broker2

(

  Input_Text                 varchar (255),

  Execution_Time            DateTime

)

 

gO

 

CREATE Procedure Test_Service_Broker_Sp

as

Begin

       DECLARE @Input_Text                 varchar (255)

 

      Insertinto Test_Service_Broker2

      Select'1',  Getdate()

End

go

 

---------------------------------------------- Step 2. Create the below Configuration Script for Service broker ---------------------------------

 

 

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

-- Configuring Service Broker

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

 

--Delete  FROM sys.service_message_types  WHERE name ='Test_Service_BrokerSendMessageType'

--Delete  FROM sys.service_message_types  WHERE name ='Test_Service_BrokerReceiveMessageType'

--Delete  FROM sys.service_contracts              WHERE name ='Test_Service_Broker_Contract'

--Delete  FROM sys.service_queues                 WHERE name ='Test_Service_Broker_QUEUE'

--Delete  FROM sys.services                       WHERE name ='Test_Service_Broker_SERVICE'

 

 

--SELECT 'X' FROM sys.service_queues WHERE name ='Test_Service_Broker_QUEUE'

 

-- Create a Type for Send Message type

IFNOTEXISTS(SELECT'X'FROMsys.service_message_typesWHERE name ='Test_Service2_BrokerSendMessageType')

BEGIN

      CREATEMESSAGE TYPE Test_Service2_BrokerSendMessageType

             VALIDATION= WELL_FORMED_XML;

END

GO

-- SELECT * FROM sys.service_message_types WHERE name ='Test_Service_BrokerSendMessageType'

      

-- Create a Type for Receive Message Type

IFNOTEXISTS(SELECT'X'FROMsys.service_message_typesWHERE name ='Test_Service2_BrokerReceiveMessageType')

BEGIN

      CREATEMESSAGE TYPE Test_Service2_BrokerReceiveMessageType

             VALIDATION= WELL_FORMED_XML;

      -- SELECT * FROM sys.service_message_types WHERE name ='Test_Service_BrokerReceiveMessageType'

END

GO

 

-- Create Contract to be used

-- you can use SENT BY ANY and use a single message instead

-- however for the sake of showing the contract functionality

-- i created two messsage types that can be sent by each

IFNOTEXISTS(SELECT'X'FROMsys.service_contractsWHERE name ='Test_Service2_Broker_Contract')

BEGIN

      CREATECONTRACT Test_Service2_Broker_Contract

      (

              Test_Service2_BrokerSendMessageType   SENTBY INITIATOR,

              Test_Service2_BrokerReceiveMessageTypeSENTBY TARGET

      )

 

      -- SELECT * FROM sys.service_contracts WHERE name ='Test_Service_Broker_Contract'

END

GO

 

-- Create a QUEUE

IFNOTEXISTS(SELECT 'X'FROMsys.service_queuesWHERE name ='Test_Service2_Broker_QUEUE')

BEGIN

      CREATEQUEUE Test_Service2_Broker_QUEUE

             WITHSTATUS=ON,

             ACTIVATION (

                     PROCEDURE_NAME= Test_Service_Broker_Sp,

                     MAX_QUEUE_READERS= 5,

                     ExecuteAS 'dbo');

END

GO

 

-- Create a Service to be used

IFNOTEXISTS(SELECT 'X'FROMsys.servicesWHERE name ='Test_Service2_Broker_SERVICE')

BEGIN

 

      CREATESERVICE Test_Service2_Broker_SERVICE

      ONQUEUE Test_Service2_Broker_QUEUE

      (

              Test_Service2_Broker_Contract

      )

END

GO

 

-------------------------------------------------   Step 3 : QUEUE_INITIATOR_SP   ---------------------------------------------------

 

CREATEPROCEDURE Test_Service2_Broker_QUEUE_INITIATOR_SP 

@GUID      UDD_GUID  

AS 

BEGIN 

  

      DECLARE @dialog_handle uniqueidentifier 

       

      BEGIN DIALOG CONVERSATION @dialog_handle 

   FROMSERVICE Test_Service2_Broker_SERVICE 

   TOSERVICE'Test_Service2_Broker_SERVICE' 

   ONCONTRACT Test_Service2_Broker_Contract

   WITHENCRYPTION= OFF; 

  

-- Now Sending a message note we are using 

-- SendMessageType since it is defined in the contract 

-- that it is to be sent only by initiater 

  

      SENDON CONVERSATION @dialog_handle 

      MESSAGETYPE Test_Service2_BrokerSendMessageType(@GUID)

      

        

 

      ENDCONVERSATION @dialog_handle

      WITH CLEANUP;

 

END  

 

-------------------------------------------------   Step 4: Test   ---------------------------------------------------

 

  Exec Test_Service2_Broker_QUEUE_INITIATOR_SP'GGGG'

  GO

 

  select*from Test_Service_Broker2

 Not working after executing this SP more than one time.

Thanks in Advance..

 


Service Broker Messsage Counts Misleading?

$
0
0

We have set up basic SQL Service Broker queues and are monitoring activity and we are finding it difficult to understand the messaging count activity.

EventsReceiveQueue receives messages from a source table via a trigger on that table.

EventsSendQueue then forwards the message to an external system for processing.

From our source we can place about 100k messages into the ReceiveQueue in about 1 minute. These messages flow through to the SendQueue quite quickly and the ReceiveQueue drops to a count of 0.

Then the funnny business starts. We can see the messages populating in the external system at a rate of about 1k per minute (the restrictin is the external system, this is known) the strange behaviour, and the reason for this post is that the count of messages stays fairly flat in the SendQueue until all messages reach the destination at which point the count dramatically falls to 0.

In the graph you can see this behaviour at 17:00 hours yesterday and 09:00 this morning.

Can anyone explain why the count of messages does not gradually reduce which is what we expected?

Many thanks,

John

p.s. we are using either 'select count (*) from queuename'  or the method described here http://blog.extreme-advice.com/2013/04/10/count-active-thread-for-service-broker-queue-in-sql-server/ to count the records.


Service Broker External Activator Service in Stopping State

$
0
0

SQL 2016 SP1 CU7 Enterprise, running on a fully-patched Windows Server 2016 VM hosted in Azure.

We have been using Service Broker and the External Activator service for years, mostly without incident. Recently, however, a problem has started.

The Service Broker External Activator service will go into a Stopping state from which it can't be re-started. The EATrace.log shows the error:

ERRORThe External Activator service is aborting ...
EXCEPTIONERROR = 90, Internal exceptions have occurred when External Activator is runtime checkpointing.
EXCEPTIONDETAILSInner Exception:
EXCEPTIONDETAILSSystem.IO.IOException: The process cannot access the file 'C:\Program Files\Service Broker\External Activator\log\EARecovery.rlog' because it is being used by another process.

The fix at this point has been to terminate the ssbeas.exe process. The service can then be re-started. We have been unable to determine the source of what other process is locking the EARecovery.rlog file, virus checker being the first place we looked but we couldn't find anything there or elsewhere.

As a temporary solution, we have created an alert to notify us when the service goes into the stopping state and then manually re-start the service as above. This condition is occurring inconsistently at intervals anywhere from hours to days.

The most recent occurrence of the problem had an extra wrinkle. After terminating the the ssbeas.exe process the external activator service would not re-start. In the EATrace.log we saw:

ERRORThe External Activator service is aborting ...
EXCEPTIONERROR = 54, The recovery log record is invalid: previous record of id 180667 does not exist.
INFOThe External Activator service is shutting down.

The solution at this point was to clear out the EARecovery.rlog file. After that, the service was successfully re-started.

Questions:
- Has anybody seen anything similar?
- What is the root cause of the EARecovery.rlog file being reported as locked by another process?
- What is the cuase of invalid record in the recovery log?


SqlDependency.OnChange fires with Sql statement but not calling a stored procedure

$
0
0

Hi all,

I don't understand why SqlDependency fires changes on DataBase if I specify a Sql stamente in the SqlCommand, but not if I specify a stored procedure.

My code:

CacheItemPolicy _policy = new CacheItemPolicy();
SqlChangeMonitor _monitor;
SqlDependency _dependency;

if (_connection.State == ConnectionState.Closed) _connection.Open();

/* This works! */
//SqlCommand _command = new SqlCommand("SELECT[LAST_UPDATE] FROM [dbo].[MY_TABLE] WHERE[ID] = " + _myId, _connection);

/* This NOT works! */
SqlCommand _command = new SqlCommand("[CACHE_CONTROLLER]" , _connection);
_command.CommandType = CommandType.StoredProcedure;
_command.Parameters.Add("@ID",SqlDbType.Int,4).Value= _myId;

_dependency = new SqlDependency(_command);
_monitor = new SqlChangeMonitor(_dependency);
_dependency.OnChange += _dependency_OnChange;

_policy.AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(600.0);

_policy.ChangeMonitors.Add(_monitor);
_policy.UpdateCallback = CacheUpdateCallback;

_cache.Set(key, elemento, _policy);

_command.ExecuteNonQuery();

The stored procedure:

alter proc [dbo].[CACHE_CONTROLLER]
@ID INT
as

SELECT [dbo].[MY_TABLE].[LAST_UPDATE] FROM [dbo].[MY_TABLE] WHERE [dbo].[MY_TABLE].[ID] = @ID

With the Sql statement bot UpdateCallback and OnChange are fired, using the stored procedure neither one or the other.

The stored contains only one statement as suggested in other posts, I ddon't use NOCOUNT clause...

Any idea?



Viewing all 461 articles
Browse latest View live


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