The SQL Server Service Broker For The Current Database Is Not Enabled, And As A Result Query Notifications Are Not Supported. Please Enable The Service Broker For This Database If You Wish To Use Notifications.
Feb 16, 2008
Hello,
I receive this error "The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications."
I attach the database in Management Studio to query and enable the broker using the scrip below but to no avail.
ALTER DATABASE DataName SET ENABLE_BROKER ‘''<<------successful
and
SELECT is_broker_enabled FROM sys.databases WHERE name = 'Database name' ‘'''<<-------value is 1
Global.asax
...
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
System.Data.SqlClient.SqlDependency.Start(ConfigurationManager.ConnectionStrings("dataConnectionString1").ConnectionString)
End Sub
...
Web.config
...
<connectionStrings>
<add name="dataConnectionString1" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|jbp_data.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
<add name="ASPNETDBConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
...
Hope you could help.
cheers,
imperialx
View 1 Replies
ADVERTISEMENT
Sep 11, 2006
Hey , I encountered a problem using SqlDependency and notification services.
I€™ve created a database with tools from c# Express 2005 and attached it to the sql server express 2005. And it turned out that €˜dependency_OnChange€™ in my application is triggered each time I execute the command.ExecuteReader(); and it shouldn€™t, because the command is just the select statement of columns and rows for which I wait to be modified.
SqlDependency dependency = new SqlDependency(command);
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
command.ExecuteReader();//when the program gets here dependency_OnChange is called
So I Used the example from here :
http://msdn2.microsoft.com/en-us/library/a52dhwx7.aspx
and with AdventureWorks it behaves as it should , but when I change the connection string and select statement in the example to work with MyDatabase, the problem appears again.
So there is something wrong with MyDatabase ?
The select statement I used was €œselect Name, Pass from Users where Name like €˜L%€™€?;
So theoretically this should work but it does not and I end up in an infinite loop with
dependency_OnChange called cyclically €¦
I€™d be grateful for any advice !
View 1 Replies
View Related
Nov 29, 2005
I backed up a database "Broker", and restored it on the same instance as "BrokerQA" (Broker db still exists, I need them both running on the same instance).
View 4 Replies
View Related
Dec 21, 2006
Hi All,
I am newbie in SQL Service broker. As we know, the is_broker_enabled can help us check whether the specified database is enabled for service broker. I would like to know
<>How can I enable servce broker for specified database if I see the value(is_broker_enabled) is 0?
<>How can I disable the service broker for specified database is I see the vlaue (is_broker_enabled) is 1? Do I need to dropped all service broker configration in the specified database?
Thanks in advance.
Michael
View 5 Replies
View Related
Sep 10, 2007
How to prevent the hang on the initator service broker if the target service broker is not started?
Our case has two service brokers (two databases), sometime, the target is need to turn off. But the sitation is the initator service broker (in fact, the message is sent from triggers) become hang, I want to prevent this case and continue to operation, and the messages should queue and will continue to send to target service broker when it startup. How should I do?
View 3 Replies
View Related
Dec 20, 2006
Hello,
I've been trying for two days now to get SQL Cache Dependencies to work. So far, nothing has worked, and I have been around the block a few times now on this one. So now I'm going back to basics, as I think my code and queries are fine. My first question is how to confirm that I have a Service Broker that is up and running. I am using SSX as my database engine. Other posts mention how the "look at the service broker folder", and I don't see a folder anywhere. Can someone tell me what to look for? I've added various SP's based on tutorials on web sites, so I can't tell if those SP's are mine or theirs at this point (I've been at this too long). Where is the "folder" the other posts have mentioned? Do I need to do anything special to get it? Did I install all the right files?
Mike
View 9 Replies
View Related
Feb 3, 2015
I had to restore a database in one of the staging servers the other day. However, upon completion, I found out that the service broker queue in the database is not working anymore. The service broker queue error was similiar to this error:
The activated proc dbo.procedure_name running on queue database_name.dbo.queue_name output the following: '<error message>.'
View 0 Replies
View Related
Aug 31, 2006
I'm having problems enabling service broker for DB Mail on a SQL 2005 cluster, when I try to execute this sql it just hangs. Any ideas?
USE master ;
GO
ALTER DATABASE AdventureWorks SET ENABLE_BROKER ;
GO
View 10 Replies
View Related
Jul 13, 2007
Hi,
I received an alert 'The SQL Server Service Broker or Database Mirroring transport is disabled or not configured'
How can I check the status of the two? and if they are disabled how do I enable them?
View 6 Replies
View Related
Jul 11, 2006
I'm trying to create a service broker on the same database...with one service and one queue. But my queue ends up with nothing in it. Here is the source...what's wrong?
Alter Database adventureworks set ENABLE_BROKER;
ALTER AUTHORIZATION ON DATABASE::[adventureworks] TO [SA];
create master key encryption by password = 'P@SSw0Rds';
CREATE MESSAGE TYPE CreateQBLetters VALIDATION = NONE
CREATE MESSAGE TYPE LetterResponse VALIDATION = NONE
CREATE CONTRACT BuildQBLetters (CreateQBLetters SENT BY INITIATOR, LetterResponse SENT BY TARGET)
CREATE QUEUE BuildLettersQueue with status=on
CREATE SERVICE CreateQBLetters ON QUEUE BuildLettersQueue
-- At this point, we can begin the conversation
DECLARE @conversationHandle UNIQUEIDENTIFIER
DECLARE @message NVARCHAR(max)
BEGIN
BEGIN TRANSACTION;
BEGIN DIALOG @conversationHandle
FROM SERVICE CreateQBLetters
TO SERVICE 'CreateQBLetters'
ON CONTRACT BuildQBLetters
-- Send a message on the conversation
SET @message = N'Hello World';
SEND ON CONVERSATION @conversationHandle MESSAGE TYPE CreateQBLetters (@message)
END CONVERSATION @conversationHandle
COMMIT TRANSACTION
END
GO
select * from sys.transmission_queue
select * from sys.conversation_endpoints
-- peek into the queue
select cast(message_body as nvarchar(max)) from BuildLettersQueue
GO
-- Receive a message from the queue
--RECEIVE CONVERT(nvarchar(max), message_body) AS message FROM BuildLettersQueue
-- Cleanup
DROP SERVICE CreateQBLetters
DROP QUEUE BuildLettersQueue
DROP CONTRACT BuildQBLetters
DROP MESSAGE TYPE CreateQBLetters
DROP MESSAGE TYPE LetterResponse
GO
-- you have to clean out the service broker first -- a conversation could be hanging around
alter database adventureworks set NEW_BROKER;
GO
DROP master key
go
View 3 Replies
View Related
Jul 24, 2006
I read the blog about service broker and database mirroring. Have you actually gotten this to work? I have a database that is mirrored. A third party vendor's software is using query notification which in turn uses service broker for dirty cache notification. Based on your blog I created a route specifying a mirror address.
CREATE ROUTE ServiceBrokerMirrorRoute AUTHORIZATION dbo
WITH SERVICE_NAME = 'http://schemas.microsoft.com/SQL/Notifications/QueryNotificationService', BROKER_INSTANCE = '70D4070D-C739-43B3-9167-7156209F87BA', ADDRESS = 'TCP://10.128.183.210:5100',
MIRROR_ADDRESS = 'TCP://10.128.183.211:5100'
And then I tried to ALTER DATABASE SET ENABLE_BROKER but it fails with a
Server: Msg 9778, Level 16, State 1, Line 1
Cannot create a new Service Broker in a mirrored database "mydatabase".
Server: Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
Is there an order to this should I have enabled servicebroker on the database and then mirrored it?
Any help would be appreciated!
View 1 Replies
View Related
Feb 15, 2008
I have a database that we have running service broker. Its a web based application hitting the database. Occasionally I need to restore the database in the development environment. Every time I trie to restore I have issues because there is a service broker connection. I have tried various commands to stop it, and usually after 20 minutes I finally get it to stop and not recreate itself.
Can anyone point me to an article or provide information on the best way to stop/prevent service broker so that you can restore a database?
View 4 Replies
View Related
Feb 29, 2008
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!
View 5 Replies
View Related
Feb 14, 2007
Hi
I tried to setup service broker to fail over to a mirror database. After the target database failed over, the message I send stays in sys.transmission_queue with no error in transmission_status. I check the mirror server log and I see the following.
An exception occurred while enqueueing a message in the target queue. Error: 15581, State: 3. Please create a master key in the database or open the master key in the session before performing this operation.
The database has the master key because its a mirrored database? Did I have to do something extra here
Paul
View 5 Replies
View Related
Apr 5, 2007
Hi,
I am struggling with the position SSB could take in an SOA. If I would want a broker in the general sense, meaning an intermediary sitting between applications which exchange information through messaging, would SSB be a good candidate? I know Biztalk is probably the primary candidate, but in my scenario I would end up with Biztalk apps with empty orchestrations. Also, I think Biztalk is more expensive to manage. So I am looking for a lightweight broker for a simple SOA targeted at application interoperability, no fancy business processes in sight.
I look forward to some responses.
Kind regards,
Neeva
View 2 Replies
View Related
Aug 29, 2007
For developers, we often have a need to backup a production database and restore it on local or integration machines. This production database is enabled for service broker and operates at a relatively high traffic level. When the database is backed up, the size is nearly 12GB; when SET NEW_BROKER is subsequently executed on the restored database, the size goes down to about 800MB. It appears that most of this is residing in the xmit queue. So, my question is: how best to backup a production database with queues activated, etc. without ending up with a 12GB backup?
Thanks.
View 3 Replies
View Related
Mar 28, 2006
Hello ,
I am wokring on an application where in I am migrating the legacy application to SQL server. for this when ever I make any changes to the legacy application,I immediately move this changes to SQL, using insert/delete/update to SQL.
I also want all these data on 2 to 3 other SQL servers which are on different remote machines. for this i thought of using the service broker to send the query as messages.
So on the initiator(where the legacy application reside), i create 2 to 3 queues(based upon number of receivers) and each time a query is successful on the initiator, i move these messages(queries) to the initiator queues and send them to the various targets. on the target i just pop these messages and execute them so that the query run on the all the targets and all my databases are in synch.
I need some info on various operations on the Service broker queues like:
1.How do i insert/update/delete from the queue.
2.Can i set some size constraint on the queue
3.Can i get the info like when the queue is full.
4.Can i set some custom flags on the queue like, queue is invalid or valid(setting and getting these falgvalues).
5.Clearing the entire queue.
These are the operations, i need on the queue for various use cases(failure cases)
Can you point to some documentation/tutorials whihc sheds more light on these queue operations.
Thanks,
View 1 Replies
View Related
Mar 30, 2007
I am trying to send a message between to SQL Server 2005 instances on two different machines. I have checked all my routes and all my objects appear to be setup correctly. However, when running Profiler on the target machine, I receive the "This message has been dropped because the TO service could not be found. Service name: "[tcp://mydomain.com/TARGET/MyService]". Message origin: "Transport". This is my activated stored procedure that is sending the message to the target service. I am using certificate security. Any help appreciated....
CREATE PROCEDURE [usp_ProcessMessage]
AS
BEGIN
SET NOCOUNT ON;
DECLARE @conversation_handle uniqueidentifier
DECLARE @message_body AS VARBINARY(MAX)
WHILE (1=1)
BEGIN
BEGIN TRANSACTION;
WAITFOR(RECEIVE TOP (1)
@conversation_handle = conversation_handle,
@message_body = message_body
FROM [tcp://mydomain.com/INITIATE/MyQueue]
), TIMEOUT 1000;
IF (@@ROWCOUNT = 0)
BEGIN
COMMIT;
BREAK;
END
END CONVERSATION @conversation_handle
IF @message_body IS NOT NULL
BEGIN
BEGIN DIALOG CONVERSATION @conversation_handle
FROM SERVICE [tcp://mydomain.com/INITIATE/MyService]
TO SERVICE '[tcp://mydomain.com/TARGET/MyService]'
ON CONTRACT [tcp://mydomain.com/INITIATE/MyMessage/v1.0]
WITH ENCRYPTION = ON, LIFETIME = 600;
SEND ON CONVERSATION @conversation_handle
MESSAGE TYPE [tcp://mydomain.com/TARGET/VisitMessage]
(@message_body);
END
COMMIT;
END
END
GO
My endpoints are created like so:
CREATE ENDPOINT MyEndpoint
STATE = STARTED
AS TCP
(
LISTENER_PORT = 4022
)
FOR SERVICE_BROKER (AUTHENTICATION = CERTIFICATE MasterCertificate)
GO
GRANT CONNECT TO CertOwner
GRANT CONNECT ON ENDPOINT::MyEndpoint TO CertOwner
GO
And my routes like so:
GRANT SEND ON SERVICE::[tcp://mydomain.com/INITIATE/MyService] TO CertOwner
GO
CREATE REMOTE SERVICE BINDING [MyCertificateBinding]
TO SERVICE '[tcp://mydomain.com/TARGET/MyService]'
WITH USER = CertOwner,
ANONYMOUS=OFF
CREATE ROUTE [tcp://mydomain.com/INITIATE/MyRoute]
WITH SERVICE_NAME = '[tcp://mydomain.com/TARGET/MyService]',
BROKER_INSTANCE = N'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
ADDRESS = N'TCP://xxx.xx.xx.xx:4022'
GO
View 10 Replies
View Related
Apr 16, 2008
Here's the scenario -
We had issues with our production database which had 'broker enabled', I restored an older backup and then renamed the Prod database to ProdOld and the Backup database to Prod. We noticed yesterday that the broker service wasn't working and had the error
'The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications.
'
I ran the following script against the database
ALTER DATABASE prod SET ENABLE_BROKER
go
GRANT CREATE PROCEDURE to User
GRANT CREATE QUEUE to User
GRANT CREATE SERVICE to User
GRANT REFERENCES on CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification] to User
GRANT VIEW DEFINITION to User
And it came back with a message that the broker was already enabled.
I did a disable/enable just for kicks, but we still get the same error message.
I did a check on the sys.databases table and it shows that the 'is_broker_enabled' field set = 0 (should be one)
Any ideas on what's going on here? Could the rename caused the broker to become out of sync?
It would be great if I could just update the bit field, but I don't believe there is an easy way of updatting the system tables.
Thanks in advance
View 3 Replies
View Related
Apr 13, 2006
My database is logging frequent errors and I am unable to determine the cause. These errors appear to be related to the Service Broker. Below is the database log file after a database restart and attempted access to the database through a web application. The first error (bottom of the logfile) is error 28054. I have searched on this error code and have found nothing helpful. Any assistance or direction would be greatly appreciated.
Database Log:
04/13/2006 12:26:05,spid22s,Unknown,An error occurred in the service broker message dispatcher<c/> Error: 15517 State: 1.
04/13/2006 12:26:05,spid22s,Unknown,Error: 9644<c/> Severity: 16<c/> State: 14.
04/13/2006 12:26:04,spid57s,Unknown,The activated proc [dbo].[SqlQueryNotificationStoredProcedure-aa148e0f-2980-4a23-b9cf-b44dbfddf783] running on queue CDR.dbo.SqlQueryNotificationService-aa148e0f-2980-4a23-b9cf-b44dbfddf783 output the following: 'Cannot execute as the database principal because the principal "dbo" does not exist<c/> this type of principal cannot be impersonated<c/> or you do not have permission.'
04/13/2006 12:26:01,spid22s,Unknown,An error occurred in the service broker message dispatcher<c/> Error: 15517 State: 1.
04/13/2006 12:26:01,spid22s,Unknown,Error: 9644<c/> Severity: 16<c/> State: 14.
04/13/2006 12:26:01,spid56s,Unknown,The activated proc [dbo].[SqlQueryNotificationStoredProcedure-aa148e0f-2980-4a23-b9cf-b44dbfddf783] running on queue CDR.dbo.SqlQueryNotificationService-aa148e0f-2980-4a23-b9cf-b44dbfddf783 output the following: 'Cannot execute as the database principal because the principal "dbo" does not exist<c/> this type of principal cannot be impersonated<c/> or you do not have permission.'
04/13/2006 12:26:01,spid56s,Unknown,The activated proc [dbo].[SqlQueryNotificationStoredProcedure-aa148e0f-2980-4a23-b9cf-b44dbfddf783] running on queue CDR.dbo.SqlQueryNotificationService-aa148e0f-2980-4a23-b9cf-b44dbfddf783 output the following: 'Cannot execute as the database principal because the principal "dbo" does not exist<c/> this type of principal cannot be impersonated<c/> or you do not have permission.'
04/13/2006 12:26:01,spid56s,Unknown,The activated proc [dbo].[SqlQueryNotificationStoredProcedure-aa148e0f-2980-4a23-b9cf-b44dbfddf783] running on queue CDR.dbo.SqlQueryNotificationService-aa148e0f-2980-4a23-b9cf-b44dbfddf783 output the following: 'Cannot execute as the database principal because the principal "dbo" does not exist<c/> this type of principal cannot be impersonated<c/> or you do not have permission.'
04/13/2006 12:26:01,spid52,Unknown,Service Broker needs to access the master key in the database 'CDR'. Error code:25. The master key has to exist and the service master key encryption is required.
04/13/2006 12:26:01,spid52,Unknown,Error: 28054<c/> Severity: 11<c/> State: 1.
View 6 Replies
View Related
Apr 13, 2006
Hi everybody
Error [364] The Messenger service has not been started - NetSend notifications wi
I am having this error from agent. Does anybody have any idea what this error means or is it sevear or not?
Thank you
asa.:)
View 3 Replies
View Related
May 10, 2006
Hi!
Just set up my first Service Broker test. Wanted to send an Event Notification from one instance to another. Finally, the message arrives but profiler shows that the message is still being continously resent (and rejected as being duplicate). What am I doing wrong?
With best regards,
Artus
--
/* Local Event Source.sql */
USE master
GO
CREATE DATABASE NotificationDB
GO
ALTER DATABASE NotificationDB SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;
GO
CREATE ENDPOINT BrokerEndpoint
STATE = STARTED
AS TCP
(
LISTENER_PORT = 5554
)
FOR SERVICE_BROKER
(
AUTHENTICATION = WINDOWS,
ENCRYPTION = DISABLED
)
GO
USE NotificationDB
GO
CREATE EVENT NOTIFICATION TestEN
ON DATABASE
FOR CREATE_TABLE
TO SERVICE 'ExpressService', 'AFEDD339-AD3D-4865-AF3C-299B0A0784C6'
GO
CREATE ROUTE ExpressRoute
WITH SERVICE_NAME = 'ExpressService' ,
BROKER_INSTANCE = 'AFEDD339-AD3D-4865-AF3C-299B0A0784C6',
ADDRESS = 'TCP://localhost:5555'
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Pa$$w0rd';
GO
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY;
GO
USE master
GO
SELECT service_broker_guid FROM sys.databases WHERE database_id = DB_ID()
GO
/* Remote Service.sql */
USE master
GO
CREATE DATABASE Test
GO
ALTER DATABASE Test SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;
GO
CREATE ENDPOINT BrokerEndpoint
STATE = STARTED
AS TCP
(
LISTENER_PORT = 5555
)
FOR SERVICE_BROKER
(
AUTHENTICATION = WINDOWS,
ENCRYPTION = DISABLED
)
GO
USE Test
GO
CREATE QUEUE ExpressQueue
WITH STATUS = ON
GO
CREATE SERVICE ExpressService
ON QUEUE ExpressQueue
(
[http://schemas.microsoft.com/SQL/Notifications/PostEventNotification]
);
GO
GRANT SEND ON SERVICE::ExpressService
TO [public]
GO
CREATE ROUTE ExpressServiceRoute
WITH SERVICE_NAME = 'ExpressService',
BROKER_INSTANCE = 'AFEDD339-AD3D-4865-AF3C-299B0A0784C6',
ADDRESS = 'LOCAL'
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Pa$$w0rd';
GO
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY;
GO
SELECT service_broker_guid FROM sys.databases WHERE database_id = DB_ID()
GO
SELECT * FROM sys.endpoints
GO
View 3 Replies
View Related
Nov 18, 2005
I'm trying to set up Service Broker Services on SQL 2005 x86. I've got two services set up, and a stored procedure associated with one of them.
View 3 Replies
View Related
Jun 19, 2005
Can't believe no one has commented on this in here yet. If you're into SQL Server Service Broker (and you are if you are reading this forum), you must go over and take Rushi's Service Broker Challange.
View 1 Replies
View Related
Jul 17, 2005
Recently there has been questions on some of the newsgroups about examples for SQL Server Service Broker. So, yesterday on a flight back to England I crofted up three different SQL Server projects as examples: LocalSampleRemoteSampleServer1RemoteSampleServer2
All three examples are jus your very basic €œHello World€? example, but they show: LocalSample €“ communication between two databases on the same SQL server instance. MasterKeys in a database and the database being TrustWorthyRemoteSampleServerX €“ These two samples are meant to run on two different machines/instances and in the samples you set up both transport security and dialog security by using Certificates.
Download the zip file from here [0], unzip and read the README.txt file, and €“ Have Fun!!
[0] : http://staff.develop.com/nielsb/code/servicebrokerexamples.zip
View 6 Replies
View Related
Jul 23, 2007
Does SQL SVR 2005 Service Broker use connection pooling?
We are building a laptop application that will use SB to send messsages
to one SQL SVR 2005 instance. SQL 2005 Express will be installed on
each laptop and will be the "sender" to one SQL SVR instance, the "receipient"
It will be deployed to over 1500+ laptops. Each laptop will have a different
IP address.
Our SQLDBA wants to know if each of the laptops will use a different
connection when sending messages?
I answered "Yes", but another team member said "No".
What is the correct answer?
View 7 Replies
View Related
Mar 12, 2007
Hi,
SQL Server 2005 SP1. (+ 5 minutes fix installed).
Query notification subscription cretaed (sys.dm_qn_subscriptions).
Subscription does not fire in response to event.
sys.transmission_queue is empty.
profiler does not show errors.
sys.conversation_endpoints shows one endpoint in status SO. (along with a lot of left over garbage - about 300K records - but this should not be a problem other than storage).
I know SP2 is suppose to solve the garbage records problem but this is not our problem. This setup was working and then just stoped.
any ideas ?
Boaz
View 7 Replies
View Related
Oct 23, 2006
helloi use Visual Web Developer and SQL server 2005 express , how can i enable service borker of my sql server ?thaks for any helpderin
View 1 Replies
View Related
Jul 14, 2006
I have configured a non-SQL linked server (via an OLE DB provider) and I wish to insert data into it via Service Broker but I am getting the following error in the SQL Server log:
The activated proc [dbo].[sp_ mytableServiceProgram] running on queue TestDB.dbo.mytableQueue output the following: 'Cannot promote the transaction to a distributed transaction because there is an active save point in this transaction.'
As you see below, my strored proc. is not issuing any 'save trans' statements, so why is it not allowing me to wrap my code in a transaction? How else can I use a transaction (in order to not lose anything from the queue) and yet still be able to insert to the linked server?
CREATE PROC sp_mytableServiceProgram
AS
SET NOCOUNT ON;
DECLARE
@XML XML,
@MessageBody VARBINARY(MAX),
@MessageTypeName nvarchar(256),
@Dialog UNIQUEIDENTIFIER;
-- This procedure continues to process messages in the queue until the
-- queue is empty.
WHILE (1 = 1)
BEGIN
BEGIN TRANSACTION;
--BEGIN DISTRIBUTED TRANSACTION; --Tried this but didn't help.
-- Receive the next available message
WAITFOR (
RECEIVE TOP(1) -- just handle one message at a time
@MessageTypeName = message_type_name,
@MessageBody = message_body,
@Dialog = conversation_handle
FROM mytableQueue
), TIMEOUT 2000 ;
-- If RECEIVE did not return a message, roll back the transaction
-- and break out of the while loop, exiting the procedure.
IF (@@ROWCOUNT = 0)
BEGIN
ROLLBACK TRANSACTION;
BREAK;
END ;
SET @XML = CAST(@MessageBody AS XML);
INSERT INTO LINKEDSERVER.dbname.user.mytable
SELECT tbl.rows.value('@doc_no', 'INT') AS doc_no,
tbl.rows.value('@queryid', 'NVARCHAR(50)') AS queryid,
tbl.rows.value('@ar_num', 'NVARCHAR(50)') AS ar_num,
tbl.rows.value('@status', 'NVARCHAR(20)') AS status,
tbl.rows.value('@creationtime', 'DATETIME') AS creationtime,
tbl.rows.value('@note', 'NVARCHAR(250)') AS note,
tbl.rows.value('@posted', 'NCHAR(1)') AS posted,
tbl.rows.value('@kms', 'INT') AS kms,
tbl.rows.value('@schresid', 'NVARCHAR(50)') AS schresid,
tbl.rows.value('@resolution_code', 'NCHAR(8)') AS resolution_code,
tbl.rows.value('@page_count', 'INT') AS page_count,
tbl.rows.value('@new_serial_number', 'NVARCHAR(20)') AS new_serial_number,
tbl.rows.value('@taskresolution', 'NVARCHAR(250)') AS taskresolution
FROM @XML.nodes('/inserted') tbl(rows);
-- If the INSERT did not insert any rows, rollback.
IF @@ROWCOUNT = 0
BEGIN
ROLLBACK TRANSACTION;
BREAK;
END
COMMIT TRANSACTION;
END
GO
View 8 Replies
View Related
Sep 7, 2006
I have an application that is reading a message from a Service Broker Queue. When I use integrated security with an NT account it works fine. When I use a SQL Server User through Management Studio I can select from the Queue however, when I use this same account through the web app with the SQL Server User, I cannot see the Queue. Is there a grant that I must do to this account to get it to see the Service Broker Objects?
Gary
View 2 Replies
View Related
Apr 26, 2006
Hi,
I have installed sql server standard edition 2005.I want to enable service broker feature or services after intalling the sql server.Please let me known any tool or utiltiy to enable the feature
Alter datatabase set enable_broker is not working.
Its giving syntax error
Thanks
View 1 Replies
View Related
May 2, 2006
I am writting a huge Service Broker Application. I notice that each message that is processed appears in the SQL Server Logs. Currently I am just testing with a single queue and tons of messages are showing up in the log. Is there a way that I can turn these informational messages off? I think in the end I may have something like 15 or 20 queues. These messages are very useful for debugging but I may not desire this extensive logging to be running all the time on all of my queues.
Gary
View 4 Replies
View Related
Sep 26, 2007
I am doing some research to see if the Service Broker technology would help my company with our Enterprise application. Here is our scenario: We have a 3 tier system. The first tier needs to contact the second tier asynchronously. Hence, using queues is a good option. However, the process that needs to happen on the second tier is mostly process intensive with little database updates. Is it still worth our time to use Service Broker?
I like the concept of Activation that Service Broker provides. But, from what I am reading most of the documentation describes activation as a way to call another stored proc. I definitely dont' want to do any process intensive work on the SQL server. So here comes my question...
How would I use a windows service to listen to the activation event from the Service Broker. I could have multiple windows services watching the same queue (scalable). Would I have to handle collisions myself? If so, I think I would rather keep it simple, and just use a simple table as my queue.
Thanks for your comments in advance...
Vijay.
View 3 Replies
View Related