Giter Club home page Giter Club logo

oci-queue-node's Introduction

OCI Queue example in NodeJS with GitHub Actions

OCI Queue

Create Queue and copy the Queue OCID and Enpoint:

When using another region than EU_FRANKFURT_1 please modify the index.js Line #10 accordingly:

const region = common.Region.EU_FRANKFURT_1;

Policies

Setup policies for your user in the tenancy

e.g. Allow <USER_GROUP> to manage queues in compartment <COMPARTMENT>

More on OCI Queue IAM policies: https://docs.oracle.com/en-us/iaas/Content/queue/policy-reference.htm

Secrets

Setup secrets to run this example with GitHub Actions:

  • OCI_TENANCY: OCI Tenancy OCID
  • OCI_USER: OCI User OCID
  • OCI_FINGERPRINT: OCI User Fingerprint
  • OCI_KEY: OCI User Private Key
  • OCI_PASSPHRASE: OCI User Private Key passphrase (optional)
  • Q_ID: OCI Queue OCID
  • Q_ENDPOINTOCI Queue Endpoint

Run Action

Monitor the GitHub action to run:

This example will poll for messages in the queue and finally writes a new message to it.

View messages in the Queue

Running locally

Clone this repo, setup npm and oci cli and modify index.js line 8 by uncommenting it and removing/commenting lines 10-18 and replace lines 21-22 with Queue details :

// Use this locally instead of env vars and region:
const provider = new common.ConfigFileAuthenticationDetailsProvider();

// Q settings
const queueId = 'ocid1.queue.oc1.eu-frankfurt-1.ama....a5z4ic2tslq';
const endpoint = 'https://cell-1.queue.messaging.eu-frankfurt-1.oci.oraclecloud.com';

Then run:

npm install
node index.js

Sending messages to Queue

You can manually send messages to the queue using the OCI Queue Console
Actions/Send Message and then see them being received by re-running the build.

You can also play with the queue's Dead Letter Queue settings to see how many times the same message is being received (default is 5). To do this comment the line 61 of the index.js and re-run the build using commit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.