Chapter 8. Publish and Subscribe with External Applications

In Chapter 3, Distribute Messages Using the Pub-Sub Model, we introduced the idea of publishing and subscribing within ICS and looked at the benefits of using such a framework. However, the ICS publish and subscribe mechanism only works within ICS and cannot be accessed directly from external applications. Oracle does, however, offer a service known as Oracle  Messaging Cloud Service (OMCS) as part of its platform as a service group of services (https://cloud.oracle.com/messaging). This provides all the benefits of publish and subscribe, as well as a provider-consumer pattern.

OMCS is an enterprise messaging solution built using WebLogic Messaging at its heart, but it extends this to provide a framework, which means clients can utilize the messaging infrastructure through web services and have the means to mitigate against certain types of security attacks.

For developers, OMCS is a powerful tool, as it implements the mature industry standard API known as Java Messaging Service (JMS). This means that it can be very simple to integrate messaging into third-party solutions. In addition to this, ICS has an adapter dedicated to supporting OMCS.

In this chapter, we are going to demonstrate how OMCS can be easily connected to ICS; both as a triggering system and as a target for ICS to invoke.

Throughout this chapter, we will demonstrate a simple integration where we send aircraft updates into OMCS to then be consumed by ICS and placed in another OMCS message queue. The second message queue will be consumed by another part of the application that creates the events. Our application will preclude the need to use SoapUI in this chapter or any of the other mocking frameworks. This means that the integration will look like the following diagram:

Publish and Subscribe with External Applications

We are going to run the Java application locally, but there should not be any reason why it could not be executed from Oracle's Java Standard Edition Cloud Service if you wanted.

Preparation

First and foremost, we need an account that provides access to OMCS; this can be a trial account. We are not going to walk you through the process of applying for an OMCS trial service, as many of Oracle's services are straightforward and the chances are you may have used a trial account to get started with ICS. OMCS can be found at https://cloud.oracle.com/messaging. Additional information on setting up OMCS can be found at https://oracle-integration.cloud.

Tip

For some Oracle PaaS solutions to work together, they are required to work within the same domain (that is, the domain ID provided when commissioning the service). Note that this is not the case for web services using WSDL and SOAP, but for other connections it is necessary. If in doubt, talk with Oracle before commissioning the services.

Once the service has been activated, no additional preparation with OMCS is needed, as our Java application will create the queues.

As you can see in the preceding diagram, we will need a small Java application. We could of course use SoapUI to load the message queue, but by using a Java application you get to see how you can communicate with OMCS via a JMS API. The Java application is available as source code, along with a JAR from the book's download site. With it are some configuration files you will need to modify to connect to your instance of ICS. This doe means you do not need to have any Java development skills, but you do need to have a JRE or JDK installed wherever you want to run the application from. Of course, if you are a developer, you will understand by looking at the code how to exploit the Java library provided.

We are going to assume you have successfully installed Java or have had it installed for you, and that it is available to you in the system PATH. This can be confirmed using the java -version command. If Java is installed and set up as needed, then you will see the Java version installed. If not, then either Java is not installed or not on your path. A solution for the latter can be found at https://www.java.com/en/download/help/path.xml.

Overview of our Java application

As previously mentioned, the Java application makes it easy to demonstrate the use of OMCS. By utilizing the OMCS library, our application is able to exploit the full capabilities of the JMS standard. As a result, when executing the application, it will read a .properties file, which will contain your OMCS credentials, and then connect to the server. It will check for the existence of two queues:

  • TrackerQueue
  • ProcessedQueue

If the queues do not already exist, then the application will create them. Once created, two threads are launched; one will read a file of position updates and add one every 30 seconds to the TrackerQueue. The messages (XML defined by a schema in the JAR file) in this queue are then  passed to ICS, transformed and placed in the ProcessedQueue. A second thread in our application then consumes the messages in this queue. As each message is consumed, the application logs what is consumed, so you can see what is happening.

The dataset provided is large enough for you to see this happening for a couple of hours, giving you time to view the activity via the ICS monitoring views if you wish.

The application has been built in such a manner that, by adding some additional configuration information to the JAR file, it can be deployed and run in the Oracle Java Cloud https://docs.oracle.com/cloud/latest/jcs_gs/ (WebLogic server in the cloud for hosting apps), or the Application Container Cloud https://cloud.oracle.com/acc, which can run Java SE style applications (along with other things such as Node.js), although we will not be using these services here.

Within the download resources are the resources necessary to enable you to rebuild the application, so it can be used as the basis for other experiments if desired.

Configuring ready to go

Once you have downloaded the JAR file, if you open the file (a JAR file is just a special zip file), you will see your preferred zip file tool in the various folders:

  • Configuration attributes for OMCS-- esourcesinstance.properties
  • Test data-- esourcesKL605_AMS_SFO.csv
  • Source code
  • OMCS library
  • Class files--icsook racker

We do need to do a little bit of configuring, as mentioned, so we need to extract and modify the OMCS connection-we need to tell the application which instance of the OMCS service to use and provide the authenticating credentials to allow a messaging connection to be established. The PROPERTIES file is called instance.properties and can be found in the esources folder.

All the other changes are entirely up to you, such as the data to be played into the system, but in case you do want to change this, then the data is located at esources.

With all of this prepared, we can start the application up to ensure there are not any problems. To do this, you need to open a Command Prompt and issue the following command in a shell console:

java -jar "FlightPositionTracker.jar"

If everything has been successful, you should see something like the following screenshot:

Configuring ready to go

You will note that the messages are being slowly added to one queue, but nothing is being retrieved from the output because the ICS integration is not running yet.

With our connectivity established and proven, let's stop the application and start setting up the ICS side of things.

The last piece of preparation is getting the FlightPathOMCS.xsd, which is provided. This schema is needed to allow us to define structure to the message payload for the inbound and outbound messages being put onto the OMCS provided queue.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset