Dequeueing a SYS.AQ$_JMS_TEXT_MESSAGE
I am new to AQ please give me advice
I created queue with AQ$_JMS_TEXT_MESSAGE and I able to enqueue the message but I am not able to dequeue the message. How do I retrive messages using pl/sql
Thanks
Message was edited by:
sheebaann
declare
dequeue_options dbms_aq.dequeue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message SYS.AQ$_JMS_MESSAGE;
begin
-- dequeue_options.msgid := MsgId; <----------------Optional
dequeue_options.dequeue_mode := DBMS_AQ.REMOVE;
DBMS_AQ.DEQUEUE(
queue_name => <Your Q Name>,
dequeue_options => dequeue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
end;
Regards,
Sanjeev.
Similar Messages
-
I'm having a problem using DBMS_AQ package to dequeue a JMS message of type SYS.AQ$_JMS_TEXT_MESSAGE that was put on the queue using Java JMS API.
Both JMS header and payload return empty but if I do "select user_data" from the queue table, I can see the message.
Appreciate any helps or tips.
KimThis has been asked a lot of times - I'm not sure how my initial searching missed all of the other questions/answers related to this topic.
In our case, the solution was to:
1) Leave the queue as a sys.aq$_jms_text_message type
2) Construct a sys.xmltype object with our desired payload
3) Do a getStringVal() on the xmltype object and use that string as the payload for our queue message
- Nathan -
I am trying to write a web-service to Enqueue/Dequeue messages from an AQ with payload type SYS.AQ$_JMS_TEXT_MESSAGE defined in Oracle DB.
In my understanding is that I need to create a JMSModule within weblogic with a ForeignServer defined within it to enqueue/dequeue message to/from the AQ.
I have created Datasource, JMSServer, JMSModule, ForeignServer (created ConnectionFactory with localJNDIName="MyQueueCF" and RemoteJNDIName as "QueueConnectionFactory" and Destination with localJNDIName="MyQueueDest" and RemoteJNDIName="Queues/<queue_name_in_DB>")
My business service has an endpoint "http://localhost:7001/MyQueueCF/MyQueueDest"
When I am testing my service to populate message on to the Queue. I get the following error:
The error was oracle.jms.AQjmsException: Error creating the db_connection
My questions are:
* Am I following the correct procedure to talk to AQ with JMS text message type payload?
* If yes, how can I get around the issue I am stuck with?
Please help!
Thanks.
Edited by: user4696353 on 27-Sep-2011 11:43
Edited by: user4696353 on 27-Sep-2011 11:49
Edited by: user4696353 on 27-Sep-2011 12:25Example:
conn / as sysdba
begin
dbms_aqadm.create_queue_table
( queue_table=> 'SCOTT.AQJMS'
, queue_payload_type=> 'SYS.AQ$_JMS_TEXT_MESSAGE'
, compatible=> '9.1'
end;
This worked fine for me after a standard DB-installation. -
Problem enqueuing with SYS.AQ$_JMS_TEXT_MESSAGE payload
We are trying to enqueue a message into a SYS.AQ$_JMS_TEXT_MESSAGE AQ from java using the standard AQjmsQueueSender. The message arrives onto the queue but the USER_DATA is always 'oracle.sql.STRUCT@5a41ec' instead of the actual message. When we enqueue from PL/SQL the USER_DATA contains the actual message. Any help would be greatly appreciated. Thanks.
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
"CORE 10.2.0.4.0 Production"
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
QUEUE DETAILS
OWNER: EIMGR
QUEUE_TABLE: AQ_VENDORS_IN_TABLE
TYPE: OBJECT
OBJECT_TYPE: SYS.AQ$_JMS_TEXT_MESSAGE
SORT_ORDER: ENQUEUE_TIME
RECIPIENTS: SINGLE
MESSAGE_GROUPING: NONE
COMPATIBLE: 8.1.3
PRIMARY_INSTANCE: 0
SECONDARY_INSTANCE: 0
OWNER_INSTANCE: 1
USER_COMMENT: EI_QUEUE
SECURE: NO
CREATED: 09-09-03
LAST_DDL_TIME: 09-09-03
-------------------------------------------------------------------------------------We've discovered with PL/SQL that setting any headers on messages causes the same problem that we're seeing from JAVA. There is no option in JAVA to send messages without headers (it's part of the JMS spec). This can be seen with the following PL/SQL script (use null instead of HEADER in the message constructor to see it work):
DECLARE
Enqueue_options DBMS_AQ.enqueue_options_t;
Message_properties DBMS_AQ.message_properties_t;
Message_handle RAW(16);
User_prop_array SYS.AQ$_JMS_USERPROPARRAY;
Agent SYS.AQ$_AGENT;
Header SYS.AQ$_JMS_HEADER;
Message SYS.AQ$_JMS_TEXT_MESSAGE;
Message_text VARCHAR2(500);
BEGIN
Agent := SYS.AQ$_AGENT('',NULL,0);
User_prop_array := SYS.AQ$_JMS_USERPROPARRAY();
Header := SYS.AQ$_JMS_HEADER( Agent, '', 'dave', '', '', '', User_prop_array);
Message_text := 'Message from PL/SQL created at '|| TO_CHAR(SYSDATE, 'mm/dd/yyyy hh24:mi:ss');
Message := SYS.AQ$_JMS_TEXT_MESSAGE(Header, LENGTH(Message_text), Message_text, NULL);
DBMS_AQ.ENQUEUE(queue_name => 'AQ_VENDORS_IN',
Enqueue_options => enqueue_options,
Message_properties => message_properties,
Payload => message,
Msgid => message_handle);
COMMIT;
END; -
Hi all,
I am trying to get PLSQL notification working on a multi subscriber queue with sys.aq$jms_text_message as the payload type. The commands to create my queue are as follows:
dbms_aqadm.create_queue_table(
queue_table => 'SOA_JMS.RJMTESTxx_QTAB',
multiple_consumers => true,
queue_payload_type => 'sys.aq$_jms_text_message'
dbms_aqadm.create_queue(
queue_name=>'RJMTESTQ',
queue_table => 'SOA_JMS.RJMTESTxx_QTAB',
retention_time => 86400, --Keep processed messages for 24 hours
max_retries => 3,
retry_delay => 1
dbms_aqadm.start_queue('RJMTESTQ');
dbms_aqadm.add_subscriber(
queue_name => 'SOA_JMS.RJMTESTQ',
subscriber => sys.aq$_agent('SUBSCRIP1',null,0),
rule => NULL,
transformation => NULL,
queue_to_queue => FALSE,
delivery_mode => dbms_aqadm.persistent
I then create a procedure with the following signature:
create or replace procedure SOA_JMS.EXCEPTION_QUEUE_NOFIFYCB_1(
p_context in raw,
p_reginfo in sys.aq$_reg_info,
p_descr in sys.aq$_descriptor,
p_payload in raw,
p_payloadl in number
And register it as follows:
reginfo := sys.aq$_reg_info(
'SOA_JMS.RJMTESTQ:SUBSCRIP1',
DBMS_AQ.NAMESPACE_AQ,
'plsql://SOA_JMS.EXCEPTION_QUEUE_NOFIFYCB_1?PR=0',
--utl_raw.cast_to_raw('STANDARDJMS')
HEXTORAW('FF')
reg_list := sys.aq$_reg_info_list(reginfo);
dbms_aq.register(reg_list,1);
The problem is the notifications are not firing as they should be.
I have done some tracing and found an error:
Error in PLSQL notification of msgid:BA964334E5A057A4E040C69BAF397075
Queue :"SOA_JMS"."RJMTESTQ"
Consumer Name :SUBSCRIP1
PLSQL function :SOA_JMS.EXCEPTION_QUEUE_NOFIFYCB_1
: Exception Occured, Error msg:
ORA-00604: error occurred at recursive SQL level 2
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'EXCEPTION_QUEUE_NOFIFYCB_1'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
This says that the parameters I have for my procedure is wrong. Looking through the documents I think it is something to do with the ?PR=0 used in the register call, but I can’t find any documentation telling me what the required parameters are.
Does anyone here know?
Thanks
RobertHi,
I have found the solution and I am posting here in case it helps anyone else.
The paramater names must match the callback not just the types and in/out.
So the following works:
create or replace procedure SOA_JMS.EXCEPTION_QUEUE_NOFIFYCB_2(
context in raw,
reginfo in sys.aq$_reg_info,
descr in sys.aq$_descriptor,
payload in raw,
payloadl in number
Robert -
Publishing SYS.aq$_jms_text_message to Oracle Streams Queue
I've created a streams queue using dbms_streams_adm and by default the payload type for the queue created is Sys.AnyData. How do I publish a message of type aq$_jms_text_message in PL/SQL to this streams Queue. I guess it all comes down to converting aq$_jms_text_message to AnyData in pl/sql. Sys.AnyData does NOT have anything to convert aq$_jms_text_message.
Any help would be appreciated.
Thanks,
DasThis has been asked a lot of times - I'm not sure how my initial searching missed all of the other questions/answers related to this topic.
In our case, the solution was to:
1) Leave the queue as a sys.aq$_jms_text_message type
2) Construct a sys.xmltype object with our desired payload
3) Do a getStringVal() on the xmltype object and use that string as the payload for our queue message
- Nathan -
Sys.aq$_jms_text_message type queues message size limitations
Are there any size limitations for enqueing text messages into a sys.aq$_jms_text_message type queue using AQ?
yes, i understand how to describe something...
my question is how to get a list of properties.
this data type has get functions that take the name of a property. now how do i know that property name to get it? -
Problem dequeueing even with sys privilege - DEQUEUE ANY
On one database instance we are seeing this; Connected user has DEQUEUE ANY sys privileges;
However, a dequeue fails saying insufficient privileges; This works on other database instances?
Any ideas? This is with database - (10.2.0.3.0 - 64bit Production)
Thanks
Vijay
SQL> select * from USER_SYS_PRIVS;
USERNAME PRIVILEGE ADM
PUBLIC DEQUEUE ANY QUEUE NO
PUBLIC ENQUEUE ANY QUEUE NO
PUBLIC DEBUG CONNECT SESSION NO
PUBLIC DEBUG ANY PROCEDURE NO
PUBLIC SELECT ANY DICTIONARY NO
6 rows selected.
SQL> DECLARE
2 dOpt dbms_aq.DEQUEUE_OPTIONS_T;
3 mprop dbms_aq.message_properties_t;
4 deq_msgid RAW(16);
5 payLoadData MyPayload;
6 BEGIN
7
8 dOpt.wait := 1;
9
10
11 dbms_aq.dequeue(
12 queue_name => 'MyQueue',
13 dequeue_options => dOpt,
14 message_properties => mprop,
15 payload => payLoadData,
16 msgid => deq_msgid);
17
18 END;
19 /
DECLARE
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_AQ", line 335
ORA-06512: at line 11
SQL>Thanks for the comment;
I don't think this is a design flaw; Design is such that queues are owned by a separate
schema user; Our install/upgrade architecture requires that the DDL be executed by
a separate user. This prevents me from granting object level privileges on the queues
because they have to be granted as the owner of the queue; I get around that by
granting "DEQUEUE ANY QUEUE" sys privilege which can be granted by a non
queue object owner (by SYS or DBA).
See this related topic.
Granting queue privileges as a DBA user to queues not owned by DBA
Also, if this was a design flaw, then why would it work on other database instances?
The fact that I am granting "DEQUEUE ANY QUEUE" to PUBLIC should be sufficient for
any database user to dequeue the message. -
Hi All,
This is regarding issue related to Dequeuing of message from AQ on Linux platform using JAVA API. Our appliaction is sending message on AQ which has queue payload type of type 'SYS.AQ$_JMS_TEXT_MESSAGE'. For dequeuing of this message we are using method AQjmsTextMessage_C.getFactory() that returns CustomDatumFactory.
The code snippet is as follows:
AQDequeueOption dequeueOption = new AQDequeueOption();
message = ((AQOracleQueue)l_queue).dequeue(dequeueOption,AQjmsTextMessage_C.getFactory());
The code is working fine on Windows environment. I ran the code from JDev IDE and also from batch file which was hitting the Oracle AQ installed on Linux environment. In both the case either through IDE or through batch file the code is running properly.
The same code on Linux is not working properly i.e. when the method AQjmsTextMessage_C.getFactory() is called we are not able to get the CustomDatumFactory. We are not getting any errors/exceptions and the control is directly going to finally block of our method and we are not getting the message from AQ. We tried with different jar files that contain the AQjmsTextMessage_C class but still not able to figure out the issue(The jar files used are viz. aqapi.jar,aqapi12.jar,aqapi13.jar,aqapi_g.jar,aqapi12_g.jar,aqapi13_g.jar).
The script that we used for creating the queue is as follows:
BEGIN
dbms_aqadm.create_queue_table(
queue_table=>'SAMPLE_T',
queue_payload_type=>'SYS.AQ$_JMS_TEXT_MESSAGE',
multiple_consumers => false,
comment => 'Queue Table For Text Message'
END;
BEGIN
dbms_aqadm.create_queue (
queue_name => 'SAMPLE_Q',
queue_table => 'SAMPLE_T');
END;
BEGIN
dbms_aqadm.start_queue (queue_name=>'SAMPLE_Q');
END;
Please let me know if you have faced such issue on Linux environment or have any pointers about the same.
Regards,
AbhishekIf "control is directly going to finally block" there must be some (unchecked) runtime exception. Catch it.
try{
AQDequeueOption dequeueOption = new AQDequeueOption();
message = ((AQOracleQueue)l_queue).dequeue(dequeueOption,AQjmsTextMessage_C.getFactory());
} catch (Throwable t) {
t.printStackTrace()
}You probably just don't have native code in the library path. -
Message not deleting from Topic after successfully dequeue
Hi All,
Help please..
I need to design a process where message have to produce into a AQ JMS topic and later i have to consume the message from the same topic and publish to a Queue.
In order to move on this i have created a sample My_Topic1 and My_Queue1 with below syntax
Topic:-
EXEC dbms_aqadm.create_queue_table (queue_table=>'MY_Topic1', queue_payload_type=>'sys.aq$_jms_text_message', multiple_consumers=>true );
EXEC dbms_aqadm.create_queue(queue_name=>'MY_Topic1', queue_table=>'MY_Topic1');
EXEC dbms_aqadm.start_queue(queue_name=>'MY_Topic1');
Queue:-
EXEC dbms_aqadm.create_queue_table (queue_table=>'My_Queue1', queue_payload_type=>'sys.aq$_jms_text_message', multiple_consumers=>false);
EXEC dbms_aqadm.create_queue(queue_name=>'My_Queue1', queue_table=>'My_Queue1');
EXEC dbms_aqadm.start_queue(queue_name=>'My_Queue1');
Now i created Foreign server and create local and destination topic of queue.topics name and also created Data source of XAType.
Now my bpel process getting a message(which as one element of sting type) from a web service and i am producing the same message to Topic. Once the message published to topic in a separate composite my JMS Adaptor dequeue/Consume the message from the topic and subscribe it to queue.
The Above scenario working as expected but here what my observation on this
1)When i dequeue message from a topic using bpel process successfully i am able to subscribe the message to queue but the message still remain in the topic i think it suppose to get of the topic once successfully dequeued.
Even i check the subscriber topic table and one subscriber is listening to the topic.
2)If in case any error generated at the time of subscribing to the queue the message should rollback( because i am using XA Transaction) but i think it is not happening as i can see in my topic view aq$my_topic1 MGS_STATE changed to PROCESSED.
Can some one please let me know where i am going wrong.
Thanks in advance.
Regards,
Tarak.
Edited by: Tarak on Sep 9, 2012 8:47 PMThe behavior should be the process consume a message from the topic and will try to do its job. If this process fail, {code]
But in this message not there in topic even it is failed in soa process.....i am very much interested how this XA is working that the reason i am trying all this.What to do with a failed/expired message is usually configurable, but doesn't make sense to place it in the same topic again... If the messages are failing too quickly better to adjust the max_retries and retry_delay...I agress in real senario we will move to error queue. But in that case also some how we need to read the message from queue and publish to the end system.
I am just trying to understand the behavior and what i came to know is after all the retire fails message not going to topictable _E. But when i pass Expire time property or time to live then it is moving to error table.What do you mean? What server was restarted, the database or the soa server? Messages that still didn't reach the max retry number will still be retried...Wheni am bouncing my managed server soa_server1 i can see the invoke activity is trying to publish the message into queue... this is happens after server restart and suppose not to happen....
But thanks alot for the inputs...
Regards,
Tarak. -
MDB / AQ / RA problem: message not dequeued when put by PL/SQL to AQ
I’m facing the following problem: I have a setup a J2CA Resource Adapter for AQ (OEMS) and a MDB listener. As polling configuration I use the following:
<config-property>
<config-property-name>ListenerThreadMaxPollInterval</config-property-name>
<config-property-value>250</config-property-value>
</config-property>
According to the spec, this configuration should make sure that the underlying the JMS implementation polls the queue (AQ) every 250 ms in order to check whether there are available message.
When I send a message to the AQ using JMS, the message is dequeued within an acceptable time range.
However, when PL/SQL code enqueues messages directly to the AQ things do not work well:
1. When PL/SQL posts a message > 4096 kb (according to the spec messages > 4096 kb have to be posted in a different way, since a CLOB column is used) for the first time it takes about 4 minutes until the MDB picks it up. All subsequent messages are picked up immediately, which is not surprisingly since the documentation mentions that an adaptive strategy is used. 4 minutes is not acceptable for me.
2. When PL/SQL posts a message < 4096 kb the message expires on the AQ-queue (even though it is a non-expirable message), without being picked up by the MDB.
What do I do wrong? Help is needed and appreciated!With great pleasure I can announce 'a' solution for the problem stated. Apparently the JMS implementation expects certain JMS headers in the Oracle AQ message in order to fetch it from the AQ properly. The PL/SQL code, which caused the problem described in this post, looked like this:
declare
enqueue_options SYS.DBMS_AQ.enqueue_options_t;
message_properties SYS.DBMS_AQ.message_properties_t;
message_handle RAW (16);
user_prop_array SYS.aq$_jms_userproparray;
AGENT SYS.aq$_agent;
header SYS.aq$_jms_header;
MESSAGE SYS.aq$_jms_text_message;
p_xml_intern_bericht varchar2(8000);
p_len_message number;
begin
--p_xml_intern_bericht :='bla';
p_xml_intern_bericht :='test';
p_len_message := LENGTH (p_xml_intern_bericht);
dbms_output.put_line('->' ||p_len_message);
IF p_len_message > 4000
THEN
MESSAGE := SYS.aq$_jms_text_message (header,p_len_message,NULL,p_xml_intern_bericht);
ELSE
MESSAGE :=SYS.aq$_jms_text_message (header,p_len_message,p_xml_intern_bericht,NULL);
END IF;
DBMS_AQ.enqueue (queue_name => 'MY_AQ' ,
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => MESSAGE,
msgid => message_handle
COMMIT;
end;
After adding the required JMS headers as in the snipped below, the message was picked up immediately from the AQ:
declare
msg SYS.AQ$_JMS_TEXT_MESSAGE;
msg_hdr SYS.AQ$_JMS_HEADER;
msg_agent SYS.AQ$_AGENT;
msg_proparray SYS.AQ$_JMS_USERPROPARRAY;
msg_property SYS.AQ$_JMS_USERPROPERTY;
queue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
msg_props DBMS_AQ.MESSAGE_PROPERTIES_T;
msg_id RAW(16);
dummy VARCHAR2(4000);
begin
msg_agent := SYS.AQ$_AGENT('', null, 0);
msg_proparray := SYS.AQ$_JMS_USERPROPARRAY();
msg_proparray.EXTEND(1);
msg_property := SYS.AQ$_JMS_USERPROPERTY('JMS_OracleDeliveryMode', 100, '2', NULL, 27);
msg_proparray(1) := msg_property;
msg_hdr := SYS.AQ$_JMS_HEADER(msg_agent,null,'MY_SCHEMA',null,null,null,msg_proparray);
msg := SYS.AQ$_JMS_TEXT_MESSAGE(msg_hdr,null,null,null);
msg.text_vc := 'test';
msg.text_len := length(msg.text_vc);
DBMS_AQ.ENQUEUE( queue_name => 'MY_AQ'
, enqueue_options => queue_options
, message_properties => msg_props
, payload => msg
, msgid => msg_id);
commit;
end;
This solution was posted in the following blog: http://technology.amis.nl/blog/?p=2384. The environment in this blog is a Oracle XE database. The writer gets an ERROR when posting a message without adding the described JMS headers (see first pl/sql code snippet). Therefore he was forced to provide them in order to make AQ work for him.
The remarkable thing is that in our environment (Oracle 10.2.0.x) posting messages without the necessary JMS headers do not result in errors. The AQ accepts them but the JMS listener remains silent or receives them after an unacceptable amount of time.
This must definitely be a bug. Hope this information can help you to solve your PL/SQL AQ JMS problem. -
How to dequeue Oracle queue(enqueue in Ora) in java using JMS text message
I'm trying below java code but its giving me error:
public class testq {
public static void main(String[] args) throws Exception {
testq q = new testq();
AQSession aq_sess = createSession();
q.runTest(aq_sess);
public static AQSession createSession() {
Connection db_conn;
AQSession aq_sess = null;
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
/* Load the Oracle8i AQ driver: */
Class.forName("oracle.AQ.AQOracleDriver");
db_conn = DriverManager.getConnection("jdbc:oracle:thin:@10.10.10.10:1521:demo", "demo_app", "demo");
System.out.println("JDBC Connection opened ");
db_conn.setAutoCommit(false);
/* Creating an AQ Session: */
aq_sess = AQDriverManager.createAQSession(db_conn);
System.out.println("Successfully created AQSession ");
catch (Exception ex) {
System.out.println("Exception: " + ex);
ex.printStackTrace();
return aq_sess;
public void runTest(AQSession aq_sess) {
//AQQueueTable q_table;
AQQueue queue;
AQMessage message;
AQRawPayload raw_payload;
AQDequeueOption deq_option;
byte[] b_array;
Connection db_conn;
try {
db_conn = ((AQOracleSession)aq_sess).getDBConnection();
/* Get a handle to a queue - aq_queue4 in aquser schema: */
queue = aq_sess.getQueue ("myadmin", "STREAM_QUEUE_DEMO");
System.out.println("Successful getQueue");
/* Creating a AQDequeueOption object with default options: */
deq_option = new AQDequeueOption();
deq_option.setDequeueMode(AQDequeueOption.DEQUEUE_REMOVE);
/* Set wait time to 10 seconds: */
deq_option.setWaitTime(10);
/* Dequeue a message: */
message = queue.dequeue(deq_option);
System.out.println("Successful dequeue");
/* Retrieve raw data from the message: */
raw_payload = message.getRawPayload();
b_array = raw_payload.getBytes();
db_conn.commit();
String value = new String(b_array);
System.out.println("queue="+value);
} catch(Exception e) {
e.printStackTrace();
The error says "oracle.AQ.AQException: JMS-174: Class must be specified for queues with object payloads
Use dequeue(deq_option, payload_fact) or dequeue(deq_option, sql_data_cl)"
Can any one tell me how to fix this error & how to get bulk dequeue messages?
And i am using sys.AQ$_JMS_TEXT_MESSAGE payload type during enqueue.
Can any one tell me how to fix this Java program to dequeue it?
Thanks in advance...Please its urgent
Thanks!the code is as bellow
File fBlob = new File ("test.pdf");
FileInputStream fIS = new FileInputStream(fBlob);
pstUpdate= con.prepareStatement("UPDATE table set file = ? where id = ?");
pstUpdate.setBinaryStream(1, fIS, (int) fBlob.length());
pstUpdate.setString(2, rs.getString("id"));
pstUpdate.execute();
con.commit(); -
Problem Dequeueing JMS_TEXT_MESSAGE payload
I am writing a .net app to dequeue messages using ODP.net 11g Release 2 (11.1.0.7.20). The payload type is SYS.AQ$_JMS_TEXT_MESSAGE.
When I make the dequeue call (DEQUEUE or DEQUEUEARRAY) I am get the following error:
ORA-25215: user_data type and queue type do not match
Which message type (RAW, XML or UDT) should be used for SYS.AQ$_JMS_TEXT_MESSAGE?
Below is the script that creates the queue table and queue:
SYS.DBMS_AQADM.CREATE_QUEUE_TABLE
QUEUE_TABLE => 'EEGADMIN.EEG_TOPIC_TAB'
,QUEUE_PAYLOAD_TYPE => 'SYS.AQ$_JMS_TEXT_MESSAGE'
,COMPATIBLE => '10.0.0'
,STORAGE_CLAUSE => '
TABLESPACE DDRP_DATA
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
,SORT_LIST => 'ENQ_TIME'
,MULTIPLE_CONSUMERS => TRUE
,MESSAGE_GROUPING => 0
,COMMENT => 'Keep eeg events in XML format'
,SECURE => FALSE
SYS.DBMS_AQADM.CREATE_QUEUE
QUEUE_NAME => 'EEGADMIN.EEG_TXT_TOPIC'
,QUEUE_TABLE => 'EEGADMIN.EEG_TOPIC_TAB'
,QUEUE_TYPE => SYS.DBMS_AQADM.NORMAL_QUEUE
,MAX_RETRIES => 2147483647
,RETRY_DELAY => 0
,RETENTION_TIME => 86400
,COMMENT => 'EEG event topic'
Any help would be greatly appreciated.Ski...Thank you for the assistance! That did the trick. Once I created the .Net class and set the UdtTypeName I was dequeueing fine.
Unfortunately, I now have one more issue. The MessageId is now null for the messages dequeued. I say "now", because previously I was dequeueing with a third party library (dotConnect for Oracle by Devart) and the MessageId was populated on the messages dequeued. According to the ODP for .NET Developers Guide,
"Dequeued buffered messages have a null value for MessageId".
But, I have verified that the queue is persistant and I am setting the message delivery mode to persistent in my code. I know the ids are in the queue and are returned with the third party library. I realize you can't speak to the third party library. I reference it here to demonstrate that the id's are there. Since the third party library basically wraps the Oracle DBMS_AQ.Dequeue() as I would imagine ODP does as well, that would seem to imply that the queue is persistent and the Dequeue is returning the ids and that I am missing something on my side. Am I missing something else?
Thanks again. -
Some of the messages aren't dequeued using JMS/AQ
Hi.
I am having strange problems dequeuing messages from an Oracle9i Release 2 database. I have a trigger that sends a message everytime a table is updated. When I have SQL worksheet and update the table through a SQL statement then I only recieve about 50-70% of the events. When I use Oracle Enterprise Manager Console I can see the rest of the messages are lying in the queue as 'READY'.
I need this to be VERY reliable so if anyone have any ideas I would really appreciate it. I used PL/SQL in the DB because of the speed increase but maybe a Java Stored Procedure will work better? I have included the code in question below.
Best regards
Christer Nordvik
JAVA code
//get a DB connection to use with JMS
dbconn = prevision.database.DBPool.getConnection();
//try to estabilish a connection to the JMS server to recieve alarm updates
tconn = AQjmsTopicConnectionFactory.createTopicConnection(dbconn);
/* Create a Topic Session */
tsess = (AQjmsSession)tconn.createTopicSession(true, Session.DUPS_OK_ACKNOWLEDGE);
tconn.start();
topic = ((AQjmsSession)tsess).getTopic("TS",strTopic) ;
tsub1 = tsess.createDurableSubscriber(topic, "T");//unique id
while (!done)
//waits forever
logger.debug("Waiting for alarms...");
dtxtmsg = (TextMessage)(tsub1.receive());
//found a message
logger.debug("Recieved alarm " + dtxtmsg.getText());
PL/SQL code
AS
BEGIN
DECLARE
Enqueue_options DBMS_AQ.enqueue_options_t;
Message_properties DBMS_AQ.message_properties_t;
Message_handle RAW(16);
User_prop_array SYS.AQ$_JMS_USERPROPARRAY;
Agent SYS.AQ$_AGENT;
Header SYS.AQ$_JMS_HEADER;
Message SYS.AQ$_JMS_TEXT_MESSAGE;
Message_text VARCHAR2(100);
gt1 number;
BEGIN
Message_properties.expiration := 3600; --Set the time to live for the message
gt1:= DBMS_UTILITY.GET_TIME;
Agent := SYS.AQ$_AGENT('',NULL,0);
User_prop_array := SYS.AQ$_JMS_USERPROPARRAY();
Header := SYS.AQ$_JMS_HEADER( Agent, '', 'aq1', '', '', '', User_prop_array);
Message_text := 'Message 1 from PL/SQL';
Message := SYS.AQ$_JMS_TEXT_MESSAGE(Header, LENGTH(Message_text), Message_text, NULL);
--setting the id of the sender
Message_properties.correlation := 'tst';
--Message_properties.correlation := gt1;
DBMS_AQ.ENQUEUE(queue_name => 'ts.tstopic',
Enqueue_options => enqueue_options,
Message_properties => message_properties,
Payload => message,I figured it out. Was something wrong with the trigger in the DB...
-
Hello everyone,
DB version : 11.2.0.1.0
I'm able to add a text message on an AQ queue, but I'm not able to dequeue it from java.
When I run the dequeue method, it waits ... it doesn't get any message in, even if new messages are being put on the queue.
What am I missing ?
Creation of the AQ queue:
EXEC DBMS_AQADM.STOP_QUEUE('textmessage_queue');
EXEC DBMS_AQADM.DROP_QUEUE('textmessage_queue');
EXEC DBMS_AQADM.DROP_QUEUE_TABLE('queue_textmessage_table');
EXEC DBMS_AQADM.CREATE_QUEUE_TABLE (queue_table => 'queue_textmessage_table', queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE', multiple_consumers => false);
EXEC DBMS_AQADM.CREATE_QUEUE (queue_name => 'textmessage_queue', queue_table => 'queue_textmessage_table');
EXEC DBMS_AQADM.START_QUEUE (queue_name => 'textmessage_queue');The createJMSClient(); used by the enqueue and dequeue methods
private JMSTopic createJMSClient() {
JMSTopic aq = new JMSTopic();
try {
TopicConnectionFactory topicConnectionFactory = null;
// Get topic connection factory
Properties info = new Properties();
info.put(userName, userPassword);
topicConnectionFactory = AQjmsFactory.getTopicConnectionFactory(connectString, info);
// Creates an AQ topic connection and session
aq.connection = topicConnectionFactory.createTopicConnection(userName, userPassword);
// If a session is transacted, message acknowledgment is handled automatically
// by commit and recovery is handled automatically by rollback
aq.session = aq.connection.createTopicSession(true, // Session is transacted
Session.CLIENT_ACKNOWLEDGE); // Acknowledges by commit and rollback
System.out.println("Successfully created AQ session");
} catch (Exception ex) {
System.err.println("AQApplication.createJMS(): " + ex.getMessage());
System.err.println("user = " + userName + ", password = " + userPassword + ", destination = " +
connectString);
ex.printStackTrace();
return aq;
}Java code to enqueue a text message
JMSTopic client = myMessage.createJMSClient();
AQjmsSession aqjmssession = (AQjmsSession) client.session;
AQjmsDestination destination = (AQjmsDestination)aqjmssession.getQueue(myMessage.DB_AQ_ADMIN_NAME, "textmessage_queue");
TextMessage createTextMessage = aqjmssession.createTextMessage("This is my first text message");
MessageProducer producer = aqjmssession.createProducer(destination);
producer.send(createTextMessage);
aqjmssession.commit();Java code to dequeue a text message
JMSTopic client = myMessage.createJMSClient();
AQjmsSession aqjmssession = (AQjmsSession)client.session;
AQjmsDestination destination =
(AQjmsDestination)aqjmssession.getQueue(myMessage.DB_AQ_ADMIN_NAME, "textmessage_queue");
MessageConsumer consumer = client.session.createConsumer(destination);
System.out.println("Waiting for a message ...");
Message message = consumer.receive();
System.out.println("Message received !!");You have to start the connection (aq.connection) to receive the message. This is not required for enqueue, but required for dequeue.
Maybe you are looking for
-
Image won't print on pdf form.
I copied an image (jpeg) onto my pdf form. When I print the form the image doesn't print. The handles around the image are blue instead of black. Can I somehow embed this image onto the form?
-
DLL's - Websphere MQ and Java Client
I am trying to post a message to Websphere MQ by using JMS Admin and Webspehre Application server. I have configured JMS Admin for registering the JNDI name with app server. I am using a standalone java (makes IIOP call) Application for posting the m
-
Hello I am new To JAVA SWING I have 2 questions related to JTable 1) How do i remove selected row in JTable ...for instance, I click on the row to delete (It is selected) , later I press the delete button, and then row is removed .... any hints ? 2)
-
Query 300 plus workstation to see what version of office is installed locally
I have over 300 workstations in the environment, most of them running office 2010; however there are still some running 2003. Is there a easy way to find out which ones have office 2010 or office 2003. I am not even sure this is possible. If there is
-
Billing due list missing order total amount
The billing due list in VF04 doesn't show the order total dollars. What's some of the ways that you've delt with this? Custom report? Another canned report?