How to Send a Message to the Oracle Messaging Cloud Service with Node.js

const https = require('https');

const req = https.request({ auth: 'username:password', headers: { 'X-OC-ID-TOKEN-STATUS': 'disabled' }, hostname: 'host', method: 'PUT', path: '/service/api/v1/connections/SampleConnection' }, (res) => {

    if (res.statusCode == 201) {
      const cookies = res.headers['set-cookie'];

      const req = https.request({ auth: 'username:password', headers: { Cookie: cookies }, hostname: 'host', method: 'PUT', path: '/service/api/v1/sessions/SampleSession?connection=SampleConnection' }, (res) => {

          if (res.statusCode == 201) {
            const req = https.request({ auth: 'username:password', headers: { Cookie: cookies }, hostname: 'host', method: 'PUT', path: '/service/api/v1/producers/SampleProducer?destination=/queues/SampleQueue&session=SampleSession' }, (res) => {

                if (res.statusCode == 201) {
                  const req = https.request({ auth: 'username:password', headers: { Cookie: cookies }, hostname: 'host', method: 'POST', path: '/service/api/v1/producers/SampleProducer/messages' });

                  req.write('Simples Assim');

                  req.end();
                }

              });

            req.end();
          }

        });

      req.end();
    }

  });

req.end();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s