09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Enqueuing a Message [Add Payload]<br />

}<br />

raw_payload = message.getRawPayload();<br />

raw_payload.setStream(b_array, b_array.length);<br />

/* Create a AQEnqueueOption object with default options: */<br />

enq_option = new AQEnqueueOption();<br />

/* Enqueue the message: */<br />

queue.enqueue(enq_option, message);<br />

db_conn.commit();<br />

/* Enqueue a message with priority = 5 */<br />

public static void example(AQSession aq_sess) throws AQException, SQLException<br />

{<br />

AQQueue queue;<br />

AQMessage message;<br />

AQMessageProperty msg_prop;<br />

AQRawPayload raw_payload;<br />

AQEnqueueOption enq_option;<br />

String test_data = "priority message";<br />

byte[] b_array;<br />

Connection db_conn;<br />

db_conn = ((AQ<strong>Oracle</strong>Session)aq_sess).getDBConnection();<br />

/* Get a handle to the queue */<br />

queue = aq_sess.getQueue ("aq", "msg_queue");<br />

/* Create a message to contain raw payload: */<br />

message = queue.createMessage();<br />

/* Get Message property */<br />

msg_prop = message.getMessageProperty();<br />

/* Set priority */<br />

msg_prop.setPriority(5);<br />

/* Get handle to the AQRawPayload object and populate it with raw data: */<br />

b_array = test_data.getBytes();<br />

raw_payload = message.getRawPayload();<br />

11-20 <strong>Oracle</strong>9i Application Developer’s Guide - <strong>Advanced</strong> <strong>Queuing</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!