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 -> Re: AQ Java API and RAW payload

Re: AQ Java API and RAW payload

From: <trevor_vaughan_at_hotmail.com>
Date: 2000/07/07
Message-ID: <8k462o$bfg$1@nnrp1.deja.com>#1/1

The constructor method of the String class accepts a byte array so that solves my problem. As Steve Bromeley pointed out I was viewing the data in hex and decimal format. In the former I didn't RTFM and the latter was due to a long day.
In article <8k2n9d$dgl$1_at_nnrp1.deja.com>,   trevor_vaughan_at_hotmail.com wrote:
> 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 ...
>
> ----------------
> import java.math.*;
> import java.sql.*;
> import oracle.AQ.*;
>
> .
> .
> .
>
> 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.
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Fri Jul 07 2000 - 00:00:00 CDT

Original text of this message

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