How to Send a Pull/Push Notification to the Oracle Messaging Cloud Service with JavaScript

const req = new XMLHttpRequest();

req.open("PUT", "https://host/service/api/v1/connections/SampleConnection", true, "username", "password");

req.setRequestHeader("X-OC-ID-TOKEN-STATUS", "disabled");

req.onreadystatechange = () => {

  if ((req.readyState === XMLHttpRequest.DONE) && (req.status === 201)) {
    const req = new XMLHttpRequest();

    req.open("PUT", "https://host/service/api/v1/sessions/SampleSession?connection=SampleConnection");

    req.onreadystatechange = () => {

      if ((req.readyState === XMLHttpRequest.DONE) && (req.status === 201)) {
        const req = new XMLHttpRequest();

        req.open("PUT", "https://host/service/api/v1/producers/SampleProducer?destination=/topics/SampleTopic&session=SampleSession");

        req.onreadystatechange = () => {

          if ((req.readyState === XMLHttpRequest.DONE) && (req.status === 201)) {
            const req = new XMLHttpRequest();

            req.open("POST", "https://host/service/api/v1/producers/SampleProducer/messages");

            req.send('Simples Assim');
          }

        };

        req.send();
      }

    };

    req.send();
  }

};

req.send();
Advertisements

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