0 Replies Latest reply on Jun 4, 2012 9:05 AM by Richard Williams

    oracle connect to hornetq

    Richard Williams Newbie

      hi,

      I have met a problem in my project when I want to send msgs from oracle. Maybe it's something about database, I am sorry ,but I do need some advice. Thanks.

      It's like this, I want to trigger a message sent to hornetq whenever data is inserted into oracle.

      I wrote a trigger, a function and loaded a java file into oracle.

      Since I want to make this process as fast as possible, I use a long connection to hornetq instead of reconnecting whenever I send a msg, to implement this ,

      a static field is used in the java class, and initialized only once.

      The problem I met is , when I insert data into oracle, the insert statement does not stop, although the msg is sent. I don't know what 's going on here.

       

      here is the code : ( i remove the try catch statements to make it short)

      Sender.java:

      import net.ser1.stomp.Client;

      public class Sender{

      public static Client client;

      static {

              client  = new Client("10.214.10.90", 61613, "guest", "guest");

      }

      public static int produce(String msg) {

              client.send("jms.queue.testQueue", msg);

      return 0;

      }

      }

       

      function:

      create or replace function p(msg varchar2) return number as

      language java

      name 'Sender.produce(java.lang.String) return int';

       

      trigger:

      create or replace trigger frms_trigger before insert on frms_table

      for each row

      declare

      my_var varchar2(200);

      ret number;

      begin

        my_var := ..... //make a string here

        ret := p(my_var);

      end;