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

Delete sys.Transmission_Queue

$
0
0

I have seen this buried deep with the questions on Service Broker, but I am looking for it again.  How do you delete all records from your sys.Transmission_Queue.  This is on a test server and I want to clean it before some more test.

 

 


sql service broker asynchronous

$
0
0

I have a SB set up that is a Fire and Forget setup, the problem I have is that it seems to be filling up TEMPDB. I see that many people have this setup without this issue.

I understand why TEMPDB is filling up but how do I prevent this without changing to a synchronous process. Currently conversations are not ending properly and the code in the target is using with cleanup.(Not my code).

As the initiator is not available the target cannot close off the end points, these are left open and eventually will be flushed from memory to TEMPDB. Remaining there until the SQL service is restarted.

I am using a trigger to kick off the initiator. How do other async processes cope with this.

Should with cleanup take care of this????

service broker activation store procedure don't run when send a message to queue

$
0
0

I want to build async triggers with service broker, and in trigger, we send message to queue, and there's a activated sp for that queue, but when send a message, the sp don't run. please help.

1.I already enable the broker, and set TRUSTWORTHY ON.

2.below is my queue info, I tried to use owner,'dbo',self,doesn't work.

CREATE QUEUE dbo.SPITargetQueue
WITH STATUS=ON,
ACTIVATION (STATUS = ON,
MAX_QUEUE_READERS = 1,
PROCEDURE_NAME = dbo.querySPI,  
EXECUTE AS owner)

the sp will only receive the message and insert into the another test table, I manually run it after send a message, it's ok.

3.below is meg from sys.dm_broker_queue_monitors and sys.service_queues table.
    select q.name,m.state,m.tasks_waiting,q.activation_procedure,q.is_activation_enabled,q.execute_as_principal_id
    from sys.dm_broker_queue_monitors m join sys.service_queues q
    on m.queue_id=q.object_id

    name                |state       |tasks_waiting |activation_procedure | is_activation_enabled |execute_as_principal_id
    SPITargetQueue |INACTIVE |0                   |[dbo].[querySPI]       | 1                             |-2


4.and there's nothing in sys.dm_broker_activated_tasks table.


Do I need to set up other db property?
my first time to use service broker and please help solve this, thanks in advance.

 

 

Queue on server Level(queue messages from multiple databases in one queue)

$
0
0

hello everyone,

i want to gather queue of messages from multiple databases in one queue(using service broker) 

so i create empty database containing the queue that receive the message from other databases 

i wanted to know whether i can use another technique in order to in-queue messages from multiple databases in one place

Basic Q's about Service Broker: May a SQL update a message? How to select for view the message queue? What to do with unable to be completed messages?

$
0
0

This week I was informed of the presence of Service Broker within SQL Server. I need to build an Agent Server to create asynchronous messaging capabilities for a Client/Server application I am the architect / application developer for. I have some basic questions bridging the vision I have already in mind, and seeking the correct Service Broker term / capability to map each to. I have worked with several SQL based message queue implementations in the past.

1) May a SQL update a message?

I was intending on creating a "status" column in my queue table. Messages when created (SQL INSERT) would have a value of "new" for the status column. When the Agent Server wakes up to process requests in category "xyz" it does a SELECT for "[status] = 'new'". During the course of working on the request, the request might not be completable. In that case, the "status" column would get changed - let's say to 'error'. Thus subsequent SELECT SQL statements would no longer detect the same message.

Failed messages would simply stay in the queue for traceability. Some sort of purge process would remove messages older than n-days.

This brings me to the next question...

2) How to select for view the message queue?

Is there some way to SELECT for display all of the messages in the queue, no matter what type of message? I envision for the admin interface to the Agent Server, this being an important tool to leave in the client admin's hands.

3) What to do with unable to be completed messages?

Like I already hinted at... what happens if a message in the queue is not able to be completed for some reason? With Service Broker must the "bad" message be removed from the queue to not get reprocessed?

I think answers to these questions will provide a good start to furthering my investigation of Service Broker. Thank you!

Sincerely,

Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/


How to set is_receive_enabled and is_enqueue_enabled from 1 to 0.

$
0
0

Hi All,

I used service broker activation in my receive queue (SQL 2005 SP1). However, it seems the stored procedure does not work after the receive queue get message. I saw the following error in SQL Error log.

"The activated proc [dbo].[Mystoredpro] running on queue test2.dbo.ReceiveQ output the following:  'The service queue "ReceiveQ" is currently disabled.'"

Then I checked the queue in sys.service_queues and noticed is_receive_enabled and is_enqueue_enabled is 0 but not 1 (is_activation_enabled is 1, which is normal). I believe this is the cause of my service broker activation issue.

According to this link:

http://www.eggheadcafe.com/aspnet_answers/SQLServerservicebroker/May2006/post26788966.asp

I tried to use ALTER QUEUE ... WITH STATUS = ON  command to set the above value back to 1, it does not work the value persists 0.  Any idea?

Thanks in advance.

Michael

 

 

CONVERSATION TIMER SHOW

$
0
0

I have created conversation timer:

DECLARE @DialogHandle UNIQUEIDENTIFIER;

BEGIN dialog CONVERSATION @DialogHandle 
FROM SERVICE myService
TO SERVICE  'myService'
ON CONTRACT [DEFAULT]
WITH ENCRYPTION = OFF;

BEGIN CONVERSATION TIMER (@DialogHandle) TIMEOUT = 7200;

That means that after 2 hours message will be delivered into my queue.
Where can I see which timers are active and when they will deliver the messages.

I can see the timers here:

SELECT * FROM sys.conversation_endpoints WHERE far_service='myService'

But there is no data about when this endpoint was started nor when timer will timeout and deliver the message.
Here is only dialog_timer date and lifetime date which are some different values.

thanks,

Simon

How count function executes in SQL Server

$
0
0

Hello all,

I have a table, schema for the table has been shown below:

Create Table Employee(

EmployeeID int NOT NULL,EmployeeName varchar(255) NOT NULL,JoinDate datetime Not NULL)

Index Structure:

Clustered Index on EmployeeID

Non-Clustered Index on EmployeName

I am execution a T-SQL query that is :

select count(*) from Employee

During the execution of this query which index will be used any why?

Thanks in advance


Pankaj Kumar Yadav-


SQL Service Broker 2012: the connection was closed by the remote end, or an error occurred while receiving data: '64(The specified network name is no longer available.)'

$
0
0

Anyone can help with the below issue please? Much appreciated.

  1. We have about 2k+ messages in sys.transmission_queue
  2. Telnet to the ports 4022 is working fine.
  3. Network connectivity has been ruled out.
  4. The firewalls are OFF.
  5. We also explicitly provided the permissions to the service account on Server A and Server B to the Service broker end points.GRANTCONNECTON ENDPOINT <broker> <domain\serviceaccount>
  6. Currently for troubleshooting purposes, the DR node is also out of the Availability Group, which means that we right now have only one replica the server is now a traditional cluster.

Important thing to note is when a SQL Server service is restarted, all the messages in the sys.transmission queue is cleared immediately. After about 30-40 minutes, the errors are continued to be seen with the below

Theconnectionwas closedbytheremoteend,oran erroroccurredwhilereceivingdata: '64(The specified network name is no longer available.)'

Failed to verify Authenticode signature on DLL msxmlsql.dll

$
0
0

Hello, I got this error message. The server is experiencing issue of service broker suddenly stopping, so we are ruling out all errors at this point. Server is setup with HADR.

Win Server 2008 R2 Ent SP1

SQL 2012 11.0.3349 Ent

Log Name:      Application
Source:        MSSQL$SQL01
Date:          4/18/2013 7:17:26 AM
Event ID:      33081
Task Category: Server
Level:         Information
Keywords:      Classic
User:          N/A
Computer:      SQL01.xxxxxx.xxx
Description:
Failed to verify Authenticode signature on DLL 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQL01\MSSQL\Binn\msxmlsql.dll'.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="MSSQL$SQL01" />
    <EventID Qualifiers="16384">33081</EventID>
    <Level>4</Level>
    <Task>2</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2013-04-18T11:17:26.000000000Z" />
    <EventRecordID>28935</EventRecordID>
    <Channel>Application</Channel>
    <Computer>SQL01.xxxxxx.xxx</Computer>
    <Security />
  </System>
  <EventData>
    <Data>C:\Program Files\Microsoft SQL Server\MSSQL11.SQL01\MSSQL\Binn\msxmlsql.dll</Data>
    <Binary>398100000A0000000F000000500052004F004400530051004C0031005C0043004F00530051004C000000040000004F006E0065000000</Binary>
  </EventData>
</Event>

Thanks.

2008 R2 security question

$
0
0

<p>I am having a devil of a time trying to get service broker working. My user has db_owner rights on two databases within the same instance. I do not have sysadmin privileges but can get them if needed. I have setup SB using 2005 successfully using different instances and now am perplexed when having these issues. before I go the 'sa' route I would like to know if setting everything up using the sysadmin priv and using&nbsp;'execute as owner' on Activation procedure would alleviate my pain. I have tried everything I can think of. I shouldn't have to setup endpoints and such since this is internal to the instance, correct? If I run through everything in the tutorial as is in this instance <em>I get this.

This message could not be delivered because the targeted service does not support the service contract. Targeted service: '//ProCred_DB/CME_UpdHoursTargetService', service contract: '//UpdateCMEHours/CMEUpdateHoursContract'.</p>

BEGIN DIALOG @InitDlgHandle
     FROM SERVICE [//CME_DB/CME_UpdHoursInitService]
     TO SERVICE N'//ProCred_DB/CME_UpdHoursTargetService', '10C4F502-5912-4EED-BE52-CA4D28BF0044'
     ON CONTRACT [//UpdateCMEHours/CMEUpdateHoursContract]
     WITH ENCRYPTION = OFF;


JC

No enabled application monitor is on behalf of queue...

$
0
0
Hello,

I am trying to set up external activation, and the external application doesn't ever seem to be launched.  I get the following error, which shows up in the EATrace.log:


EXCEPTION    ERROR = 32, No enabled application monitor is on behalf of queue [my target queue name].


Any ideas where I should be looking to find the source of the problem?  I'm not sure what it means by 'no enabled application monitor...'

Thanks in advance.

How to reuse service broker conversation handle in trigger

$
0
0

in my trigger, i get data from inserted table and send it to targetQueue.
There's a targetProc configured for that queue, in this sp, it get data from queue and do something and then end conversation.
And then a message sent back to initQueue, i have a cleanProc for this queue, this sp only receive message from initQueue and end conversation.

It will take some time and resource when generate GUID, I think it's not a good idea to generate it each time in trigger, so how can I reuse conversation handle in trigger ? Can anyone help me? Thanks a lot in advance.

i found some article about reuse conversation handle, and it's associated to @@SPID, and is this ok for trigger, and do I need to end conversation in targetProc and cleanProc ?

please give some detail message, i'm very new for this. thanks again.

Service broker cross instances (to different databases)

$
0
0

Hi all,

I am creating a service broker application for a cross instance/server communication. I have been working with Service broker for sometime and I am a little comfortable. my service broker is working for the same instance (different databases messaging)

BUT what I am trying to is send a message from Server 1 to server 2. I have this working using dialog security and necessary service broker objects. Though, what I am trying to do is send a message from [Server 1 database 1] to [server 2 database 1 and database 2 ~ same instance].

i created necessary certificate on [Server 1 database  1] and [Server 2 database 1] and exchanged them  then created all service broker objects. When I send a message from [Server 1 database 1] to [Server 2 database 1] everything works perfect.

BUT,

when i try to also send a message from [server 1 database 1] to [server 2 database 2] (after creating a certificate on the new database and exchange them, the messages will not be send and i see an error in the SQL profile : certificate not found (this error is on server 2 database 2).

Just to give more info, I have the same service name on server 2 database 1 & 2 ...

Your help will be much appreciated specially after spending 2 weeks on this :( 

Regards,

 

Why I cannot see messages?

$
0
0

Hello,

Why I cannot see messages on MorilloReceivingQueue? Please see the following script:

USE [master];

GO

IFEXISTS(SELECT *FROMsys.databasesWHERE [name] = 'ColasDB')

  DROPDATABASE [ColasDB]

GO

CREATEDATABASE [ColasDB]

GO

ALTERDATABASE [ColasDB] SETTRUSTWORTHYON

GO

ALTERDATABASE [ColasDB] SETenable_broker

GO

USE [ColasDB];

GO

CREATEMASTERKEY ENCRYPTIONBYPASSWORD='P@ssw0rd';

CREATEMESSAGETYPE MorilloMessage

VALIDATION=WELL_FORMED_XML;

CREATECONTRACT MorilloContract

(MorilloMessageSENTBY ANY);

-- SENT BY INITIATOR

-- SENT BY TARGET

CREATEQUEUE MorilloSendingQueue

WITH

STATUS=ON

,RETENTION=OFF;

CREATEQUEUE MorilloReceivingQueue

WITH

STATUS=ON

,RETENTION=OFF;

CREATESERVICE MorilloSendingService

ONQUEUE MorilloSendingQueue

(MorilloContract);

CREATESERVICE MorilloReceivingService

ONQUEUE MorilloReceivingQueue

(MorilloContract);

CREATEROUTE MorilloRoute

WITH

SERVICE_NAME='MorilloReceivingService',

ADDRESS='LOCAL'

DECLARE @handleuniqueidentifier

BEGIN DIALOGCONVERSATION @handle

FROMSERVICE MorilloSendingService

TOSERVICE'MorilloReceivingService'

ONCONTRACT MorilloContract WITHENCRYPTION=OFF;

SENDONCONVERSATION @handle

MESSAGETYPE MorilloMessage

('<message>Hola </message>')

ENDCONVERSATION @handle WITH CLEANUP;

SELECT*FROM MorilloReceivingQueue;


Thank you in advance.

Regards,
Alberto Morillo
SQLCoffee.com



activation stops working after a cluster failover

$
0
0

Hi All, 

I'm running into a problem with SSB on 

Microsoft SQL Server 2008 (SP1) - 10.0.2841.0 (X64) 
May 13 2011 12:08:08 
Copyright (c) 1988-2008 Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.0 <X64> (Build 6002: Service Pack 2)

after a cluster failover, activation doesn't work. Queues build up until I turn activation off and back on. Is this a bug or a feature?


Mordechai Danielov

The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.

$
0
0

Hi Friends

I'm using


selecT

tt ,cast(start_timeasdatetime) from Call_logDetails

and getting error;

Msg 242, Level 16, State 3, Line 1

The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.

Please help me to resolve this problem.

Check if service broker service exists?

$
0
0

Hi

I need to code creating a service broker service.

How can i check if the service broker service exists before trying to create it? 

via T-SQL or C#

Service Broker - sys.conversation_endpoints climbing higher

$
0
0
Hello everyone.  Hope you are all having a great Friday.

Earlier this week I noticed that the number of items in the sys.conversation_endpoints table for our databases is getting rather large.  1-2million records depending upon the database.  What I cannot figure out is why.  

To start with, here is the counts from the sys.conversation_endpoints table:

StateTOTAL
Total- 1217855
CONVERSING - 1191883
DISCONNECTED_INBOUND - 25407
CLOSED - 547
STARTED_OUTBOUND - 18

Now, as it shows above, there is A LOT of messages in a CONVERSING state.  I cannot figure out why.  The maximum number of messages in any one of 7 queues we have is just under 300, and the majority are at 0 messages sitting in the queue.  BOL states that the CONVERSING state is: 

"Conversing. The conversation is established, and both sides of the conversation may send messages. Most of the communication for a typical service takes place when the conversation is in this state."

However, I don't see where we have 1.2 million conversations happening.

In looking around, I found an article by Remus Rusanu about "fire and forget" found here:  Fire and Forget: Good for the Military, but no for Service Broker Conversations.  However, it doesn't look like in our system, this is the method we are following.

Here is a general setup for our system.

To send a message, we use the following code:

BEGIN DIALOG CONVERSATION @ConversationHandle
      FROM SERVICE CompEngineService
      TO SERVICE 'CompEngineService'
      ON CONTRACT CompEngineContract;

SEND ON CONVERSATION @ConversationHandle 
      MESSAGE TYPE CompEngineMessageType(@TaskMessage)

We use SB to call a stored procedure on the other side of the convesation.  So each of the conversations use an activation stored procedure.  Those procedures look like this:

DECLARE     @TaskMessage xml
      DECLARE @Conversation_Handle uniqueIdentifier

      BEGIN TRY                           
            WAITFOR (RECEIVE top(1) @TaskMessage = Message_body
                              , @Conversation_Handle = conversation_handle
                        FROM  [GenericProcessQueue]
                        ), TIMEOUT 10000

            if @@RowCount = 0 OR @taskMessage is null
                  return
            
            <<< Fun logic goes here >>>
            end conversation @conversation_handle
      END TRY
      BEGIN CATCH<< LOG Conversation and Task Message to error table >>
          END CONVERSATION @Conversation_handle

            IF @@TRANCOUNT > 0

            BEGIN
                  ROLLBACK TRAN

            END
      END CATCH


Does anyone have a clue as to what I am missing here.  When I test the code individually, everything seems to be working as expected and all messages in the sys.conversation_endpoints system finish in a CLOSED state.

Running SQL 2005 SP4 64 bit on 2003 window server machines.

Thanks,

Fraggle

Service Broker

$
0
0
I have some requirement in which I have to send data to the sever in CRUD operation performed in any of the tables in the database. I want to send the updated data into server and update the corresponding table. After searching a lot, I found that all are  suggesting that to use service broker in sql server. But I am not able to find out the proper procedure to do that. How can I do ? 

S.K. Satpathy

Viewing all 461 articles
Browse latest View live


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