【问题标题】:Oracle Advance Queue and Java: Able to send message through code but not able to see in queue tableOracle Advanced Queue 和 Java:能够通过代码发送消息但无法在队列表中看到
【发布时间】:2021-08-15 14:56:57
【问题描述】:

尝试使用 Oracle 网站上提供的 Java 代码向队列发送消息。 代码运行成功,但我在数据库中看不到任何记录。

    static String myJson =
                "Hello Message"; 
                
        public static void runTest(AQSession aq_sess) throws AQException
        {
              AQQueueTable             q_table;
             AQQueue                  queue;
             AQMessage                message;
             AQRawPayload             raw_payload;
             AQEnqueueOption          enq_option;
             String                   test_data = myJson;
             byte[]                   b_array;
    
             /* Get a handle to queue table - aq_table4 in aqjava schema: */
    //       q_table = aq_sess.getQueueTable ("MASTERDATA", "TEST_TABLE");
    //       System.out.println("Successful getQueueTable");  
    
             /* Get a handle to a queue - aq_queue4 in aquser schema: */
    //       queue = aq_sess.getQueue ("APPS", "XXEDGE_CONTACT_TO_QUE");
             queue = aq_sess.getQueue ("MASTERDATA", "TEST_QUEUE");
             System.out.println("Successful getQueue");  
    
             /* Create a message to contain raw payload: */
             message = queue.createMessage();
             
             AQMessageProperty amq = message.getMessageProperty();
             amq.setExpiration(10000l);
             amq.setSender(new AQAgent("Gren", "",0));
             /* Get handle to the AQRawPayload object and populate it with raw data: */
             System.out.println(test_data);
             b_array = test_data.getBytes();
             
             raw_payload = message.getRawPayload();
             System.out.println(b_array.length);
             raw_payload.setStream(b_array, b_array.length);
             System.out.println("Queue");
             /* Create a AQEnqueueOption object with default options: */
             enq_option = new AQEnqueueOption();
             
             /* Enqueue the message: */
             queue.enqueue(enq_option, message);
             System.out.println("EnQueued");
        }

有什么建议丢失消息的地方吗?

【问题讨论】:

    标签: java jms oracle-aq


    【解决方案1】:

    在入队后提交连接很重要。

    我已经输入了提交语句并且它起作用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-02
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 2011-08-20
      • 2012-10-20
      • 2017-04-27
      相关资源
      最近更新 更多