AQ JMS messages not "seen" at the Java side
From: yossarian <yossarian99_at_operamail.com>
Date: Tue, 23 Sep 2008 16:34:24 +0200
Message-ID: <48d8fe70$0$14487$5fc30a8@news.tiscali.it>
Date: Tue, 23 Sep 2008 16:34:24 +0200
Message-ID: <48d8fe70$0$14487$5fc30a8@news.tiscali.it>
I'm learning AQ (Oracle 10.2.0.3 on Linux).
In my experiments, I'm enqueing messages with a PL/SQL script in SQL*Plus and trying to dequeue them with a little Java class.
I succesfully implemented the point-to-point model, but I'm not able to dequeue messages with the publish-subscribe model.
I get no errors, simply JMS messages are not "seen" at the Java side.
Here are the statements I used to create and start the queue:
---
exec dbms_aqadm.create_queue_table (queue_table=>'multi_message_table',
queue_payload_type=>'SYS.XMLTYPE', multiple_consumers=>true) ;
exec dbms_aqadm.create_queue (queue_name=>'multi_queue',
queue_table=>'multi_message_table') ;
exec dbms_aqadm.start_queue (queue_name=>'multi_queue') ;
exec dbms_aqadm.ADD_SUBSCRIBER (QUEUE_NAME=>'multi_queue', SUBSCRIBER=>
sys.aq$_agent ('SUBSCRIBER1','TEC_SCHEMA.MULTI_QUEUE',0)) ;
exec dbms_aqadm.schedule_propagation(queue_name=>'MULTI_QUEUE', latency
=>0);
--
Here's the PL/SQL script I'm using to enqueue messages:
--
declare
msg SYS.XMLType;
queue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
msg_props DBMS_AQ.MESSAGE_PROPERTIES_T;
msg_id RAW(16);
aprop sys.aq$_agent;
rlist dbms_aq.aq$_recipient_list_t ;
Begin
msg := SYS.XMLType.createXML('<?xml version="1.0"?>'<id>42</id>');
aprop := sys.aq$_agent(USER, NULL, 0);
queue_options.sequence_deviation := dbms_aq.top;
rlist(1) := sys.aq$_agent ('SUBSCRIBER1','TEC_SCHEMA.MULTI_QUEUE',0) ;
msg_props.sender_id := aprop;
msg_props.delay := dbms_aq.no_delay;
msg_props.recipient_list := rlist ;
DBMS_AQ.ENQUEUE(
queue_name => 'MULTI_QUEUE',
enqueue_options => queue_options,
message_properties => msg_props,
payload => msg,
msgid => msg_id
);
end ;
/
--
And here's the Java class I'm using to dequeue messages:
--
import oracle.jdbc.*;
import java.sql.*;
import oracle.jms.*;
import oracle.sql.*;
import oracle.xdb.*;
import javax.jms.*;
public class JmsQueue {
public static void main (String args[]) throws Exception
{
// Load the Oracle JDBC driver
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
// create a connection factory
java.util.Properties login = new java.util.Properties() ;
login.put("tec_schema","tecpw") ;
TopicConnectionFactory factory =
AQjmsFactory.getTopicConnectionFactory
("jdbc:oracle:thin:@testserv:1521:test",login);
// create an aq topic (=queue) connection, session and topic reference
TopicConnection conn =
factory.createTopicConnection("tec_schema","tecpw") ;
Session sess =
conn.createTopicSession(true,Session.CLIENT_ACKNOWLEDGE);
Topic topic =
((AQjmsSession)sess).getTopic("TEC_SCHEMA","MULTI_QUEUE");
// create a subscriber
ORADataFactory orad = oracle.xdb.XMLType.getORADataFactory();
TopicReceiver subscriber =
((AQjmsSession)sess).createTopicReceiver(topic,"SUBSCRIBER1",null,orad) ;
// waits 60 seconds for the message
System.out.println("wait (60
sec)..................................") ;
ObjectMessage msg = (ObjectMessage)subscriber.receive(60000) ;
}
}
--
I'm sure I'm missing something, but I'm not able to figure out what.
Any suggestion?
Kind regards, Y.
Received on Tue Sep 23 2008 - 09:34:24 CDT
