Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Java Dequeue's from Oracle AQ

Java Dequeue's from Oracle AQ

From: Pete Hawdon <peter.hawdon_at_ppa.nhs.uk>
Date: 10 Sep 2001 03:19:51 -0700
Message-ID: <1554f8b1.0109100219.238d4ccf@posting.google.com>


Anyone had any problems doing DEQUEUE operations on Oracle AQ queues using Java
where the queue is in a different schema to the user doing the DEQUEUE? I have some code that connects and gets the queue table, gets the queue, creates a message object and then attempts a dequeue, but fails with the following exception:

Exception in thread "main" java.lang.NullPointerException
     at oracle.AQ.AQOracleQueue.dequeue(AQOracleQueue.java:1436)
     at oracle.AQ.AQOracleQueue.dequeue(AQOracleQueue.java:1127)
     at testDequeue.main(testDequeue.java:105)


This code works fine if i log on and try to dequeue from a queue in my schema but not if i try to access a queue in a different schema. I have been granted the necessary priveleges to access queues in other schemas.

ANY IDEAS? my code is below :

import java.io.*;
import java.sql.*;
import oracle.sql.*;

import oracle.AQ.*;
import java.util.Date;
import java.text.*;

import org.ppa.nhs.busobj.*;

public class testDequeue {

	private static Connection conn;
	private static QueueControl qControl;
	private static AQSession qSession;

	private static String userName = xxx;
	private static String passWord = xxx;
    
	private static String queueTableName = "QUEUE_TAB_1";
        private static String queueName = "QUEUE_1";

    private static     AQQueueTable             q_table;
    private static     AQQueue                  queue;
    private static     AQMessage                message;
    private static     AQRawPayload             raw_payload;
    private static     AQDequeueOption          deq_option;
    private static     byte[]                   b_array;



	public static void main(String[] args) throws AppException {

	   QueueControl qControl = new QueueControl();

	   /* create a connection object */
	   try
		{
			/* Load the Oracle jdbc thin driver: */
			Class.forName("oracle.jdbc.driver.OracleDriver");

			conn =   DriverManager.getConnection(
			         "jdbc:oracle:thin:@22.22.10.10:1521:sdf1",
			         userName, passWord);

			System.out.println("JDBC Connection opened ");

			conn.setAutoCommit(false);

}
catch (SQLException e) { System.out.println("connection error");
}
catch (ClassNotFoundException e) { System.out.println("connection error");
}
/* create a new Advanced Queueing Session, passing in the username and password */ try { Class.forName("oracle.AQ.AQOracleDriver"); qSession = AQDriverManager.createAQSession(conn); //qSession = qControl.createSession(conn); } catch (Exception e) { System.out.println("Error creating session"); } /* Get a handle to queue table */ q_table = qSession.getQueueTable ("ETP", queueTableName); System.out.println("Successful getQueueTable"); /* Get a handle to a queue */ queue = qSession.getQueue ("ETP", queueName); System.out.println("Successful getQueue"); /* Create a AQDequeueOption object with default options: */ deq_option = new AQDequeueOption(); System.out.println("Successful create dequeue option"); deq_option.setNavigationMode(AQDequeueOption.NAVIGATION_FIRST_MESSAGE); /* Dequeue a message: */ try { message = queue.dequeue(deq_option); } catch (AQOracleSQLException e) { e.printStackTrace(); if(e.getErrorCode() == 25226) { System.out.println("The Queue " + queueName + " in Queue Table " + queueTableName + " in schema " + userName + " is not enabled for DEQUEUE operations - try STARTing the queue"); } throw new AppException(e.getMessage(),2);
}

...
...ETC Received on Mon Sep 10 2001 - 05:19:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US