c# - OracleDependency with ASP.NET MVC 3 -
i want utilize oraclechangenotifications in asp.net mvc 3 app. have created simple console application illustration code here, , works expected. if alter registered database table, notification gets fired in console application.
then created asp.net mvc 3 app same sample code mvc app not getting notifications. im using oracle 11g. apparently listener gets registered in oracle database. if run query:
select * user_change_notification_regs; i next result:
regid: 127 regflags: 4 callback: net8://(address=(protocol=tcp)(host=127.0.0.1)(port=59747)?pr=0 operations_filter: 0 changelag: 0 timeout: 48556 table_name: mytable my guess iis somehow blocking callback, cannot figure out why? ideas?
heres code using:
using system; using system.data; using nlog; using oracle.dataaccess.client; namespace cachetestwebapp.services { public class notification { private static logger _logger = logmanager.getcurrentclasslogger(); private const string connectionstring = "<connection_string>"; private const string tablename = "mytable"; private const string querystring = "select * " + tablename; public static void registernotification() { seek { using (var con = new oracleconnection(connectionstring)) { con.open(); var cmd = new oraclecommand(querystring, con); var dependency = new oracledependency(); dependency.onchange += dependency_onchange; dependency.addcommanddependency(cmd); cmd.notification.isnotifiedonce = false; cmd.addrowid = true; cmd.executenonquery(); con.close(); con.dispose(); } } grab (exception e) { _logger.error(e.message); } } private static void dependency_onchange(object sender, oraclenotificationeventargs eventargs) { // handle notification } } } notification.registernotification() executed in application_start() in global.asax.cs:
protected void application_start() { arearegistration.registerallareas(); registerglobalfilters(globalfilters.filters); registerroutes(routetable.routes); notification.registernotification(); } c# asp.net asp.net-mvc asp.net-mvc-3 oracle11g
No comments:
Post a Comment