SQL Server What is enable_broker for SQLTableDependency - sql-server

In SQL Server, What is enable_broker?
What is the risk?
SQL Table Dependency wants that.

1) https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-service-broker?view=sql-server-2017
SQL Server Service Broker provides native support for messaging and
queuing applications in the SQL Server Database Engine. This makes it
easier for developers to create sophisticated applications that use
the Database Engine components to communicate between disparate
databases. Developers can use Service Broker to easily build
distributed and reliable applications.
2) https://www.sqlservercentral.com/Forums/Topic818423-146-1.aspx
One risk being if there are already service brokers setup to use that
DB they will probably break, and any live connections will be killed
and rollback.
3) Sql Dependency with Service Broker
It's not necessary but if you want to see changes you need it or you can use an other service like periodic polling
Be careful using the SqlDependency class to monitor changes in the
database tables - it has the problems with the memory leaks.
I hope it will help you !

Related

Sociable SQL Server instance replication - Best practice

I would like to know what are best practices for using SQL Server replication on a SQL Server instance that may have other application databases that may also use replication. That is, our product needs to play well with other users of the instance.
The product currently uses SQL Server replication to create a copy database used for reporting. It is always the sole user of the SQL Server instance. But we now need to document and test (regulatory requirements) how the product can share the instance.
I'm making the assumption here that we still need replication as we do not see another way to isolate reporting load from the application's database.
Has anybody done this successfully?
If we are using instance level replication:
Is there a way we can stop/start/modify replication for our application without affecting others?
Do setting differ greatly? That is, is it realistic to share instance level replication settings across applications?
Non-instance replication just looks hard, do I have the wrong view here?
Our customers use SQL Server 2008 R2 or SQL Server 2012.
At an instance level, replication configures only one distributor. That is, regardless of how many databases you have configured for replication on an instance, they'll all share one distributor. You do have the option to make that distributor local (i.e. on the same instance) or remote. So, if you find that distribution is taking up considerable resources (or anticipate that that's going to be the case), configure remote distribution.
Whatever drive holds your databases' log files will need to have sufficient headroom in their throughput to handle the logreader agent. If you're concerned that your database's activity will be impacting to other databases, isolate.
As for other concerns, replication is a lot like your line of business application. That is, it needs to read data (from the publisher and distributor depending on which phase of replication you're talking about) and write data (from the distributor and subscriber again depending on which phase of replication you're talking about). Provision resources accordingly and you should be just fine.

SQL Service Broker as a generic Enterprise Message Bus for .net

I'm in need of an Enterprise Service Bus/Message Queueing solution for publisher/subscriber functionality. I know MANY exist... MSMQ, MS Series, RabbitMQ, NServiceBus, etc etc etc...
My one requirement is that in a shared hosting solution, the only dependency that I can guarantee will exist is SQL 2005 and later... this leads me directly to SQL Service Broker.
If it sounds like I'm trying to shoehorn ESB functionality into SSB... I suppose I am...
My question is: does anyone know of a .NET API or framework that sits on top of SQL Service Broker and already provides much of the plumbing?
If I were to use pure ADO.net, I could add items to the queues by calling a stored procedure, but then:
Do to the nature of conversations, would I make one conversation per message?
If so, do I lose sequential message processing?
How do I receive messages (I know the receive syntax in t-SQL), do I call a stored procedure repeatedly in a message loop to try to
get a message off the queue?
Or would I WAITFORever? Keeping the connection open and executing the stored procedure forever?
SQL Service Broker doesn't support monologue conversations, but I read they can be implemented...
It's these kind of questions that make me wish there existed a .net solution that already managed all of this.
There was an effort to package a WCF Transport Channel for SQL Server Service Broker but, afaik, is abandonware.
But NServiceBus supports Service Broker as a transport, see Using NServiceBus and ServiceBroker.net and there are github projects like A simple wrapper API for SQL Service Broker and an ITransport plugin for NServiceBus. While not exactly mainstream, some support and community effort does exists.
As an ESB I think you will have problems due to lack of true pub-sub and broadcast. SQL Server 2012 has the ability to SEND a message to multiple targets, see How to Multicast messages with SQL Server Service Broker, but you will still have to implement the pub-sub infrastructure (publishing topics, subscribers etc) from scratch. MySpace did that and was a major effort, see Scale out SQL Server by using Reliable Messaging. My observation reffers to the low level direct use of SSB, I have never used NServiceBus so I cannot tell how well does it abstracts/expose unicast/broadcast/multicast/pub-sub over SSB.
As for your specific questions, I recommend reading Writing Service Broker Procedures and Reusing Conversations.

Database synchronization

Recently my clients have asked me if they can use they’re application remotely, disconnected from the local network and the company server.
One solution is to place the database in the cloud, but a connection to the database, and the cloud and an internet connection must be always available.
There not always the case.
So my question is - Is there any database sync system, or a synchronization library so that I can work disconnected with local database and when I connect synchronize the changes I have made and receive changes others have made?
Update:
The application is under Windows (7/xp) ( for now )
It's in Delphi 2007 win32
All client need to have Read/Write access
All Clients have internet connection, but not always ON
Security is not critical, but the Sync service should encrypt the communication
When in the presence of the companies network the system should sync and use the Server Database and not the local one.
You have a host of issues with thinking about such a solution. First, there are lots of possible solutions, such as:
Using database replication within a database, to mimic every update (like a "hot" backup)
Building an application to copy the database periodically (every night)
Using a third-party tool (which is what you are asking, I think)
With replication services, the connection does not have to always be up. Changes to the database are logged when the connection is not available and then applied when they can be sent.
However, there are lots of other issues when you leave a corporate network. What about security of the data and access rights? Do you have other options, such as making it easier to access the database from within the network? Do the users need only read-access to the database or read-write access? Would both versions need to be accessed at the same time. Would there be updates to both at the same time?
You may have other options that are more secure than just moving a database to the cloud.
I believe RemObjects DataAbstract allows offline mode and synchronization by using what they call Briefcases. All your other requirements (security, encrypted connections, etc.) are also covered.
This is not a drop-in replacement, thought, and may need extensive rewrite/refactoring of your application. There are lots of upsides, thought; business rules can/should be enforced on the server (real security), scriptable business rules, multiplatform architecture, etc.
There are some products available in the Java world (SymmetricDS lgpl license) - apart from actually being a working system it is documents how it achieved synchronization. Connects to any db with jdbc support. . There is a pro version but the user guide (downloadable pdf) gives you the db schema plus rules on push pull syncing. Useful if you want to build your own.
Btw there is a data replication so tag that would help.
One possibility that is free is the Microsoft Sync Framework: http://msdn.microsoft.com/en-us/sync/bb736753.aspx
It may be possible for you to use it, but you would need to provid some more detail about your application and operating environment to be sure.
IS it possible to share a database like .mdb and work fine? i try but sometimes the file where the databse is changes from DB to DB1 i use delphi Xe4 and Google Drive .
Thank´s

Service Broker in Database/Programming

Service Broker
What can be the Benefits of Programming with Service Broker?
In which condition one should use Service Broker?
Do you have Sample link for Code/Video that easily/precisely explains it's usage?
Queuing and asynchronous messaging are needed for many database
applications today. Service Broker provides a new, queue-based durable
messaging framework to address these needs. Using the Transact-SQL API
provided by Service Broker, you can easily develop services to handle
application requirements for queuing or asynchronous communications.
Some of the benefits of programming with Service Broker are:
Flexible development: The programs used in a single distributed
application can be written in multiple languages. Each program
provides the functionality of each distributed application component.
Improved security: You can express security requirements via
certificates, so application components do not need to share the same
security context. Service Broker uses SQL Server security features to
help you secure your applications.
Transactional processing: Message processing occurs within SQL Server
transactions to ensure data integrity. Service Broker supports remote
transactional messaging over a standard connection to the database.
Guaranteed ordering: Service Broker provides strong guarantees
regarding the delivery and processing of a related set of messages
exactly once and in order, so no additional coding is required to
provide this functionality.
Reliable delivery: All of the data needed for a conversation--a set of
related communications between two or more services--is persisted in
SQL Server. Service Broker supports clustering and database mirroring.
A conversation may be maintained through system restarts, server
failover, network outages, and so on without failing or losing data.
Improved scalability: Service Broker routing delivers messages based
on the name of the service, rather than on the network address of the
computer where the service runs. This allows you to install an
application on multiple computers without changing application code.
Ability to leverage existing knowledge: Service Broker uses
Transact-SQL to create objects. Applications that use Service Broker
are most often implemented in Transact-SQL or Microsoft .NET
Framework-compatible languages. You do not have to learn a new
language to create Service Broker applications.
For further detail check this link
http://dotnet.dzone.com/articles/c-sqldependency-monitoring
Service brokers are useful when we want do asynchronous processing in the database. which will improve the performance.
When we need inter database communication.
you can find sample code for creating and sending the messages using service broker here.

access and sql server realtime synchronization

i have a security application that stores its data in a access database.now i'm required to
make a realtime synchronization (replication) between that access database and a new database in sql server 2005. these two database are the same.
any suggestion?!
i don't know how to do it using a windows service or not. i need exact technical answer.
Mostly, I would suggest you use a windows service to periodically check the MS Access db, and attempt to synchronize it with the Sql database.
This will allow you to remove the Human factor, and have this task run periodically to sync the dbs.
Have a look at
Creating a Basic Windows Service in
C#
Creating a Windows Service in C#
Also
Connect to Microsoft Access .mdb
database using C#
Beginners guide to accessing SQL
Server through C#
SQL server has built-in replication functionality that you get for free, so you don't need to worry about copying rows & tracking changes. There are several types of SQL replication that are used for different situations, such as merge replication, snapshot replication, and transactional replication. This last one, transactional replication sounds like what you want. Merge replication is used when you have users that might disconnect, go away and return later to synchronize (like remote users). Transactional replication is used where the subscribers and publisher are reliably connected. Snapshot replication generates a new snapshot each time synchronization occurs, and doesn't think about changes to the data. Read the MSDN documentation and find which of these types is appropriate for your situation.
Using these replication methods will require that you set up your tables in a SQL server or express instance - you can use that to synchronize with your SQL server and keep everything else Access as the front end. I think you want to follow astander's suggestion and use a windows service to trigger synchronization. However you can set up the Windows Synchronization Manager to automatically try to synchronize at startup, shutdown, when the computer is idle, etc. If you need finer control over triggering the synchronization then perhapse use a Windows app or service as astander suggested.

Resources