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.
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?
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 ‘''<<------successfulandSELECT 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
My company has a system where we have a mirrored server and multiple clients communicating with that server using service broker. Up until now although we had mirroring set up, we weren't bothering to specify a mirror when creating routes from the clients to the server. Now that we've done this messages can be sent from the server to the clients, but not the other way round.
I suspect this is because the mirror database instance does not have the same certificates installed in its master database as the primary (we are using both transport and dialog security). I thought about manually copying the certificates over from backups, but I don't think this would work. Also, according to one of my colleagues, it isn't possible to mirror the master database (which makes sense).
I've tried altering the endpoints on each of the machines involved using the following to disable transport encryption, but maybe I'm not understanding something since this doesn't seem to work:
Code Block
use master alter endpoint [EndpointName] for service_broker (encryption = disabled)
My question is how can I either make sure that anything required for transport security is available to the mirror, or how do I disable transport security and simple use dialog security instead (and also if this is actually the problem).
Thanks in advance,
Adam Connelly
[edit] I think I've realised why disabling encryption doesn't do anything for me (i.e. the certificates are still used to sign the messages), but unfortunately knowing that doesn't solve my problem [/edit]
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?
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
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?
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?
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
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?
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).
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>.'
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 tried to setup a service broker from one database to another that is mirrored. I specified the mirror address in the create route sql. When I tried to failover to the mirror database, the message was never sent to the mirror database. I do not see any error in transmission_status of sys.transmission_queue. I do see the following errors in the sql log
Service Broker login attempt failed with error: 'Connection handshake failed. The certificate used by the peer is invalid due to the following reason: Certificate not found. State 89.'. [CLIENT: 10.76.223.38]
The mirror route is not operational. 'TCP://11.78.223.54:4022' is acting as 'Mirror' []. 'TCP://11.78.223.38:4022' is acting as 'Unknown' [].
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]'
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.
Hi to all, I want to study Sql server Service broker, have some questions1. What is the use of service broker ?2. Where this will use ? (With example)3. How to enable Service broker? Because i have sql server 2005 version but no folder like service broker.
Im having a hard time understanding everything required to create a simple Service Broker example. Can someone please assist? Source code would be ideal, but if not "do this, do that" would even be helpful.
I am trying to implement service broker. I send a message from my application code to the database to execute a specific stored procedure. How do i return the result set obtained by the execution of the stored procedure to the application.
My service broker seems to be broken... The database was restored from another crashed server but i have tried the
ALTER AUTHORIZATION ON DATABASE::[SPYDERONTHEWEB] TO [SA];
The error i'm getting is
Service Broker needs to access the master key in the database 'SpyderOnTheWeb'. Error code 25. The master key has to exist and th service master key encryption is required.
It will be great to have an update on MS plans to solve the problem of using Service Broker for remote users who sit behind the NAT. Any news will be appreciated.
Hello , I am trying to Implement distribution of the Stock Quotes over the LAN(only within the Network) and showing the live changing stock Quotes on the front end (in datagrid) installed at each clients desktop.I am receiving the Stock prices over the TCP / IP from the Stock Exchange. I am recieving atleast 10-15 messages per second over the TCP / IP from the Stock Exchange. Now i need to distribute this feed to Each connected client.
I tried doing it from TCP / IP , but in vein. Can we install the SQL 2005 Database Client Version on every client and use Service broker instaed of Live TCP / IP connections programmatically?
Ideally Can i dump the meesages from Stock Exchange in to each connected client's database locally and each front end application will keep a record of all the incomming messages.i.e Front end have a notification event , it will referesh the Datagrid in Front end accordingly...
Is it possible to develop Service Broker in .Net 1.1 (VS 2003)? Currently I have a project developed in .Net 1.1 and I want to add a new method utilize the message queue concept (instead of using MSMQ, using Service Broker SQL 2005), although my DB is SQL server 2005.
I am looking at the Service Broker as a way to notify multiple clients that there has been data changed on a table in the shared database. These clients may or may not be online. When there is a change, the notification should fire off a query to refresh the clients local cache. Is this a situation where Service Broker would help me? Can multiple clients recieve the notification at different times ( some recieve while online, some recieve when they come back online)? Any help on this would be appreciated. It seems from what I read that the messages are pulled off the queue when a notification has taken place. Is this correct? If so, can I set it to behave differently?
Let's assume the situation: we have Initiator and Target. Target is behind ISP's NAT and can't be published outside. So, when Initiator sends a message to Target, Target will not be able to establish a backward connection and will not send an acknowledge. Initiator will retry and retry...
I have tried the following, each runs successfully with no error, but nothing is in the queues, what can be the issue? CREATE MESSAGE TYPE SentMsgType VALIDATION = WELL_FORMED_XML;
CREATE CONTRACT MQContract (SentMsgType SENT BY ANY );
CREATE QUEUE SentQueue WITH STATUS=ON, RETENTION=OFF;
CREATE QUEUE ReceivedQueue WITH STATUS=ON, RETENTION=OFF;
CREATE SERVICE SentService ON QUEUE SentQueue (MQContract);
CREATE SERVICE ReceivedService ON QUEUE ReceivedQueue (MQContract);
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [dbo].[insertTrigger] ON [dbo].[tblBBB] FOR INSERT AS BEGIN SET NOCOUNT ON; DECLARE @handle uniqueidentifier DECLARE @msgBody nvarchar(500)
select @msgBody = someString from inserted
BEGIN DIALOG CONVERSATION @handle FROM SERVICE SentService TO SERVICE 'ReceivedService', 'CURRENT DATABASE' ON CONTRACT MQContract;
--Sends a message SEND ON CONVERSATION @handle MESSAGE TYPE SentMsgType ('<message>' + @msgBody + '</message>') END CONVERSATION @handle WITH CLEANUP; END
SELECT * FROM SentQueue SELECT * FROM ReceivedQueue;
Can anyone let meknow how do i enable a service broker. I am trying to enable a service broker for an issuetracker application to get change of events in my database. When ever i try enabling it using the ALTER DATABASE [ databse] set Enable_Broker. it takes abt more that 2 hrs or more but doesnt show as enabled. Thanks in Advance, Pawan Venugopal
So SQLDependencies failed to do what I wanted them to do for my Cache Invalidating, so i'm going to humor another possibility for a half day - Triggers on my database table that communicate messages to my C# inside my ASP.NET App. Any advice on how to tap into a message queue with C#? I'm thinking that my messages could be 1 of about 100 different strings as far as what occurred on the Database Tables
We have a customer whos database just grows and grows. Not the customers own tables, but the:
sys.sysconvgroup sys.sysdesend sys.sysdercv
And these tables are linked to the Service Broker, and according to http://msdn2.microsoft.com/en-us/library/ms179503.aspx these tables exists in every database and are used by the Service Broker.
Now to my questions =)
HOW do I delete rows from these tables? How come these tables hust grows and grows, could it be any setting in the SQL 2005 Server or is it the customer who has programmed his application wrong?
I'm in the process of doing the initial research for the architecture of a large scale, transactional messages routing platform.
My initial design called for a series of MSMQ queues and Windows Services, written in C#, to process the messages in these queues. There will be incoming and outgoing queues, queues to store unroutable messages, etc.
My application will be routing many hundreds of thousands (and eventually millions) of messages per day. These message are very small (< 200 bytes each) and must be routed very quickly. (<1 second processing overhead per message for high priority messages.)
Using the term "routing" may be a bit misleading. The messages arrive via TCP socket connections. I will just need to take in a message, examine its intended destination, and send it to one of several outgoing socket connections, likely on different machines. Some messages require higher priority routing than others, but I don't need multi-hop routing or anything like that.
Of great concern to me is that there are absolutely no single points of failure in the system. Because of this I was considering using a combination of MSMQ and Windows Services in a Clustered environment.
Can the Service Broker provide me with this kind of functionality? If so, how well does it perform and scale? Is it a better choice for messaging applications that require high transactional throughput than MSMQ?
I'm just trying to get an idea of what products/services I should look into further.
i'm new with service broker and need to develop mail site to send mass email and decide to use sevice broker i'm make aqueue ,sevice and all function for run service borker and creat databasie mail profile
then test it but it's don't work please help me to fine what's the problem ?
thanks very mcuh for every one read my request and response to me thanks very mcuh