Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Oracle 11g Continuous Query Notification to a vs 2005 c# service

Oracle 11g Continuous Query Notification to a vs 2005 c# service

Scheduled Pinned Locked Moved Database
databasecsharporaclevisual-studiohelp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    livez
    wrote on last edited by
    #1

    Hello! Im trying to set up a Continuous Query Notification between our oracle database and my c# service, but can´t seem to get it to work. This is the method I have for making the connection:

    private void SubscribeToTable(string tableName)
    {
    Log.Write("Add listener: " + tableName);

            OracleConnection con = DataBase.GetOpenConnection();
            OracleDependency dependency = new OracleDependency();
            dependency.QueryBasedNotification = false;
            OracleCommand cmd = con.CreateCommand();
            cmd.CommandText = "Select \* from " + tableName;
            dependency.OnChange += new OnChangeEventHandler(dependency\_OnChange);
            dependency.AddCommandDependency(cmd);
            cmd.Notification.IsNotifiedOnce = false;
            cmd.AddRowid = true;
            cmd.ExecuteNonQuery();
            con.Close();
            con.Dispose(); 
        }
    

    And when I run this I get a row in user_change_notification_regs with these values:

    42 4 net8://(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.119)(PORT=1521))?PR=0 0 0 49999 WEB.EXPORTEDDOCUMENTS

    and this is the callback event:

    static void dependency_OnChange(object sender, OracleNotificationEventArgs eventArgs)
    {
    Log.Write("Table has been Changed");
    Log.Write(eventArgs.Source.ToString());
    Log.Write(eventArgs.Info.ToString());
    Log.Write(eventArgs.Source.ToString());
    Log.Write(eventArgs.Type.ToString());
    }

    My problem is the callback-event never runs. Has anyone else had this problem?

    S 1 Reply Last reply
    0
    • L livez

      Hello! Im trying to set up a Continuous Query Notification between our oracle database and my c# service, but can´t seem to get it to work. This is the method I have for making the connection:

      private void SubscribeToTable(string tableName)
      {
      Log.Write("Add listener: " + tableName);

              OracleConnection con = DataBase.GetOpenConnection();
              OracleDependency dependency = new OracleDependency();
              dependency.QueryBasedNotification = false;
              OracleCommand cmd = con.CreateCommand();
              cmd.CommandText = "Select \* from " + tableName;
              dependency.OnChange += new OnChangeEventHandler(dependency\_OnChange);
              dependency.AddCommandDependency(cmd);
              cmd.Notification.IsNotifiedOnce = false;
              cmd.AddRowid = true;
              cmd.ExecuteNonQuery();
              con.Close();
              con.Dispose(); 
          }
      

      And when I run this I get a row in user_change_notification_regs with these values:

      42 4 net8://(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.119)(PORT=1521))?PR=0 0 0 49999 WEB.EXPORTEDDOCUMENTS

      and this is the callback event:

      static void dependency_OnChange(object sender, OracleNotificationEventArgs eventArgs)
      {
      Log.Write("Table has been Changed");
      Log.Write(eventArgs.Source.ToString());
      Log.Write(eventArgs.Info.ToString());
      Log.Write(eventArgs.Source.ToString());
      Log.Write(eventArgs.Type.ToString());
      }

      My problem is the callback-event never runs. Has anyone else had this problem?

      S Offline
      S Offline
      sonosun
      wrote on last edited by
      #2

      Hello, Have you solved this issue? I am having a similar problem. I used a OCI sample code from ORACLE site. My OCI client was able to register the subscription. However, the subscription was removed from USER_CHANGE_NOTIFICATION_REGS as soon as I updated the table that is registered for subscription. And, my client callback function never got called. Btw, I used oracle client 11.2.0.1.0 and my db is running 11.2.0.1.0. The sample code was compiled on Linux Centos 5.5. I checked my user privilege and it has CHANGE_NOTIFICATION. I also check "job_queue_processes" and "dml_locks", both of them have non-zero values.

      L 1 Reply Last reply
      0
      • S sonosun

        Hello, Have you solved this issue? I am having a similar problem. I used a OCI sample code from ORACLE site. My OCI client was able to register the subscription. However, the subscription was removed from USER_CHANGE_NOTIFICATION_REGS as soon as I updated the table that is registered for subscription. And, my client callback function never got called. Btw, I used oracle client 11.2.0.1.0 and my db is running 11.2.0.1.0. The sample code was compiled on Linux Centos 5.5. I checked my user privilege and it has CHANGE_NOTIFICATION. I also check "job_queue_processes" and "dml_locks", both of them have non-zero values.

        L Offline
        L Offline
        livez
        wrote on last edited by
        #3

        Hello! Sadly I never solved it. My subscription was also removed eventhough I set it up to stay (cmd.Notification.IsNotifiedOnce = false;), and I can see with network sniffer that something is sent to my computer from databasecomputer, but my application never registers the callback. I also tried with samplecode from oracle (http://www.oracle.com/technetwork/issue-archive/win06odp-099708.html[^] and http://www.devart.com/dotconnect/oracle/docs/Devart.Data.Oracle~Devart.Data.Oracle.OracleDependency.html[^]) but I experienced same problem with that. I used oracle client 11.2.0.2.0 and my db is running 11.2.0.1.0. I´ve shelved this issue for a while but figured I'd give it another go in a few weeks. If you or anyone else solve this issue I would very much appreciate a reply here, and I will of course do the same. /regards

        modified on Thursday, February 10, 2011 3:53 AM

        S 3 Replies Last reply
        0
        • L livez

          Hello! Sadly I never solved it. My subscription was also removed eventhough I set it up to stay (cmd.Notification.IsNotifiedOnce = false;), and I can see with network sniffer that something is sent to my computer from databasecomputer, but my application never registers the callback. I also tried with samplecode from oracle (http://www.oracle.com/technetwork/issue-archive/win06odp-099708.html[^] and http://www.devart.com/dotconnect/oracle/docs/Devart.Data.Oracle~Devart.Data.Oracle.OracleDependency.html[^]) but I experienced same problem with that. I used oracle client 11.2.0.2.0 and my db is running 11.2.0.1.0. I´ve shelved this issue for a while but figured I'd give it another go in a few weeks. If you or anyone else solve this issue I would very much appreciate a reply here, and I will of course do the same. /regards

          modified on Thursday, February 10, 2011 3:53 AM

          S Offline
          S Offline
          sonosun
          wrote on last edited by
          #4

          Thanks for the reply. If I solve this issue, I will post it here.

          1 Reply Last reply
          0
          • L livez

            Hello! Sadly I never solved it. My subscription was also removed eventhough I set it up to stay (cmd.Notification.IsNotifiedOnce = false;), and I can see with network sniffer that something is sent to my computer from databasecomputer, but my application never registers the callback. I also tried with samplecode from oracle (http://www.oracle.com/technetwork/issue-archive/win06odp-099708.html[^] and http://www.devart.com/dotconnect/oracle/docs/Devart.Data.Oracle~Devart.Data.Oracle.OracleDependency.html[^]) but I experienced same problem with that. I used oracle client 11.2.0.2.0 and my db is running 11.2.0.1.0. I´ve shelved this issue for a while but figured I'd give it another go in a few weeks. If you or anyone else solve this issue I would very much appreciate a reply here, and I will of course do the same. /regards

            modified on Thursday, February 10, 2011 3:53 AM

            S Offline
            S Offline
            sonosun
            wrote on last edited by
            #5

            Hi, May I know what Oracle edition that you have? Is it Enterprise or Standard edition? Mine is standard edition. I am trying to find out if publish/subscribe is supported in standard edition.

            1 Reply Last reply
            0
            • L livez

              Hello! Sadly I never solved it. My subscription was also removed eventhough I set it up to stay (cmd.Notification.IsNotifiedOnce = false;), and I can see with network sniffer that something is sent to my computer from databasecomputer, but my application never registers the callback. I also tried with samplecode from oracle (http://www.oracle.com/technetwork/issue-archive/win06odp-099708.html[^] and http://www.devart.com/dotconnect/oracle/docs/Devart.Data.Oracle~Devart.Data.Oracle.OracleDependency.html[^]) but I experienced same problem with that. I used oracle client 11.2.0.2.0 and my db is running 11.2.0.1.0. I´ve shelved this issue for a while but figured I'd give it another go in a few weeks. If you or anyone else solve this issue I would very much appreciate a reply here, and I will of course do the same. /regards

              modified on Thursday, February 10, 2011 3:53 AM

              S Offline
              S Offline
              sonosun
              wrote on last edited by
              #6

              Hello, I managed to get my subscription working. Here is what I have done on my test environment. My client uses oracle-instant-client 11.2.0.1. My db server is running Oracle 11.2.0.1 release. Both client and server are on Centos OS. Previously, I have client on Centos and server on Solaris. I have done quite few tests with combination of different client, server and their OS. I found that the Oracle version and the OS platform contributed to the issue that I had. As a preliminary quick test, I also ran my client on the same box where my db server was running. In my case, this worked fine. Hopefully, this will help. Cheers, sw

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups