Problem with OracleDependency
Hi everybody,
It seems that OracleDependency doesn't notify all inserted rows in table. I have 2 programs run separately, one is filling the table with data and the other program is waiting notification from database.
OracleDependency notifies my program with some datas instead of all new datas.
Can someone help me ?
The code below is for the notification:
/// <summary>
/// Wath the database for new news
/// </summary>
public void Watch()
{
// Oracle connection
OracleConnection oraCon = new OracleConnection(OracleManager.Instance.GetOracleConnection());
// Oracle command
OracleCommand cmd = null;
try
{
// Open oracle connection
oraCon.Open();
// Create the command object
cmd = oraCon.CreateCommand();
cmd.CommandText = ""SELECT GUID, FEEDID FROM RSS_DATA"";
cmd.CommandType = CommandType.Text;
cmd.AddToStatementCache = false;
// Add ROWID to the query to identify the specific rows that
// have been changed. ROWID is a pseudo-column in every Oracle
// table that uniquely identifies each row.
cmd.AddRowid = true;
// Create the dependency object
// note this does not perform the registration
// it only defines the relationship
OracleDependency dep = new OracleDependency(cmd);
// Set the notification to persist after first notification is received
// this will allow all notifications to be received instead of just
// a single notification
cmd.Notification.IsNotifiedOnce = false;
cmd.Notification.IsPersistent = true;
// define the event handler to invoke when the change notification
// is received
dep.OnChange += new OnChangeEventHandler(dep_OnChange);
// Execute the command (ignore actual result set here)
// this performs the registration that was defined here when
// the dependency object was created
cmd.ExecuteNonQuery();
// Simply loop forever waiting for the notification from database
// You need to ctrl+C from the console
while (true)
{
//logger.Info("Waiting for notication");
Thread.Sleep(2000);
}
}
catch (Exception e)
{
logger.Error("Error while waiting news notification", e);
}
}