I'm using EF 6 with SQL Server 2012.
I'm trying to use SqlDependency to refresh my cached data, in a class library (DLL).
I have the following, based on whatever guides I found, but seems like it is not working, and I get no error.
enabled broker service on the db
created the broker queue, and the service
Using sa login.
I'm testing this whole thing through unit testing code, not sure maybe the notification is not instantaneous, my breakpoint in SqlDependency.OnChange never triggered.
But even if I purposely slow down the post-changes, OnChange is still not triggered.
Once I made relevant data changes, how can I know SQL Server is generating a notification in db?
Update:
Initially I found "master key encryption is required" in SQL log. By creating that key, the log no longer happened, but OnChange is still not triggered.
After many trials, and based on 1 important article:
http://www.codeproject.com/Articles/12335/Using-SqlDependency-for-data-change-events
1) After SqlDependency is initialized, must execute the SqlCommand, can simple just invoke sqlCmd.ExecuteNonQuery().
2) After OnChange event triggered, must remove the event handling, recreate a new SqlCommand and SqlDependency, rebind the event handling, and follow rule #1
Related
I am working on the Data Integration Specialist Superbadge. I can't get the call out trigger to save.
Challenge Not yet complete... here's what's wrong:
The ProjectTrigger does not appear to be calling 'BillingCalloutService.callBillingService()' and passing in the collection of old and new records.
The Trigger doesn't seem to be saving either on the Developer Console or the Apex Trigger in Setup. I have deleted the old workspace in workspace manager in the console as it could be corrupt.
Any ideas or recommendations?
Any recommendations to fix the trigger not saving?
Environment: SQL Server 2012 Express edition.
Goal: Setup SQL Server Service Broker with external activation, calling a command line app.
What I have done so far: created message types, contracts, initiator and receiver queues and corresponding services. I also did set up a notification queue, notification service and created event notification for the TargetQ. The event notification is configured so that when an event is raised, it should (I thnk) call the NotifySvc letting it know that there is work to be processed in TargetQ. Please feel free to correct me at any point – this is very new to me.
What happens: I have a trigger on a table that (upon insert) creates a message and calls the TargetSvc. The message arrives at the TargetQ happily. And this is where everything stops. I am not sure if the event notification for queue activation is never triggered or what, but the message never makes it to the NotifyQ. Therefore my EA app is never called.
I realize I am skipping a lot of detail around setup and configuration but, as the topic is new to me, I am hoping that you guys see something obvious. Any help is much appreciated.
I currently have my application integrated with Hibernate. It saves/retrieves data from the database successfully. Next, I would like to configure ehcache such that my application does not have to hit the database every time.
That being said, I was wondering if there are any ehcache event handlers that would allow me to run some custom piece of code before (or after) a cache operation (i.e. put, remove, get, etc.)?
Also, when my application is about to save a DAO, my understanding is hibernate will push that to the database. What I would like to know whether the db operation will be performed before, during or after the event handler (above) is triggered?
Perhaps you could create a CacheEventListener which would allow you to receive notifications of put/update/remove events - and then you could perform some action accordingly. The notification occurs after the event has happened.
You configure a listener in the ehcache.xml file on a per-cache basis:
<cache ...>
<cacheEventListenerFactory class="your.listener.FactoryClass" />
...
</cache>
Where the cacheEventListenerFactory is a class that you create which in turn creates your listener. See the EHCache docs for more detailed info.
For integration of EHCache with Hibernate, you should look at the EhCacheRegionFactory. Again see the docs for step by step instructions of how this is set up.
We've got a program that runs on our network (it's published to our app-server and run from there as well) and I'd like to show an Alert window (by DevExpress) to all users who are running the app, whenever a new item is entered. Obviously the code would go in the Save event but when I put it in there, it only works for me, meaning I'm the only user who sees the alert, no one else. The same can be said for other users...they only see the alert when they enter it, not when someone else enters it.
Any ideas as to how this can be accomplished?
You can use straight MSMQ to put on a message and have clients listen on that queue. You can also use NServiceBus (which does use MSMQ) that has a publish subscribe framework built in. This way your clients can subscribe to all clients or certain clients.
Since WinXP, Vista and Win7 have MSMQ it just maybe a matter of installation and configuration (which NServiceBus will do 'automatically' for you)
You could try with Comet if you want true push mechanism. Otherwise you could use periodical pull using setInterval and ajax calls. However, both techniques have some performance repercussions.
I am having difficulty deploying RIA services/Silverlight 3 to a staging environment.
Here is my situation:
1) I am using RIA for authentication. This works fine on both my development machine and in the staging environment.
2) I created a custom LinqToEntities RIA service to get data from the database into my application. This service works fine when I do a local build, but does not work on the staging server.
The server side RIA code never gets called when the client makes a call to it.
The RiaContext appears to be initialized ok, i.e. it does not throw an exception.
I use code sililar to Context.Load(qry); to put data into the entities. The LoadOperation's complete event fires, but no data was loaded, the serverside methods were never called.
Any ideas on what may be wrong?
I would check to make sure that you have:
The correct connection string in your web.config.
The application is configured to run under a service account that has permissions to access the database.
Your Context.Load should be passing a completed event handler and in that handler you chould check that the LoadOperation.HasError is false. There will be no exception thrown if something went wrong, you have to explicity check for the error.