title: How to enqueue a JMS message into Oracle AQ using Java
body: <p>I have an Oracle AQ with the queue type of SYS.AQ$_JMS_TEXT_MESSAGE. What I'm trying to do is to insert a text into the mentioned queue from a java application.</p>
  
  <p>The equivalent SQL query is</p>
  
  <pre><code>declare
   r_enqueue_options    DBMS_AQ.ENQUEUE_OPTIONS_T;
   r_message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
   v_message_handle     RAW(16);
   o_payload            SYS.AQ$_JMS_TEXT_MESSAGE;
  begin
   o_payload := sys.aq$_jms_text_message.construct;
   o_payload.set_text(xmltype('&lt;user&gt;text&lt;/user&gt;').getClobVal());
   sys.dbms_aq.enqueue (
     queue_name         =&gt; 'QUEUE_NAME',
     enqueue_options    =&gt; r_enqueue_options,
     message_properties =&gt; r_message_properties,
     payload            =&gt; o_payload,
     msgid              =&gt; v_message_handle
   );
   commit;
  end;
  /
  </code></pre>
  
  <p>I got most of it right using <a href="http://docs.oracle.com/cd/B28359_01/java.111/b31224/streamsaq.htm" rel="noreferrer">this guide</a>, but I'm stuck at</p>
  
  <pre><code> o_payload := sys.aq$_jms_text_message.construct;
   o_payload.set_text(xmltype('&lt;user&gt;text&lt;/user&gt;').getClobVal());
  </code></pre>
  
  <p>The guide shows how to enqueue a RAW message, but I need it to be JMS, otherwise the data type doesn't match the queue type.</p>
  
  <p>Any help would be appreciated, because even with the almighty google I am not able to find a solution to this problem. Is there a way to do it using the <code>oracle.jdbc.aq</code> classes, or do I just have to suck it up and use the SQL query?</p>