Pivotal Cloud Foundry

So I wanted to learn about Pivotal Cloud Foundry (PCF) and it turns out there is a free intro available:

https://pivotal.io/platform/pcf-tutorials/getting-started-with-pivotal-cloud-foundry/introduction

What is PCF? I don’t really know. But I think PCF is what folks call a “Platform-as-a-Service” cloud offering. You can Google all the different cloud options (SaaS, PaaS, IaaS, etc) but essentially PCF provides a platform to deploy Applications you write in a lot of different languages (Java, .NET, Node.js, etc). And you get to focus on writing the application and PCF owns how your application runs. PCF can also connect your app to services like databases and monitoring tools automatically. And that entire stack of your app and everything that supports it can be managed using PCF tools like an admin console through your web browser or a command-line interface (CLI) on your local machine. You can start and stop apps, scale them, add and remove services, etc. And PCF isn’t really a specific cloud provider…its a framework you can take and put almost wherever you want, like Amazon Cloud, somewhere in your enterprise or even your local PC.

So I ran through the intro linked above and have a few small notes:

  1. You have to setup a Pivotal Web Services (PWS) account first – but you need to do more than get a login name. You’ll have to validate your email and then you need to actually log into PWS and setup a default Org (like a way to group your apps). Once you do that, download CLI and do the git stuff and then “cf push” will work. “cf push” didn’t work for me until I setup that PWS Org.
  2. I had to download git for Windows and I used the Git GUI to clone the repository on the “Deploy the Sample App” page. I just created a local folder (C:\pivotal) and told Git GUI to clone the PWS Intro app into that folder.
  3. FYI – the app doesn’t really do that much…it essentially throws up some config type stuff using templates/index.html. You’re really just getting an overview of how to use PCF without any focus on the app in the demo/intro.
  4. I also had to run “cf push” a few times…apparently it tries to pick a random endpoint/URL (a “route”) for your application and I guess it kept picking random words that were already used by other users or apps. So I just kept hitting “cf push” and eventually it worked.
  5. Pretty much everything you’re doing in the CLI can be done in your PWS Admin Console. It was neat to type into the CLI and then switch over to the console and see all the changes taking place, like the new DB and the scaling changes.

So what’s next? I think I’ll work on a custom Java or Node.js app and get that deployed and see what happens. I’ll check on Eclipse and PCF/git connections as well.

(Update 1/17/19) I was able to also get PCFDev working. I had to update my VirtualBox client and run the install a couple of times but eventually I had PCF running in a virtual machine on my PC and was able to deploy the spring-music demo app, which was pretty cool.

Then I pushed spring-music to my free PCF cloud instance and I connected it to a ClearDB service (essentially MySQL). I was then able to download MySQL Workbench on my local machine and connect to my ClearDB instance – neat. I tried to connect spring-music to a Redis service in PCF but couldn’t get that working…will try that again later.

IBM BPM – EPVs

IBM BPM provides a capability called Exposed Process Variables (EPVs). These assets allow you to use variables that can be changed in the run-time without a new code deployment. IBM BPM has a basic change utility and audit tracker for these values so you can use an out-of-the-box utility to see the current values, update them and also track when they were last changed and who changed them.

EPVs are great for parameters that might need to be changed frequently after a process application is deployed. I use EPVs a lot for things like threshold values or service integration parameters that are used for identification but not business logic.

Another helpful option is to define a comma-delimited list of strings that we might want to validate against a service response. For example if we call a service that returns a list of securities like IBM, AMZN, BLK, F, GPS but we only care about IBM and BLK for example, we can store the entities we care about in an EPV and iterate through the response list to see if the current item is one of our EPV values.

Use the code below as an example for parsing a comma-delimited EPV into a native JS array and then comparing the current array value to some local variable (tw.local.checkVar is this example)

// Get the EPV String
var currentEPV = String(tw.epv.EPVGroup.specificEPV);

          
if (currentEPV && currentEPV.length > 0) {
      // Split the EPV String into a native JS Array
      var currentEPVArray = currentEPV.split(/,/g);             
      for (var i = 0; i < currentEPVArray.length; i++) {
        var curItem =  currentEPVArray[i].trim();
        if (tw.local.checkVar == curItem) {
           // Apply whatever variable or logic check 
           // you need against the current value
           tw.local.logicFlag = true;                            
        }
      }
}

JMS Learning

IBM BPM added some event capabilities they call DEF for Dynamic Event Framework. It looks like this functionality could replace Tracking Groups and Tracking Points in process assets. Essentially DEF provides a way to dump notifications and data out of the process to an external system.

IBM KC Article on DEF
https://www.ibm.com/support/knowledgecenter/en/SSFPJS_8.5.7/com.ibm.wbpm.admin.doc/topics/capturingevents.html

My current role has a potential business case to connect an IBM BPM application to a Solace message engine. IBM BPM would both drop messages to Solace and also be able to consume messages (or be called from Solace to send a message over).

When I started some research on Solace and connecting it to WebSphere Application Server I realized I didn’t have any practical experience with JMS so I set aside some time this week to hack through some JMS tutorials and see what I could learn. Here are my notes from this journey.

Sites that helped

Old School JMS Tutorial from IBM: https://www.ibm.com/developerworks/java/tutorials/j-jms/j-jms-updated.html

JMS in Liberty:
https://github.com/WASdev/sample.jms.server

JMS Overview:
https://www.javatpoint.com/jms-tutorial

So first I just needed to learn the lingo of JMS and all of those sites helped with that. Next thing was to get coding, so I had to download the latest version of Eclipse (64-bit) for Java EE Developers. Easy enough. I already have a 64-bit Java JDK so there wasn’t a need to download anything new from Oracle.

My plan to take the code samples from Mr. Farrell’s IBM JMS overview and put those into a new project that will run on Liberty using the queues and topics setup by lauracowen’s demo. I like to combine things to help understand how each of them work and to avoid the cookbook approach of just following directions without understanding what was happening.

I wanted to focus on Pub/Sub so I took Mr. Farrell’s code for TPublisher.java and TSubscriber.java into a new Eclipse project. I liked that his code prompted for TopicConnectionFactory and Topic names; laura’s sample had the values in the code. So I figured I could use laura’s server.xml for Liberty and just type in the values to Mr. Farrell’s app and all would be good.

Well it turns out I couldn’t really figure out how to connect Mr. Farrell’s code to the Liberty JMS stuff in server.xml. I mean I ran the code “On Server” but I don’t really know if it had all the necessary context. It was failing at the JNDI look-up.

So instead of that approach and went with all of lauracowen’s code. I didn’t use Git for Eclipse so I just created a new project called jms11-JMSSample, copied all of her Java files and packages into Eclipse, used her server.xml and booted up Liberty.

I kept getting another JNDI failure. Ugh. It was here:

TopicConnectionFactory cf1 = (TopicConnectionFactory) new InitialContext().lookup("java:comp/env/jmsTCF");  

Again I couldn’t figure out what was the matter. The JNDI values seemed fine in server.xml:

	<jmsTopicConnectionFactory jndiName="jmsTCF"
		connectionManagerRef="ConMgr3" clientID="clientId1">
		<properties.wasJms />
	</jmsTopicConnectionFactory>

So what was the matter?

This is another case of not doing Java development frequently enough…I didn’t copy web.xml over. web.xml had the Java resource references that connected the code to the JNDI values. What’s interesting is that if I replaced the lookup value in the code with just “jmsTCGF” it worked fine – yay! But it look me a bit more time to understand how web.xml fit into that flow and get it corrected. The web apps worked perfectly after that.

My next task was to find some sort of tool that would let me look at the JMS queues and topics in Liberty. The sample web app had a little bit of info but I wanted to change it up and start dropping messages, not consume them, but be able to look at them somewhere else.

I found this application: JMSToolBox

It looked the a good solution so I downloaded the zip. Unfortunately I couldn’t get this tool to talk to my Liberty server. I have the full WAS JARs that are required and the Liberty JAR as well but I’m getting hung up on the SSL stuff. I don’t need SSL (everything is just local) but either Liberty or JMSToolbox is somehow forcing someting over https instead of just http…I’ll keep trying to work on this or maybe try a different tool…or just try jConsole. I’ll post an update later.

But in the end I had a good refresher on Java development, Liberty and an overview of JMS. Now I get to keep hacking with the code and start writing my own messages and topics.

Then maybe I’ll move on to adding an Elasticsearch index as a source for the messages…?