recursive.codes

recursive.codes

recursive.codes


The Personal Blog of Todd Sharp

Quick Pub/Sub Testing for Oracle Advanced Queuing With a Command Line Interface (CLI)

Posted By: Todd Sharp on 11/5/2021 8:00 GMT
Tagged: Java, Messaging

I have been spending a lot of time playing around with Oracle Advanced Queuing (AQ) lately and one of the things that has bothered me is the lack of a Command Line Interface (CLI) that can quickly test message enqueuing (publishing) and dequeuing (subscribing). It can be tedious to spin up an entire sample application just to publish a few messages to see if your queue is working as expected. I've spent a good amount of time working with other messaging solutions - from MQTT to Kafka - and just about every one of them have some sort of CLI that can be used for this purpose. So, instead of just complaining about it on Twitter, I decided to build one! The CLI was built with Micronaut (using Picocli) and converted to a native image with Graal (with support for Windows, Mac and Linux). I won't go into the details of how I built the CLI in this post, but you're more than welcome to check out the source code on GitHub. Instead, let's take a look at how to use it! Here's what we'll cover in this post:

Download and Install

To get started, download the latest release (v0.0.1 as of this post). Depending on your OS, you might have to make the binary executable and/or move it to your path for easier invocation. Once that's done, we're ready to use it! Yay for quick and easy download and install! I've downloaded the Mac version, and added it to my path so that I can execute it with aq.

How to Use the CLI

It's not difficult to use. There are two commands: enqueue and dequeue. You'll also need to pass credentials so the CLI can authenticate. That can be done in one of three ways:

We'll go over examples of each of these auth types below. To get help at anytime, just use aq --help which will output a help doc that looks like so:

Enqueuing Messages

Enqueuing a message is done with the enqueue command. 

Enqueue With an Autonomous DB Wallet 

Note: To use an Autonomous DB wallet, you'll need to have previously configured the OCI CLI and have a local config file already set up.

You'll need your wallet OCID, the OCI profile to use, and the path to the profile.

Enqueue With a TLS Enabled Autonomous DB Connect String

Enqueue With a Host, Port and Service Name

Enqueue Output

Using any of the above methods, you should see output similar to the following.

Dequeuing Messages

Dequeuing is done with the dequeue command. Dequeuing messages will stream all incoming messages until you interrupt it with CTRL+C.

Dequeue With an Autonomous DB Wallet 

Dequeue With a TLS Enabled Autonomous DB Connect String

Dequeue With a Host, Port and Service Name

Dequeue Output

Summary

And that's it! Quick and easy pub/sub to AQ from a CLI. If you have any questions or suggestions, please file an issue on GitHub or leave a comment below!



Related Posts

Querying Autonomous Database from an Oracle Function (The Quick, Easy & Completely Secure Way)

Querying Autonomous Database from an Oracle Function (The Quick, Easy & Completely Secure Way)

I've written many blog posts about connecting to an Autonomous DB instance in the past. Best practices evolve as tools, services, and frameworks become...

Sending Email With OCI Email Delivery From Micronaut

Sending Email With OCI Email Delivery From Micronaut

Email delivery is a critical function of most web applications in the world today. I've managed an email server in the past - and trust me - it's not fun...

Brain to the Cloud - Part III - Examining the Relationship Between Brain Activity and Video Game Performance

Brain to the Cloud - Part III - Examining the Relationship Between Brain Activity and Video Game Performance

In my last post, we looked at the technical aspects of my Brain to the Cloud project including much of the code that was used to collect and analyze the...

Note: Comments are currently closed on this blog. Disqus is simply too bloated to justify its use with the low volume of comments on this blog. Please visit my contact page if you have something to say!