Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> AQ Java API and RAW payload
I'm using the Java API for Advanced Queuing on Oracle v8.1.5 EE. The payload for my test queue is of type RAW. I'm having difficultly in converting the dequeued payload from its RAW format to a string.
The administrative side of creating the queue table, the queue and the enqueuing of the message string "ad" is achieved via PL/SQL. I want the java application to display a dequeued message of "ad".
I have written a java application that reads from the queue. The code snippet is ...
. . .
message = queue.dequeue(deq_option);
AQRawPayload payload = (AQRawPayload)message.getRawPayload();
System.out.println("RAW payload is <" + payload + ">");
byte[] byte_payload = payload.getBytes();
System.out.println("Byte payload length is <" + byte_payload.length
+ ">");
for (int i = 0; i < byte_payload.length; i++) {
System.out.println("value at index #" + i + " = " + byte_payload
[i]);
}
System.out.println("Byte payload is <" + byte_payload + ">");
System.out.println("String payload is <" + byte_payload.toString()
+ ">");
The output on the W2K command window with an enqueued message of "ad" was
RAW payload is <Length: 2Data : 6164>
Byte payload length is <2>
value at index #0 = 97
value at index #1 = 100
Byte payload is <[B_at_408fc193>
String payload is <[B_at_408fc193>
Why is the RAW payload showing data of 6164 when I enqueued 'a' and 'b' with their respective ascii values of 97 and 100?
The values for the last 2 debug lines change with each invocation so I think they may possibly be addresses for the objects.
I have played around with this using the PL/SQL interface to AQ where I use utl_raw.cast_to_raw() to cast my payload from varchar2 to raw when enqueuing and utl_raw.cast_to_varchar2() to convert the RAW payload back to varchar2 when dequeuing. This works as expected.
Any ideas as to achieving the same functionality in Java? Have I missed something very basic here?
Thanks in advance.
Regards
Trevor
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu Jul 06 2000 - 00:00:00 CDT
![]() |
![]() |