Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> How-to send a non-persistent (BUFFERED) message using JMS?
I'm trying to send a BUFFERED (in Oracle terms) message using JMS. I
would expect the Oracle implementation of JMS to map the JMS
non-perisstent delivery mode in the Oracle BUFFERED delivery mode.
However, try as I might my JMS programs always send messages as
persistent. Why? Is there any way I can send a BUFFERED AQ message
using JMS? I can soo easily do that using PL/SQL I'm just trying to
accomplish the same thing from a different programmatic environment.
This is on Oracle 10.2.1 jars from 10.2.1 as well.
import javax.jms.*;
import oracle.jms.*;
import oracle.xdb.*;
public class jms
{
public static void main (String args []) throws java.sql.SQLException, ClassNotFoundException, JMSException { trySession.CLIENT_ACKNOWLEDGE);
{
String ora_sid = "tap620"; String host = "hadrian"; String schema = "ops$tromanow"; String password = "tromanow"; String queueName = "Q_XML_RFD_OUTPUT"; int port = 1521; Enqueue(ora_sid, host, schema, password, queueName, port); System.out.println("You should see 3 messages in Q_XML_RFD_INPUT. Should be buffered but they are persistent instead"); } catch (Exception ex)
{
System.out.println("Exception: " + ex); } } public static void Enqueue(String ora_sid, String host, String schema, String password, String queueName, int port) { QueueConnectionFactory qc_fact = null; QueueConnection q_conn = null; QueueSession q_sess = null; java.sql.Connection db_conn = null; Queue queue = null; AdtMessage adt_msg = null; QueueSender q_sender = null; oracle.xdb.XMLType xtype = null; String data = null; try
{
qc_fact = AQjmsFactory.getQueueConnectionFactory(host, ora_sid, port, "thin"); q_conn = qc_fact.createQueueConnection(schema, password); q_sess = q_conn.createQueueSession(true,
q_conn.start(); db_conn = ((AQjmsSession)q_sess).getDBConnection(); queue = ((AQjmsSession)q_sess).getQueue(schema, queueName); q_sender = q_sess.createSender(queue); adt_msg = ((AQjmsSession)q_sess).createAdtMessage(); data = "<bolek>olek</bolek>"; xtype = oracle.xdb.XMLType.createXML(db_conn, data); adt_msg.setAdtPayload(xtype); //try sending a buffered message, different ways, none of them works! ((AQjmsQueueSender)q_sender).send(queue, adt_msg, DeliveryMode.NON_PERSISTENT, 1, AQjmsConstants.EXPIRATION_NEVER); q_sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT); ((AQjmsQueueSender)q_sender).send(queue, adt_msg, DeliveryMode.NON_PERSISTENT, 1, AQjmsConstants.EXPIRATION_NEVER); adt_msg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); ((AQjmsQueueSender)q_sender).send(queue, adt_msg, DeliveryMode.NON_PERSISTENT, 1, AQjmsConstants.EXPIRATION_NEVER); q_sess.commit(); q_sess.close(); q_conn.close(); } catch (Exception e)Received on Wed Jun 14 2006 - 10:41:11 CDT
{
System.out.println("Exception: " + e); } }
![]() |
![]() |