Skip to Main Content
  • Questions
  • Adding a value to JMS Queue from Oracle Database

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Abhi.

Asked: October 07, 2020 - 12:43 pm UTC

Last updated: October 09, 2020 - 8:15 am UTC

Version: 19C (19.0.0.0.0)

Viewed 1000+ times

You Asked

Platform: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 (A pleasure to have moved to Oracle 19c). Java Version in OracleHome: "1.8.0_201"

Hello Tom, A very wonderful morning for you and all experts. As always, my admiration for your efforts which makes our developer community learn and move forward.

Task: Add a value to the JMS queue from Oracle DB.

So we tried and read various approaches:

1. we tested a hello world java program and loaded into DB using loadjava tool. It worked. So we thought we will write a complex java class/jar which will take a value and add it to JMS queue. Tried to load a .jar files using loadjava and wrote a PL/SQL wrapper to call this Java Class.

Issue: After a successful load using loadjava, When we execute via Oracle PL/SQL Function, we are getting the following error.

"ORA-29532: Java call terminated by uncaught Java exception: javax.jms.JMSRuntimeException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory"


Our analysis: We thought it is missing some libraries of Weblogic. So we added wlthint3client.jar separately using loadjava utility. loadjava threw a lot of errors. We also tried to add wlthint3client.jar under "ORACLEHOME\jdk\jre\lib\ext" so that it gets picked up at instance load. But the error keeps happening. We included this as a part of our original jar yet the same issue.

Reached out to Service Request, they said "This looks like a third party jar files and you may have to check with the vendor about compatibility and confirm if it's been tested with 19c DB and compiled with JDK 1.8, tested outside DB as a standalone Java code."

2. We moved to Oracle JDBC package oracle.jdbc.aq. We created a DB Queue, added some data and created a Dequeue on Java as following:

AQDequeueOptions options = new AQDequeueOptions();
options.setDeliveryFilter(AQDequeueOptions.DeliveryFilter.BUFFERED);
AQMessage mesg = conn.dequeue("HR.MY_QUEUE", options, "RAW");


And it worked. Java when executed can now DEQUEUE a single value from Oracle Queue.

Issue: How will Java know when to Dequeue, it has no clue when a value got added to DB Queue? and we don't want Java to make millions of blind pings.

3. We looked into this promising 8 min video on Youtube called "OracleDB to ActiveMQ JMS". But couldn't make it work.

4. Finally, we moved to Stand-alone WebLogic AQ JMS Clients and started exploring that ( https://docs.oracle.com/middleware/12213/wls/JMSAD/aq_jms.htm#JMSAD628; https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/advanced-queuing.html#GUID-A74A1FDD-8984-411C-9706-19A0A6FF0429 ). We couldn't find a working example.

We have been eagerly waiting for the question button to show up on your portal. We assume that we overwhelmed ourselves Googleing and reading a variety of options. Kindly suggest a simple solution to our expedition so that Oracle DB or PL/SQL can drop a value into JMS queue, Or, have an integrated listener for Java to listen to DB Queue with an example if possible.

Thank you,
Aj and Team.

and Chris said...

1. As support said, it looks like an issue with the third party jar files.

2. You need to configure subscribers in Java. This is outside my expertise, so there's not much guidance I can give.

3. Uhhh, OK

4. I would check the Advanced Queuing Guide. This discusses configuring JMS queue extensively and using the Messaging Gateway to communicate with other queues, such as Websphere MQ

https://docs.oracle.com/en/database/oracle/oracle-database/19/adque/

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library