Insert To A Linked Server Possible Via Service Broker?

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


ADVERTISEMENT

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 β€˜''<<------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 

View 1 Replies View Related

How To Prevent The Hang On The Initator Service Broker If The Target Service Broker Is Not Started?

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

Using Service Broker To Insert/Update DB2

Jan 26, 2008



HI,


My requirement is to insert/update DB2 files once the data is ready in SqlServer. As the DB2 connection itself is taking around 8 - 10 seconds we are moving the insert/update operation from UI(Aspx) to Batch Jobs(SSIS). The UI will pull the ID to service broker queue and the SSIS package configured to run every 15 minutes will pick the ID from queue and run select to get all the details and updates DB2 database.

Please advice the above usage of SSIS and Sevice Broker can be in a better way.

Thx-
Sami

View 1 Replies View Related

Architectural (broker) Place Of SQL Service Broker

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

The SQL Server Service Broker Challange

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

SQL Server Service Broker Examples

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

SQL SERVER 2005 Service Broker

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

Enabling Service Broker In Sql Server 2005

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

Can See Service Broker Queue With SQL Server Login

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

Service Broker Feature In Sql Server 2005

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

SQL Server Logging Of Service Broker Messages

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

SQL Server 2008 :: Service Broker Queue In Database

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

SQL Server 2008 :: Service Broker And Temp Tables

Feb 12, 2015

Let's say that I have a stored proc that is assigned to a service broker queue and is constantly running while it waits for messages in said queue. When a message comes in on the queue, the stored proc creates a table variable based off of the contents of the message and performs various operations with the data. Since the stored proc is constantly running, do the contents of this table variable ever truly get emptied? Should I be deleting the contents of the table variable at the end of the operation to ensure that stale data doesn't persist?

View 5 Replies View Related

ASP.NET SqlDependency Using Sql Server 2005 Service Broker Problem.

Dec 4, 2007

I created the table dbo.customer from the orginal table sales.customer. dbo.customer works but sales.customer does not. WHY? We took the time to design our tables under different schemas to help control, organize and assign permissions.Private Function GetCustomers() As DataTable
Dim sqlconnection As New SqlConnection(WebConfigurationManager.ConnectionStrings("connectionstringAlliance").ConnectionString.ToString)WORKS:Dim command As New SqlCommand("SELECT CustomerID, CustomerType FROM dbo.Customer WHERE CustomerID=1234", sqlconnection)DOES NOT WORK:Dim command As New SqlCommand("SELECT CustomerID, CustomerType FROM Sales.Customer WHERE CustomerID=1234", sqlconnection)

Dim dependency As New SqlCacheDependency(command)
Dim dad As SqlDataAdapter = New SqlDataAdapter(command)
Dim customers As New DataTable
dad.Fill(customers)Cache.Insert("Customers", customers, dependency)
Return customersEnd Function Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadDim customers As DataTable = CType(Cache.[Get]("Customers"), DataTable)

If customers Is Nothing Then
customers = GetCustomers()
Label1.Text = System.DateTime.Now.ToString()
End If
gridviewCustomer.DataSource = customers.DefaultView
gridviewCustomer.DataBind()

End Sub

View 6 Replies View Related

Service Broker TO Service Could Not Be Found Message Origin: Transport

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

SQL Server Service Broker Admin Tool For SQL Server 2005 RTM

Dec 27, 2005

Back in July I released the (then) latest version of SsbAdmin. For you who
don'r know what it is; it's a tool which allows you to graphically administer
SQL Server Service Broker.

I have now uploaded a new version which is compiled against the released
versions of SQL Server 2005 and .NET 2.0.

You can download it from here: [0].

After download, un-zip to some directory and read the README.doc file.

[0]: http://staff.develop.com/nielsb/code/ssbadmin.zip

View 2 Replies View Related

The SQL Server Service Broker Or Database Mirroring Transport Is Disabled Or Not Configured

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

SQL Server 2005 Service Broker - Activation Stored Procedure Memory Usuage

Nov 9, 2007

We are looking for some guidance with an issue we have picked up with our implementation of Service Broker here on the ABSA Capital project and I am hoping you can help or point us in the direction of someone.

The architecture we have implemented for service broker is to make use of an Activation stored procedure on two queues (1 SP per queue) to process the messages received. What we have found is that the activation stored procedure runs on a background session and its CPU time and memory just grows to the point where it brought one of our UAT servers to a grinding halt.

Is there anyway we can reduce the memory consumption of the activation stored procedure or is this one of those things that still need to be ironed out in Service Broker?

View 6 Replies View Related

Service Broker And .net Windows Service

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

SQL Service Broker

Apr 5, 2008

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. 

View 2 Replies View Related

Service Broker Example.

Aug 29, 2006

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.

Thanks.

View 1 Replies View Related

Service Broker

Sep 8, 2006

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.

View 4 Replies View Related

Service Broker

May 16, 2006

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.

Error: 28054, Severity 11, State: 1.

View 4 Replies View Related

Service Broker And NAT

Sep 26, 2006

Hi

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.

Leonid.

View 1 Replies View Related

Service Broker

Sep 11, 2006

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...

ALL my front end application are made in dot net

Pls suggest if this above workflow will help me

Yugant







View 2 Replies View Related

Service Broker + .Net 1.1

Jan 8, 2008

Hi,

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.

Thanks,

View 1 Replies View Related

How To Use Service Broker And When

Jul 3, 2007

Hi all



if any one have any white paper or artical cover this issue kindly i need it



thanks , regards

View 1 Replies View Related

Is SQl Service Broker What I Need??

May 16, 2007

Hi,



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?



Thanks,

-paul

View 1 Replies View Related

Service Broker From Behind The NAT

Sep 15, 2005

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...

View 8 Replies View Related

Service Broker

Apr 26, 2008

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;

View 3 Replies View Related

Service Broker

Oct 16, 2006



How to create service broker and whic version is supported to create serveice broker.



can you plz exlain to create servece broker from the scratch



View 1 Replies View Related

Sql Dependency And Service Broker.

Feb 16, 2007

Hi everyone,
 
                  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

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved