<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dave Winstone on Medium]]></title>
        <description><![CDATA[Stories by Dave Winstone on Medium]]></description>
        <link>https://medium.com/@davidwinstone?source=rss-74fb351e5bdb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*KgA9tpcMvA8CwAuiWKDouQ.jpeg</url>
            <title>Stories by Dave Winstone on Medium</title>
            <link>https://medium.com/@davidwinstone?source=rss-74fb351e5bdb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:54:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@davidwinstone/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Upgrading TIBCO BusinessWorks Container Engine Runtime in a Kubernetes Environment]]></title>
            <link>https://davidwinstone.medium.com/upgrading-tibco-businessworks-container-engine-runtime-in-a-kubernetes-environment-aa0886cb0aef?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa0886cb0aef</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[tibco-businessworks]]></category>
            <category><![CDATA[tibco]]></category>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Thu, 05 Jan 2023 09:15:18 GMT</pubDate>
            <atom:updated>2023-01-05T09:15:18.776Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8rkMSps_64abaf3M" /><figcaption>Photo by <a href="https://unsplash.com/@frankiefoto?utm_source=medium&amp;utm_medium=referral">frank mckenna</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In my previous article, I looked at how you would upgrade the TIBCO BusinessWorks Container Edition runtime for an application running on Docker.</p><p>In this article I want to extend the approach for when your application/microservice is deployed in a Kubernetes environment where you can achieve a Zero Downtime upgrade.</p><p>I’ll continue using my simple Greeting microservice that is a REST API that responds with a message, the container hostname and the BusinessWorks runtime version:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pH0JBBnxVeIIEZASF5UHKg.png" /><figcaption>Greeting Microservice in BusinessWorks Container Edition</figcaption></figure><h4>Building the BusinessWorks Container Edition Base Image</h4><p>There’s lots of instructions and different examples of how to do this at TIBCO’s official github repo <a href="https://github.com/TIBCOSoftware/bwce-docker">here</a> that I’d recommend you take a look at.</p><p>I’m going to start with my application built using version 2.7.3 of BusinessWorks Container Edition, then upgrade the runtime to 2.8.0.</p><p>Once you’ve followed the instructions from the TIBCO GitHub to clone the BWCE repo and downloaded the BWCE runtime from TIBCO’s download site you are ready to build the base image using a command similar to the following from the cloned bwce repo:</p><pre>./createDockerImage.sh ~/bwce-runtime-2.7.3.zip 127.0.0.1:32000/bwce:v2.7.3</pre><p>The first argument is the BWCE runtime zip file that you downloaded from TIBCO, and the second argument is the tag we’ll be using. You’ll notice that in my tag I’ve got an ip address and port, and that’s because I want to push this image to a registry — in this case I’m using microk8s, so when the base image is built, I can push it to the registry using this command:</p><pre>docker push 127.0.0.1:32000/bwce:v2.7.3</pre><h4>Building the Application Container Image</h4><p>I’ll adjust my application Dockerfile to include the correct base image tag as follows:</p><pre>FROM 127.0.0.1:32000/bwce:v2.7.3<br>LABEL maintainer=&quot;Dave Winstone&quot;<br>ADD greeting_1.0.0.ear /<br>EXPOSE 8081 7777</pre><p>Now to build the application and push it to the registry too:</p><pre>docker build -f Dockerfile -t 127.0.0.1:32000/greeting-app:1.0 .</pre><h4>Deploying to K8s (microk8s)</h4><p>To deploy my application to K8s, I need to create a yaml file that configures my application, creates a service and also defines the update strategy:</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: greeting-app<br>  labels:<br>    app: greeting-app<br>spec:<br>  type: NodePort<br>  ports:<br>  - port: 8081<br>    targetPort: 8081<br>    nodePort: 30092<br>  selector:<br>    app: greeting-app<br>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: greeting-app<br>spec:<br>  replicas: 2<br>  strategy:<br>    type: RollingUpdate<br>    rollingUpdate:<br>      maxSurge: 1<br>      maxUnavailable: 0<br>  selector:<br>    matchLabels:<br>      app: greeting-app<br>  template:<br>    metadata:<br>      name: greeting-app<br>      labels:<br>        app: greeting-app<br>    spec:<br>      containers:<br>        - name: greeting-app<br>          image: 127.0.0.1:32000/greeting-app:1.0<br>          imagePullPolicy: Always<br>          env:<br>          - name: BW_LOGLEVEL<br>            value: &quot;ERROR&quot;<br>          - name: BW_PROFILE<br>            value: &quot;default&quot;<br>          ports:<br>            - containerPort: 8081<br>            - name: readiness-port<br>              containerPort: 7777<br>          readinessProbe:<br>            httpGet:<br>              path: /_ping<br>              port: 7777<br>            initialDelaySeconds: 60<br>            periodSeconds: 15</pre><p>To deploy the application from the command line, I can execute the following:</p><pre>kubectl apply -f greeting1.0.ROLLING.yml</pre><p>When the application is ready (kubectl get deployments) you can test the application with a curl command (notice we defined the nodeport as 30092 in the yaml file):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGA2JVAKTtIfWijV3RwV9Q.png" /></figure><p>As we have 2 replicas created if we keep issuing the curl command we’ll see that both pods are responding</p><pre>while true;do curl http://192.168.1.10:30092/greeting/Dave; printf &quot;\n&quot;; sleep 1; done </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGjzSdNNQyK8GGW4RnBlYQ.png" /></figure><p>So — we’re all good — we have our microservice API up and running, and we’ve got 2 instances available and processing our messages. Now we want to keep the application running and update the base image to a new version of the container runtime.</p><h4>Update the Base Image</h4><p>To rebuild the base image to use v2.8.0 of BusinessWorks Container Edition, we first need to remove the bwce-runtime-2.7.3.zip from the resources folder under the cloned bwce repo, then run the command (assuming I have downloaded the bwce-runtime-2.8.0.zip file from TIBCO), followed by the Docker Push command:</p><pre>./createDockerImage.sh ~/bwce-runtime-2.8.0.zip 127.0.0.1:32000/bwce:v2.8.0<br>docker push 127.0.0.1:32000/bwce:v2.8.0</pre><p>Make a small change to our Dockerfile to use this new version (tag is 127.0.0.1:3200/bwce:v2.8.0):</p><pre>FROM 127.0.0.1:32000/bwce:v2.8.0<br>LABEL maintainer=&quot;Dave Winstone&quot;<br>ADD greeting_1.0.0.ear /<br>EXPOSE 8081 7777</pre><p>To rebuild the application use the following (and don’t forget to push to the registry):</p><pre>docker build -f Dockerfile -t 127.0.0.1:32000/greeting-app:1.1 .<br>docker push 127.0.0.1:32000/greeting-app:1.1</pre><p>The next job we need to do is update our yaml file that describes the deployment in Kubernetes to point to the new version of the image and then re-apply the yaml file to the deployment using the kubectl command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*LD4lf94U8AUux9yJhSFRWg.png" /><figcaption>Updated yaml deployment file</figcaption></figure><pre>kubectl apply -f greeting1.0.ROLLING.yml</pre><p>I deliberately left my curl command running so that as Kubernetes is deploying the rolling update — we can see that when the new pod is instantiated it starts responding with the new version of the BWCE container runtime, whilst another instance of the pod is being started. When completed, you can see that all instances are now running at the latest version:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCQdXiy-Hjq7ZhnE5N31lA.png" /></figure><p>So there we have it — we have successfully upgraded our BWCE container runtime in a Kubernetes environment without having to upgrade the entire infrastructure — saving lots of time, effort and of course money.</p><p>When you start applying DevOps principles to this approach — then you can see how this level of automation can significantly, positively impact your development and operations costs.</p><p>As you can see from the screenshot above — this approach does not force you to upgrade every microservice to the same runtime version all at the same time — different versions can co-exist at the same time, which allows you to better plan upgrades alongside existing development and maintenance activities rather than having to plan a separate activity just for upgrading the platform. Co-Existence of containers running different versions of the core run-time is actually a better way of making the best use of developers and operations time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa0886cb0aef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upgrading TIBCO BusinessWorks Container Engine Runtime]]></title>
            <link>https://davidwinstone.medium.com/upgrading-tibco-businessworks-container-engine-runtime-54814fb79399?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/54814fb79399</guid>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[tibco-businessworks]]></category>
            <category><![CDATA[tibco]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Thu, 05 Jan 2023 09:07:37 GMT</pubDate>
            <atom:updated>2023-01-05T09:07:37.694Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8rkMSps_64abaf3M" /><figcaption>Photo by <a href="https://unsplash.com/@frankiefoto?utm_source=medium&amp;utm_medium=referral">frank mckenna</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I considered an alternative Title — “How Containerisation massively reduces your upgrade process”, as this is applicable for any technology that you containerise, but I wanted to show you how to do this specifically with TIBCO BusinessWorks Container Edition as it removes one of the biggest costs/effort of upgrading a BusinessWorks infrastructure.</p><p>Let’s consider a scenario with “classic” BusinessWorks — either version 5.x or 6.x. Here, you will have a set of servers (deployed on either physical/virtual/cloud) where you deploy the applications that you build. These applications are tested, running and scaled to the right level to cope with your peak demand.</p><p>Let’s say you have BusinessWorks 6.7.0 running and things are nice and stable (as all things TIBCO are of course!). TIBCO release 3 new versions of BusinessWorks over the next 2 years, let’s call them 6.8.0, 6.8.1 and 6.9.0. This means that you are now 3 versions behind and TIBCO’s support policy means that they will announce an end of support date for 6.7.0 in due course. Once that happens — if you raise a Support Call — you are quite likely to be asked to perform an upgrade before support is provided.</p><p>So — to keep up with support you need to upgrade your TIBCO platform to the most appropriate version in order to stay current and make sure that TIBCO will provide support for your version.</p><p>The above policies are valid for most Enterprise Software Vendors in the market today — so you can replace TIBCO with any other vendor name to suit your environment.</p><p>What it means though, is that you and your development team must build into your plans the appropriate time and effort as part of your BAU process alongside building new projects and providing maintenance for existing projects to ensure you can upgrade the platform.</p><p>Unfortunately, this doesn’t always happen and it can come as an unwelcome surprise that you are going to have to plan an unscheduled upgrade.</p><p>As TIBCO BusinessWorks runs many of the world’s core businesses — upgrading a classic BusinessWorks infrastructure means a lot of planning. I know of organisations that process Billions of $ orders <strong><em>EVERY DAY </em></strong>on TIBCO — so your upgrade can’t go wrong. There’s a lot of planning, testing, re-testing and potential downtime too.</p><p>Alongside this — you’ve also decided to move to Containerisation as part your digital transformation planning and that includes moving your TIBCO BusinessWorks applications to Container Edition.</p><p>If you are already on BusinessWorks 6.x — moving those applications to Container Edition is pretty straightforward, from BusinessWorks 5.x TIBCO provide tooling to help as well as a migration factory for large projects — but I want this article to focus on what it means to upgrade the container runtime for a deployed container edition application as there are other resources and blogs that cover migrating to Container Edition.</p><p>If you’ve seen some of my previous blogs — you’ll recognise my simple Greeting microservice that is a simple REST API that responds with a message and the container hostname:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*keHqW_fl6dBQY1by" /><figcaption>Greeting Micro Service in TIBCO BusinessWorks</figcaption></figure><p>This application is built using the following Docker File:</p><pre>FROM bwce:latest<br>LABEL maintainer=&quot;Dave Winstone&quot;<br>ADD greeting_1.0.0.ear /<br>EXPOSE 8081 7777</pre><p>You’ll notice the first line tells the docker build command that I’ll be using the latest version of my TIBCO BusinessWorks Container Edition (bwce) base image. Best practice though is to specify a specific version to ensure you are pulling the right image for your deployment. It also means that you should be maintaining your Docker files in source code control too.</p><p>It goes without saying (almost) that you should also be building and deploying your applications with a DevOps pipeline to automate everything and remove human error — but I want to show you how you would upgrade the runtime manually.</p><p>The greeting application itself is the “greeting_1.0.0.ear” file. In this example I’ve changed the output very slightly to include the BusinessWorks runtime engine version as part of the output.</p><h4>Building the BusinessWorks Container Edition Base Image</h4><p>There’s lots of instructions and different examples of how to do this at TIBCO’s official github repo <a href="https://github.com/TIBCOSoftware/bwce-docker">here</a> that I’d recommend you take a look at.</p><p>I’m going to start with my application built using version 2.7.3 of BusinessWorks Container Edition, then upgrade the runtime to 2.8.0.</p><p>Once you’ve followed the instructions from the TIBCO GitHub to clone the BWCE repo. and downloaded the BWCE runtime from TIBCO’s download site you are ready to build the base image using a command similar to the following from the cloned bwce repo:</p><pre>./createDockerImage.sh ~/bwce-runtime-2.7.3.zip bwce:v2.7.3</pre><p>The first argument is the BWCE runtime zip file that you downloaded from TIBCO, and the second argument is the tag we’ll be using.</p><h4>Building the Application Container Image</h4><p>I’ll adjust my application Dockerfile to include the correct base image tag as follows:</p><pre>FROM bwce:v2.7.3<br>LABEL maintainer=&quot;Dave Winstone&quot;<br>ADD greeting_1.0.0.ear /<br>EXPOSE 8081 7777</pre><p>Now to build the application:</p><pre>docker build -f Dockerfile -t greeting-app:1.0 .</pre><p>And to run the application:</p><pre>docker run -p 8081:8081 greeting-app:1.0</pre><p>To see the results, I can issue a simple Curl command and see the response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvbHLBt9Xn06-WMnr7bcjA.png" /></figure><p>So all good.</p><p>But now we have a new version of the BusinessWorks Container Edition Runtime that we want to use — but I don’t want to rebuild the original EAR file, as that would result in a code change — leading to regression testing, UAT etc. Plus usually it means that the whole platform needs to be upgraded — but we only need this single microservice to be updated as there’s a bug that’s been fixed by TIBCO that we need for this single microservice.</p><p>In this instance, all we need to do is rebuild the base image for BusinessWorks Container Edition, alter the Dockerfile of my application to use that new image and then rebuild the container image and re-run.</p><h4>Update the Base Image</h4><p>To rebuild the base image to use v2.8.0 of BusinessWorks Container Edition, we first need to remove the bwce-runtime-2.7.3.zip from the resources folder under the cloned bwce repo, then run the command (assuming I have downloaded the bwce-runtime-2.8.0.zip file from TIBCO):</p><pre>./createDockerImage.sh ~/bwce-runtime-2.8.0.zip bwce:v2.8.0</pre><p>Make a small change to our Dockerfile to use this new version (tag is bwce:v2.8.0):</p><pre>FROM bwce:v2.8.0<br>LABEL maintainer=&quot;Dave Winstone&quot;<br>ADD greeting_1.0.0.ear /<br>EXPOSE 8081 7777</pre><p>And to rebuild the application:</p><pre>docker build -f Dockerfile -t greeting-app:1.0 .</pre><p>And to run the application:</p><pre>docker run -p 8081:8081 greeting-app:1.0</pre><p>And using my Curl command I can test the new version of the application to see if the BusinessWorks Container Edition runtime has been upgraded:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMUcrio9gc6rFoTOtB4_Rw.png" /></figure><p>As you can see — we have successfully upgraded the BWCE runtime within our container for our Greeting microservice.</p><p>This is a huge benefit to containerisation — particularly where your microservices utilise other frameworks or integration frameworks like TIBCO for your API strategies.</p><p>What’s even more interesting is that this approach does not force you to upgrade every microservice to the same runtime version all at the same time— different versions can co-exist at the same time, which allows you to better plan upgrades alongside existing development and maintenance activities rather than having to plan a separate activity just for upgrading the platform. Co-Existence of containers running different versions of the core run-time is actually a better way of making the best use of developers and operations time.</p><p>If you think about the time, resources and money that you would normally spend on performing this type of upgrade and comparing that to what you save using this approach, I think you’ll agree that taking this approach is well worth the effort.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54814fb79399" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing Flutter Apps with TIBCO Cloud Integration]]></title>
            <link>https://davidwinstone.medium.com/developing-flutter-apps-with-tibco-cloud-integration-59bb94d592f4?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/59bb94d592f4</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[tibcocloud]]></category>
            <category><![CDATA[tibco]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 13:09:03 GMT</pubDate>
            <atom:updated>2022-10-04T13:09:03.652Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j0tuyiwgInNHdJTWVEfrug.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@roketpik?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Artur Shamsutdinov</a> on <a href="https://unsplash.com/s/photos/flutter?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>It seems like there are 1001 different frameworks for creating an Application these days — whether you want to build a native mobile app, a website or a build once, deploy anywhere app.</p><p>For work (I work at TIBCO), I needed to build a quick Mobile App for a customer using TIBCO Cloud Integration and I decided that I wanted to also learn Flutter whilst I was at it. I chose Flutter, purely because it had been mentioned in a few conversations and I knew nothing about it, and I liked the fact that you could deploy the same code to IOS/Android, Windows, Mac, Linux and the Web.</p><p>The customer had no preference, but just needed to see how easy or hard it would be to build a mobile app that used APIs delivered by the TIBCO Platform.</p><blockquote>From <a href="https://flutter.dev/">https://flutter.dev:</a> “Flutter transforms the app development process. Build, test, and deploy beautiful mobile, web, desktop, and embedded apps from a single codebase.”</blockquote><p>First things first, if you haven’t got Flutter installed and running go here <a href="https://docs.flutter.dev/get-started/install">https://docs.flutter.dev/get-started/install</a>. The rest of the tutorial will assume that you are using Visual Studio Code, so if your are using a different editor you will have to alter some of the steps accordingly.</p><h3>Creating an API in TIBCO Cloud Integration</h3><blockquote>If you haven’t got a subscription to the TIBCO Cloud — you can sign up for a 30-day trial here: <a href="https://cloud.tibco.com/">https://cloud.tibco.com</a></blockquote><p>For my App — I needed two APIs. One that returns a list of Countries and their Currency, and one that we could pass in a Country and return its Currency.</p><p>To do this, I used the API Modeller to create two Resources — /currencies and /currency/{country}, each with their own JSON schema as a response. I used sample data with a list of currencies and the currency code to generate my JSON schema — the benefit of this is that when I create a mock application — the default success response is my sample data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arHFKJkpH26S8yxfJTZxug.png" /><figcaption>TIBCO Cloud API Modeler</figcaption></figure><p>I then created a Mock application from this model using the TIBCO platform (just press the “Create Mock Application” from the API definition list). Once the Mock Application is created, I’m then provided with an Endpoint, which I immediately made “Private” — which means that the API is not accessible externally, and is published to the TIBCO API Mesh.</p><p>I can then use the Wizard to publish my API so that it can be managed properly by the TIBCO Cloud API Management platform — I can apply security, configure policies and manage API Keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jREPIpB3ZWgi4cYTVLeiMw.png" /><figcaption>Mock API Publication</figcaption></figure><p>Having gone through the wizard to publish my mock application endpoint, I now have an Endpoint, and an API Key. Both of these can be found in the Developer Portal. I can use these in Postman to test that my API/key combination works. For example in the screenshot below I tried the /currencies API endpoint to return the full list of Countries and their Currency. Replace the URL and your API key accordingly of course.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HaEMvgWveUbTI3Q8YfZ4lg.png" /><figcaption>Testing API through Postman</figcaption></figure><p>This means my Mock API is working and I’m ready to start building my flutter app!</p><h3>Create Skeleton Flutter App</h3><p>I’ve set up my environment to use Microsoft Visual Studio Code — there’s lots of support and plugins for Flutter and the underlying Dart programming language that just make it easier — so follow the instructions from <a href="https://flutter.dev/">https://flutter.dev</a> to get your environment set up.</p><p>First we need to create our basic application, and flutter contains the ability to create applications with templates, and for this tutorial I’m using the provided “skeleton” template. From a terminal window, navigate to your projects folder and run the following command — I’m calling my app currencyapp:</p><pre>flutter create -t skeleton currencyapp</pre><blockquote>Note: flutter/dart uses a lowercase naming convention for project names.</blockquote><p>You can follow the instructions to run the basic application, and you are also given the location of the core application code:</p><pre>flutter create -t skeleton currencyapp</pre><pre>Creating project currencyapp...</pre><pre>Running &quot;flutter pub get&quot; in currencyapp...                      1,592ms</pre><pre>Wrote 140 files.</pre><pre>All done!</pre><pre>In order to run your application, type:</pre><pre>$ cd currencyapp</pre><pre>$ flutter run</pre><pre>Your application code is in currencyapp/lib/main.dart.</pre><p>Opening the currencyapp folder in Visual Studio Code you’ll see that the skeleton app includes many files — which can be confusing — but the main ones that we want to look at are all under the lib directory. The skeleton contains a number of helpful suggestions of how to organise your files</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pc1yR7pL-hAtOnF_DJI6eQ.png" /><figcaption>Skeleton Template opened in Visual Studio Code</figcaption></figure><p>The template organises code by feature, so all views, controllers and services are grouped in the same package — which as your project grows will make it easier to manage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*FGrMrYVGLDQzzuQzVf-Cpw.png" /><figcaption>Features organised by Service/View/Controller</figcaption></figure><p>The base template is immediately runnable and it’s a very good base application to start working with APIs from TIBCO Cloud Integration.</p><p>To Debug your application you first need to tell VS Code which Device you are going to emulate. On the bottom right of the VS Code window, you’ll see something similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*KQT3pvbRwXEoYI2vV5Bk3g.png" /></figure><p>Currently my deployment environment is set to Chrome (web-javascript), but if I wanted to switch to using an iPhone device using the Apple Simulator, I’d click on “Chrome” and then a pop up will appear giving you the different options available:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*VzVqM2LWHtKBFvDyBwhQgw.png" /></figure><p>I’ve already started the iPhone SE emulator in the terminal (which is how it knows about the iPhone SE device) using the following command:</p><pre>open -a simulator</pre><p>When all is set, all you need to do is to open “main.dart” in VSCode and click on the Debug button, and the application will be compiled and installed on the simulated device (or Web page etc.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*0mv8UisDfwp1cAfVC6Ayyg.png" /><figcaption>Base Skeleton App on the iOS Simulator</figcaption></figure><h3>Calling our TIBCO Cloud Integration API</h3><p>Ok — we’re ready to start building out our application to call our Mock API we created earlier. Let’s start with just returning all of the Currencies/Countries, I’ll use the the second resource in another post in the future.</p><h4>Include “http” package</h4><p>The first change we need to make is to include the “http” package into our project by adding it to the dependencies section of the pubspec.yaml file. The easiest way to do this is to start a Terminal window in VS Code and run:</p><pre>flutter pub add http</pre><p>You will see that the pubspec.yaml file is automatically updated with the correct dependencies, plus is also downloads the required libraries you need. My pubspec.yaml now includes:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  flutter_localizations:<br>  sdk: flutter<br>  http: ^0.13.5</pre><h4>Create a “Feature”</h4><p>The flutter skeleton app packages its functionality using Features. By packaging this way, all the code/classes required for that feature are packaged in the same place — which allows for projects to be shared with other team members easily — and follows the same kind of principles as micro-services — few dependencies between packages etc.</p><p>So let’s create a new folder in our project called “currency_feature” and we need to create 4 empty files:</p><pre>currency.dart                   : the main &quot;class&quot; file<br>currency_service.dart           : responsible for the REST calls<br>currency_list_view.dart         : builds the list of currencies view<br>currency_details_view.dart      : builds the detail view</pre><p>Remember our REST service? It just had 2 simple fields — Currency and Country — so update the currency.dart file with the following code to represent this as a class.</p><pre>/// A  class that represents a currency.<br>class Currency {<br>  final String code;<br>  final String country;</pre><pre>  const Currency({required this.code, required this.country});</pre><pre>  factory Currency.fromJson(Map&lt;String, dynamic&gt; json) {<br>    return Currency(<br>      code: json[&#39;currency_code&#39;] ?? &#39;&#39;, country: json[&#39;country&#39;] ??              &#39;&#39;); //Using ?? &#39;&#39; to cope with cases where fields are null<br> }<br>}</pre><p>Next we’ll create the currency_service.dart file with the code to actually make the API call and create a list of the currencies using the currency.dart class:</p><pre>import &#39;currency.dart&#39;;<br>import &#39;package:http/http.dart&#39; as http;<br>import &#39;dart:convert&#39;;</pre><pre>class CurrencyService {<br>  Map&lt;String, String&gt; requestHeaders = {<br>    &#39;Content-type&#39;: &#39;application/json&#39;,<br>    &#39;Accept&#39;: &#39;application/json&#39;,<br>    &#39;api_key&#39;: &#39;<strong><em>YOUR API KEY HERE</em></strong>&#39;<br>  };</pre><pre>List parseCurrencies(String responseBody) {<br>  final jsonResponse = json.decode(responseBody).map((responseBody) =&gt; Currency.fromJson(responseBody)).toList();<br>  return jsonResponse;<br>}</pre><pre>Future&lt;List&gt; fetchCurrencies() async {<br>  final response = await        http.get(Uri.parse(&#39;<strong><em>https://YOURHOST.COM/currencies</em></strong>&#39;),headers: requestHeaders);</pre><pre>  if (response.statusCode == 200) {<br>    return parseCurrencies(response.body);<br>  } else {<br>    throw Exception(&quot;Error: &quot; + response.statusCode.toString() + &#39;:   Unable to get date from REST API&#39;);<br>    }<br>  }<br>}</pre><p>This class is relatively simple. First I needed to set up the requestHeaders — in my case, the API key is a header field called ‘api_key’ — so set this field up with your API key.</p><p>I then have a helper function called parseCurrencies that takes the response from the API call and decodes it into a JSON object.</p><p>Finally, I have the actual API call itself — which makes the actual call, and returns a list that I can use in my User Interface.</p><p>Best practice would be to have my API key and URL in a separate file to make it easier to change for larger applications.</p><p>So — that’s the basics for actually making the call into TIBCO Cloud Integration.</p><h4>Creating the UI</h4><p>For my user interface, I’m going with something simple — a straightforward list of currencies, and when you click on one of them — I want to open a details page. And of course-the list needs to call the API in order to get the list of currencies.</p><p>So I’ll need to update my two View files, currency_list_view.dart and currency_details_view.dart.</p><p><strong>currency_list_view.dart:</strong></p><pre>import &#39;package:currencyapp/src/currency_feature/currency_details_view.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;currency.dart&#39;;<br>import &#39;currency_service.dart&#39;;<br>import &#39;../settings/settings_view.dart&#39;;</pre><pre>/// Displays a list of Currencies.<br>class CurrencyListView extends StatelessWidget {</pre><pre>  CurrencyListView({Key? key}) : super(key: key);<br>  static const routeName = &#39;/currencies&#39;;<br>  final currencyService = CurrencyService();</pre><pre>  Widget currencyWidget() {<br>    return FutureBuilder(<br>      builder: (context, AsyncSnapshot currencySnap) {<br>        if (!currencySnap.hasData) {<br>          return const Center(child: CircularProgressIndicator());<br>        }<br>        return ListView.builder(<br>          itemCount: currencySnap.data.length,<br>          itemBuilder: (context, index) {<br>            Currency currency = currencySnap.data[index];<br>            return Card(<br>              child: ListTile(<br>                title: Text(currency.country),<br>                onTap: () {<br>                  Navigator.of(context).push(MaterialPageRoute(<br>                    builder: (context) =&gt; CurrencyDetail(<br>                      currency: currencySnap.data[index],<br>                    )));<br>                   },),);<br>                 },);},<br>          future: currencyService.fetchCurrencies(),<br>        );<br>      }</pre><pre>@override<br>Widget build(BuildContext context) {<br>  return Scaffold(<br>    appBar: AppBar(title: const Text(&#39;Currencies&#39;), actions: [<br>      IconButton(<br>      icon: const Icon(Icons.settings),<br>      onPressed: () {<br>      // Navigate to the settings page. If the user leaves and      returns<br>      // to the app after it has been killed while running in the<br>      // background, the navigation stack is restored.<br>      Navigator.restorablePushNamed(context, SettingsView.routeName);<br>      },<br>    ),<br>   ]),<br>  body: currencyWidget(),<br>  );<br> }<br>}</pre><p><strong>currency_details_view.dart:</strong></p><pre>import &#39;dart:io&#39;;<br>import &#39;package:intl/intl.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;currency.dart&#39;;</pre><pre>class CurrencyDetail extends StatelessWidget {<br>  final Currency currency;<br>  const CurrencyDetail({Key? key, required this.currency}) : super(key: key);</pre><pre>  static const routeName = &#39;/currencyDetail&#39;;</pre><pre>  String getCurrencySymbol(String code) {<br>    var format = NumberFormat.simpleCurrency(locale: Platform.localeName, name: code);<br>    return format.currencySymbol;<br>  }</pre><pre>@override<br>Widget build(BuildContext context) {<br>  return Scaffold(<br>    appBar: AppBar(<br>      title: Text(currency.country),<br>    ),<br>    body: Column(<br>      children: [<br>        ListTile(<br>          title: Text(currency.country),<br>          subtitle: Text(&quot;Currency Code: ${currency.code}&quot;),trailing: Text(style: const TextStyle(fontFamily: &#39;&#39;),getCurrencySymbol(currency.code)),<br>        )<br>      ],<br>    ),<br>   );<br>  }<br>}</pre><p>It looks a little daunting — but actually there’s not a lot of code there to worry about. There’s plenty of tutorials out there for helping you build out nice UI’s using flutter, so I won’t go into much of that detail here.</p><p>The key things in currency_list_view.dart are that I have created a Widget for displaying the currency list, and I’ve defined it as a Future, and that Future runs the fetchCurrencies() function asynchronously. The widget is then using the ListBuilder widget to display the main list. There is also an onTap function where I’m calling out to the currency_details_view.dart file to navigate to the UI to display the details.</p><p>currency_details_view.dart is pretty simple as all I have is a straightforward ListTile which displays the country and currency code, and a helper function to display the currency symbol.</p><p>The final changes I had to make were to the app.dart file so that instead of using the sample feature, it uses my new currency feature instead.</p><p>The changes in app.dart are in the onGenerateRoute code (the skeleton app uses routes which are defined in the feature):</p><pre>onGenerateRoute: (RouteSettings routeSettings) {<br>  return MaterialPageRoute&lt;void&gt;(<br>    settings: routeSettings,<br>    builder: (BuildContext context) {<br>      switch (routeSettings.name) {<br>        case SettingsView.routeName:<br>          return SettingsView(controller: settingsController);<br>        case CurrencyListView.routeName:<br>          return CurrencyListView();<br>        default:<br>          return CurrencyListView();<br>      }<br>    },<br>  );<br>}</pre><p>And that’s it!</p><p>When we run the application in the iPhone simulator, it automatically calls the service, displays the list and when you click on a currency — it displays the details page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*Y87MbG1DV4phCmM2Edr6fg.gif" /><figcaption>Completed Application!</figcaption></figure><p>What I learned from this exercise is that Flutter is actually really easy — and particularly easy to develop multi-platform applications, but it’s also incredibly easy to use the APIs developed in TIBCO Cloud Integration — allowing me to spend my time on UI/Application code and benefit from the time saved using the low code development environment provided by TIBCO.</p><p>Full source code can be found here: <a href="https://github.com/davewins/currencyapp">https://github.com/davewins/currencyapp</a></p><p>Let me know what you think!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59bb94d592f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hybrid Database Access with TIBCO Cloud Integration]]></title>
            <link>https://davidwinstone.medium.com/hybrid-database-access-with-tibco-cloud-integration-cf3ba9acac1f?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf3ba9acac1f</guid>
            <category><![CDATA[hybrid-cloud]]></category>
            <category><![CDATA[tibco-businessworks]]></category>
            <category><![CDATA[tibco]]></category>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Tue, 15 Feb 2022 14:29:23 GMT</pubDate>
            <atom:updated>2022-02-15T14:29:23.423Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WI0s5fI_sU0_65j6hfHDbg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@billy_huy?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Billy Huynh</a> on <a href="https://unsplash.com/s/photos/cloud?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Whilst every Business wants to move to a 100% cloud environment, large Enterprises are faced with a long road to realisation — they can’t just switch off their data centres overnight and expect everything to work in a Cloud environment as it did before. Couple this with data sovereignty issues and most Enterprise Customers that I work with move towards a Hybrid Cloud model.</p><p>In this model — much of the Business Logic, Micro-Services and of course SaaS applications live in the Cloud somewhere — but databases often reside in a data centre and are unlikely to move to the Cloud for the foreseeable future.</p><p>This article walks you through how to use TIBCO Cloud Integration to connect to an on-premise Database instance to access the data — allowing you to build out a hybrid implementation where your Business logic is in the Cloud and the data is in your data centre. In this article I’m using MongoDB but the same techniques work for Microsoft SQL Server, Oracle, MySQL, Postgres etc.</p><h3>TIBCO Cloud Integration — Hybrid Agent</h3><p>The Hybrid Agent is a lightweight app that runs on your data centre to facilitate communication between on-premises apps and TIBCO Cloud™ Integration. With the TIBCO Cloud Integration — Hybrid Agent , you can:</p><ul><li>Establish tunnel connections to apps running on TIBCO® Cloud Integration. In TIBCO® Cloud Integration, you can configure an app to use the tunnel to connect to on-premises resources like a database server (in this case MongoDB), a Kafka Broker, a JMS server, or a REST server etc.</li><li>There is no need to expose your database or service as a public Internet service, so there is no requirement to change the firewall rules or to host the TIBCO Cloud — Proxy Agent in the DMZ (Demilitarized Zone).</li><li>Stream logs directly from a TIBCO® Cloud Integration app container.</li><li>Securely communicate information on registered remote apps, such as monitoring statistics, app status, and other app details. Remote apps are displayed in TIBCO® Cloud Integration on the Apps list. You can see and monitor your remote apps the same way as your cloud apps.</li></ul><p>The full documentation for using the Hybrid agent can be found at this location: <a href="https://integration.cloud.tibco.com/docs/using/hybrid-agent/index.html">https://integration.cloud.tibco.com/docs/using/hybrid-agent/index.html</a></p><p>The main benefit of using the Hybrid Agent is that it removes the need for organisations to open firewalls to the Internet or messing about with whitelisting — whilst providing secure TLS based communication between the data centre and the TIBCO Cloud. Communications are also initiated from the Data Centre to create the tunnel, providing an extra layer of security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1QLtHJWbH5D8kNMg.png" /><figcaption>Proxy Connections with the Hybrid Agent</figcaption></figure><h3>Setting up the Hybrid Agent</h3><p>There are a few steps to get the Hybrid Agent up and running:</p><ul><li>Get logged into the TIBCO Cloud (https://cloud.tibco.com — 30 day trial available)</li><li>Create a Proxy Agent Access Key</li><li>Set up Inbound whitelist rules (if required)</li><li>Download the Hybrid Agent</li><li>Configure the Agent with your Access Key</li><li>Start the Agent, mapping the ports required</li><li>Build and Test your App (which has its own steps covered later!)</li></ul><p><strong>Creating a Proxy Agent Access Key</strong></p><p>Once you’ve logged into your TIBCO Cloud Account, Navigate to Settings and look for “Proxy Agent Access Keys” on the left hand side of the page — when you are there — you’ll see a page similar to the screenshot below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*JHn7A6ibP8iWzIsM6E4igA.png" /><figcaption>Creating Proxy Agent Access Keys</figcaption></figure><p>To generate a new key — just click on “Generate Access Key” and give it a name (something recognisable!). This will generate the key — which will only be displayed once — so make sure you copy it to your clipboard as you’ll need it later!</p><p><strong>Downloading the Agent</strong></p><p>To download the Agent — you’ll need to navigate to TIBCO Cloud Integration, click on “Environment &amp; Tools” and click on “New Agent” and choose the appropriate agent for your intended Operating System.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8gkQgGJRfiOYEtQQ" /><figcaption>Downloading the Agent CLI</figcaption></figure><p><strong>Configuring the Agent</strong></p><p>First of all, we have to create an Agent configuration. In my case, I’m running on a Mac, and I want to create a new agent called “mongodb_agent”, so all I need to do is to run the following command from the terminal:</p><pre>./tibagent configure agent mongodb_agent</pre><p>You will then need to provide your credentials to log into the correct account and Organisation within the TIBCO Cloud.</p><p>Once completed, you now need to configure the Agent with the access key that you generated earlier replacing &lt;key&gt; with your access key, replacing &lt;key id&gt; with your key ID and of course the agent name as we created above:</p><pre>./tibagent configure connect — accessSecret &lt;key&gt; — accessKey &lt;key id&gt; mongodb_agent</pre><p><strong>Starting the Agent</strong></p><p>The final step in this stage is to start the agent, with the appropriate Ports that you want to tunnel between your environment and The TIBCO Cloud.</p><p>MongoDB has a number of default ports, which are mainly 27017, 27018 and 27019. On my machine, I have set up a MongoDB replica-set with 3 replicas each known as mongoset1, mongoset2 and mongoset3. Each of these instances are mapped in my Hosts file — so that they can be accessed by name rather than IP address.</p><p>I’m going to set up a “Change Data Capture” process to monitor changes in the MongoDB database — and therefore we are mandated by MongoDB to use replica-sets. A request/reply pattern for querying the database does not mandate the use of replica-sets, so how you start and map the ports may be different.</p><p>To start the Hybrid agent, mapping the appropriate ports, we will use the following command:</p><pre>./tibagent start agent mongodb_agent -spec 27017:mongoset1:27017 -spec 27018:mongoset2:27018 -spec 27019:mongoset3:27019</pre><p>This will start the Hybrid Agent and create the tunnel between the 3 MongoDB replicas and the TIBCO Cloud.</p><p>You can confirm that the Hybrid Agent is running by navigating back to the TIBCO Cloud, into “Integration Apps”, then click on “Environment &amp; Tools”, choose “Agents” and then on the “Filter By” panel on the left, click “Hybrid”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VVu8lm9xn3Kc3f7I6vRW-A.png" /><figcaption>Checking the Agent is running</figcaption></figure><p>You’ll see that if we hover over the agent — we can see the ports that are mapped and that the tunnel is up and running.</p><p>Now to go and build an app to test it all out!</p><h3>Build an Application in the TIBCO Cloud</h3><p>I’m going to use TIBCO Cloud Integration to build an application that listens to changes made to our MongoDB instance. This application will be running in the TIBCO Cloud — but it will listen to changes that are being made to our MondoDB instance in our data centre (or more accurately, my laptop!), it’s only going to be a simple application that write to a log — but you can take that simple app and go from there.</p><p><strong>Configure a connection</strong></p><p>First we need to configure a Connection to MongoDB, and this is done by logging into TIBCO Cloud Integration and navigating to the “Connections” tab where you will see all the currently configured connections:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WZfwIh5nY4dPQzFg" /></figure><p>Press the “Create” button to create a new connection and navigate to the “MongoDB Connector” which is marked with the “Develop” tag. You can use the search button to narrow down the list. The “Develop” tag tells us that it is a connector for TIBCO Flogo. “Connect” means that it is a connector for TIBCO Scribe. We’ll be using Flogo in our examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/0*5vDzyFJWNotcnl0N" /></figure><p>When you have selected the connector, you will need to configure the details:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*AdEMDTUaUV3o2Ob-" /></figure><p>The main area to configure is the URL, and you can see that I have the 3 machine names and appropriate ports for each machine — plus I have defined the replica-set that my instances use. If you need to add the username/password — you will need to change the “Credential” type to use the appropriate security algorithm before filling out the details for the user.</p><p><strong>Create the App</strong></p><p>Click on the “Apps” tab in the top left of the screen, which takes you to the main dashboard. Click on “Create/Import” on the top right and then choose “Flogo” in the dialog box, finally clicking on “Create New App”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9oihmy-pXerU3jwi" /></figure><p>Give your new app a name, by overwriting the name that is automatically generated in the top left corner:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2jHsM1NTmKHf7v3E" /></figure><p>Then, click the “Create” button where we will be asked how we want to create our application. Click on “Trigger” and look for the MongoDB Trigger:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/0*mlS-lu9gMFr9sQ7Y" /></figure><p>You’ll be asked which connection you want to use — and select the connection you created earlier, then click “Create”</p><p>You will now have an empty application that is triggered by mongoDB changes — so now we want to add some logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rz993BBtrhDZOzWa" /></figure><p>Click on “New Flow” and this time we want to choose “Flow” in the dialog and give it a name — for instance, “mongoDBListener”, followed by “Create”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*N4nmziPairsCZ1Qy" /></figure><p>Select your existing trigger and press “Continue”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/0*lxVbQjVLlqw6W97m" /></figure><p>Choose “Copy Schema”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/0*OQQJY7hjRju7OyZe" /></figure><p>You will then be taken to a screen similar to the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M8bEp0rWLc1JhAJJ" /></figure><p>This is showing you the schema from the output of the trigger — but we don’t need to do anything with that for now, as we’ve copied the schema from the trigger. Next we need to configure what database and collection we want to listen to, and what triggers we want to monitor. To do that click on the trigger button which is on the left hand side of the screen and has a red “X” icon on it. It is marked with the X because there is work to do. When you click on it, you will see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-Hp63bmrB_l7SkeO" /></figure><p>What we need to do is to configure the database name, collection and which events we want to listen to. For example, my database is “customers” and I will leave “Collection” as empty so I can listen to all events on all collections.</p><p>I want to listen to all events, so I will leave them as default, then click on “Save” when ready.</p><p>You will see that “Map to Flow Inputs” is marked with a yellow triangle. This means that we have to configure how we want to map the output of the trigger to the input of the flow we are creating. Click on the “Map to Flow Inputs” link and you will see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oFcel7fCcgGOwyVz" /></figure><p>The “Flow Input” panel is what the flow itself is expecting. On the right hand side — this is where you map the incoming data from the trigger to the flow. So to do this, I expand the “{} output” branch of the “Flow Input”, then also expand the “{} trigger” output in the centre and click on “{} output” to insert the mapping into the panel above. What you should end up with is the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tbZfTnaHjib6rjlF" /></figure><p>Click “Save” when happy and then click on the “x” button on the top right of the dialog to close this window.</p><p>We now have a flow that is ready to be built. If you hover over the main canvas, you can see a “+” button appears — click on this to add an activity in that location:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FFZOkMgA_sCqicBI" /></figure><p>You will see a list of activities that you can click on, or you can use the search area to look for a specific activity. For now, all we are going to do is “log” the output of the trigger from MongoDB. So type in “log” into the search box, and choose the “Log Message” activity:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KLlTvm2Z42aS5-_znMSKEQ.png" /></figure><p>Here we can decide what we will output on our log message — so click on the “Input” panel, which shows you that it is expecting the “message” input to be defined (it’s marked in red), an you can see the output from the upstream activities — in this case it’s our trigger. You could type in the formula that you want to use, or click around on the functions etc. For now, we can use the following formula:</p><pre>string.concat(“Received “,$flow.output.OperationType,&quot; Event&quot;)</pre><p>Which will just output the type of trigger that we received:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CoeE3_RzBF1hc1qwqFPq1Q.png" /></figure><p>We’re ready to try out our application!</p><p>Normally we would be able to use the “Test” function in the top right corner of the screen to run through and debug the application, but because we are using the Hybrid Agent we have to do one more configuration step to deploy our application for testing.</p><p><strong>Configure, Deploy &amp; Run</strong></p><p>First — we need to configure our App with the correct Access Keys so that it can listen to our MongoDB instance. So from the Application details screen, click on the “Environment Controls” link:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zriqk6dCBmy-twZS" /></figure><p>Choose the key that you set up in Step 1 and click “Push updates”</p><p>Go back the the “Flows” section and then click “Push” — this compiles and deploys the application into a container in The TIBCO Cloud — but does not start it until you are ready.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xTjlCMLASHCXLsVO" /></figure><p>When the application is deployed — you can then use the “Instances” counter to decide how many instances of the application you want to start. 1 is enough for our purposes — click on the counter and press the “Scale” button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Wik5lBU2zrjRm-j4" /></figure><p>At this point — you can click on the “Logs” tab to view the logs — and click on the “Real-time” slider to see the logs as they are generated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e2ATPN3ku23WdHWW" /></figure><p>Look for the line:</p><pre>“[flogo.trigger.mongodb.mongodb-event-listener] — ===listening===” </pre><p>Which tells us that the application has successfully started and has created a connection through the tunnel into the local MongoDB application.</p><p>If you get any failure at all — then we will have to debug further.</p><p><strong>Test the App</strong></p><p>To test the application — all we need to do is to add a new entry into the mongodb collection. To do this, I have used “mongosh” to connect into the mongo cluster and used the following commands:</p><pre>mongodb-replicaset:PRIMARY&gt; use customers<br>switched to db products<br>mongodb-replicaset:PRIMARY&gt; db.customers.save({firstname: “Dave”})<br>WriteResult({ “nInserted” : 1 })<br>mongodb-replicaset:PRIMARY&gt; db.customers.find()<br>{ “_id” : ObjectId(“5ffdb8db3405ea9985f1e92f”), “firstname” : “Dave” }<br>mongodb-replicaset:PRIMARY&gt; db.customers.save({firstname: “David”})<br>WriteResult({ “nInserted” : 1 })<br>mongodb-replicaset:PRIMARY&gt; db.customers.save({firstname: “Davie”})<br>WriteResult({ “nInserted” : 1 })<br>mongodb-replicaset:PRIMARY&gt; db.customers.save({firstname: “Davey”})<br>WriteResult({ “nInserted” : 1 })<br>mongodb-replicaset:PRIMARY&gt; db.customers.save({firstname: “Abhijeet”})<br>WriteResult({ “nInserted” : 1 })<br>mongodb-replicaset:PRIMARY&gt;</pre><p>And when I look at the log output from our Flogo application we see the logs updating and our “LogMessage” activity shows that it received an “Insert” operation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SYsPIrUIPgyFAVdQ" /></figure><p>So now you know how to configure the TIBCO Hybrid Agent to create a tunnel between your private cloud and the TIBCO Cloud platform, how to configure a connection to MongoDB that resides within your private cloud, and how to create a basic application that listens for updates to MongoDB.</p><p>You next task would be to expand that application to perform whatever you need in order to process the MongoDB updates.</p><p>To find out more about TIBCO Cloud Integration — go to <a href="https://cloud.tibco.com/">https://cloud.tibco.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf3ba9acac1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero Downtime Deployment of BusinessWorks Container Edition with Kubernetes — Part 5]]></title>
            <link>https://davidwinstone.medium.com/zero-downtime-deployment-of-businessworks-container-edition-with-kubernetes-part-5-a52bd00de7ce?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a52bd00de7ce</guid>
            <category><![CDATA[tibco-businessworks]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[tibco]]></category>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Mon, 17 Jan 2022 11:41:55 GMT</pubDate>
            <atom:updated>2022-01-17T11:41:55.208Z</atom:updated>
            <content:encoded><![CDATA[<h3>Zero Downtime Deployment of BusinessWorks Container Edition with Kubernetes — Part 5</h3><h3>Canary Strategy</h3><p>In my previous posts we created and deployed a Micro Service using TIBCO BusinessWorks Container Edition into Kubernetes (I used Minikube), and then upgraded it using the Recreate,Rolling Update and Blue/Green strategies.</p><p>In this post, we’re going to take the original deployment of Version 1.0 (which we rolled back to at the end of the second post) and upgrade it again to 1.1, but this time using the Canary deployment strategy.</p><p>With a Canary deployment strategy, we want to deploy a new version of a micro service and route some traffic to it, whilst most traffic goes to the original version. If we see no issues, we can increase the number of new Pods of the new version — taking more and more of the traffic over time.</p><p>In this example, we really need more replicas to show it working a little better, so I will deploy our original version with 3 replicas instead of 2. I created this <a href="https://github.com/davewins/EAR/blob/master/greeting1.0.3replicas.yml">manifest</a> and removed the original deployment and re-deployed this new 3 replica version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*bfpSVgCpZew_thoO" /></figure><p>To deploy a Canary version of the application, there’s not a huge amount of work that we need to do to our manifest. Literally all we need to change is the Application name itself! You can add in the Version as a Label, or an Environment label if you wish. In my Canary <a href="https://github.com/davewins/BWK8s/blob/master/greeting1.1.CANARY.yml">manifest</a>, all I’ve done is to change the application name, then deployed it using the kubectl apply command below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*HUfpBC3I5kgQYU_M" /></figure><p>This starts a 4th Pod, the 3 original Pods are left alone, the new Pod is started and the Service starts routing traffic to the new Pod on a 4:1 basis:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*_1SWnEfThuSSHg95" /><figcaption>Kubernetes Dashboard with Live + Canary Deployed Pods</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*6SbCUGnKpwUuUusb" /><figcaption>Resulting API Calls</figcaption></figure><p>As you can see from the screenshot — a percentage of our calls are now being routed to our Canary deployment. We can continue to monitor the application and we can decide to scale down the original application, and scale up the Canary application to vary the load between the versions as appropriate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*5KvAlytLFv_1mlAy" /></figure><p>When we are happy, we can re-deploy the Canary version as the production version just by scaling down V1 and/or deleting the deployment completely.</p><p>As in my previous posts — you can watch the corresponding <a href="https://www.youtube.com/watch?v=hc2MPfRYiNE&amp;list=PLnmoGGHHJldgMBSrLO-n8B4ElpYemFBIn&amp;index=9">video here</a> to see the Canary Strategy live!</p><h3>Conclusion</h3><p>My original intention of this series of posts was to show how you could employ Rolling Updates to existing TIBCO BusinessWorks Container Edition applications with zero downtime. I realised that of course, there’s more than one way to skin a cat (as they say), so it needed to cover off other deployment strategies too.</p><p>What I think it shows is how mature Kubernetes really is — but also how mature you have to be as an organisation to be able utilise such powerful functionality.</p><p>As Martin Fowler says — <a href="https://martinfowler.com/bliki/MicroservicePrerequisites.html">“You have to be this tall”</a> to use Micro Services, and this rings true with Container based deployments in Kubernetes — you’ve got to have a proper understanding of how your micro services are interacting with each other and how your deployment practices affect each of those micro services.</p><p>Of course, the other aspect I haven’t covered is that all of this should all be automated in your CI/CD Pipeline!</p><p>I’m a strong believer that you’ve got to really understand what’s going on under the covers so that you can appreciate and get the best out of your automated pipeline — so when things go wrong — you know how to resolve them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a52bd00de7ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero Downtime Deployment of BusinessWorks Container Edition with Kubernetes — Part 4]]></title>
            <link>https://davidwinstone.medium.com/zero-downtime-deployment-of-businessworks-container-edition-with-kubernetes-part-4-b4f11bf84583?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4f11bf84583</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[tibco]]></category>
            <category><![CDATA[tibco-businessworks]]></category>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Thu, 06 Jan 2022 10:30:38 GMT</pubDate>
            <atom:updated>2022-01-06T10:30:38.704Z</atom:updated>
            <content:encoded><![CDATA[<h3>Zero Downtime Deployment of BusinessWorks Container Edition with Kubernetes — Part 4</h3><h3>Blue/Green Strategy</h3><p>In my previous three posts we created and deployed a Micro Service using TIBCO BusinessWorks Container Edition into Kubernetes (I used Minikube), and then upgraded it using the Recreate and Rolling Update strategy.</p><p>In this post, we’re going to take the original deployment of Version 1.0 (which we rolled back to at the end of the second post) and upgrade it again to 1.1, but this time using the Blue/Green strategy.</p><p>A Blue/Green deployment strategy (sometimes also known as Red/Black) allows you to deploy upgraded services alongside your existing services and the two don’t interact in any way. The URL of the Service defined is different so it allows you to test the new deployment before switching over all the traffic.</p><p>I’ve created an example manifest file where the changes I’ve made are pretty minimal and really just add in the keywords ‘version: green’. The complete version of the file is <a href="https://github.com/davewins/BWK8s/blob/master/greeting1.1.GREEN.yml">here</a>. I’ve also removed the definitions for the Service as we’ll keep the same service as our original application, and later we’ll update the configuration to point to our new green deployment later.</p><p>In my Minikube environment, I still have my version 1.0 running — so I’ll deploy this new “Green” version of the deployment using the command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*o_JxLJFbo99I7mpt" /></figure><p>When the deployment is complete, you’ll see that we now have 2 deployments — our original deployment, plus our new Green deployment — each with 2 Pods running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*iHn0UxnOKYB73m0y" /><figcaption>Kubernetes Dashboard</figcaption></figure><p>So we have our Green deployment running — but there’s no traffic there just yet, so we’ve got to create a new Service that points to the new deployment. You can find the service file <a href="https://github.com/davewins/BWK8s/blob/master/green-greeting-service.yml">here</a>, and you can create the service using the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*PB97JR-BmCcEXnw8" /></figure><p>Executing “minikube service list” shows the below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*xVzoyit7vaWaiRpQ" /></figure><p>Where we can see our two deployments. Our new service can be found at <a href="http://192.168.49.2:30092,">http://192.168.49.2:30092,</a> so we can now do our testing using the new URL.</p><p>So at this stage — we have both deployments up and running in parallel and our testing is going ahead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*jrS7RvWbK19sB8x5" /><figcaption>Green/Blue deployment side-by-side</figcaption></figure><p>Now — we are ready to switch traffic fully over to our Green deployment as our “Live” deployment and then we can remove our old deployment.</p><p>To do this, I’ve created a new manifest <a href="https://github.com/davewins/EAR/blob/master/live-greeting-service.yml">file</a> for the “Live” service and changes the selector to point to the green-greeting-app and version:green as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*XyyQETyUpXlO3IyJ" /></figure><p>Issuing the following command modifies the existing greeting-app service to point to the new Green app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*yvPoYTQfcqLkfO25" /></figure><p>Looking at the terminal output below — you can see that as soon as I issue the update, Live traffic is immediately switched over to the green deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*eDPZXiASvDl3rbKZ" /><figcaption>Live Traffic switching over to Green Deployment</figcaption></figure><p>It feels like these posts are getting shorter — once you’ve got your micro service based application deployed in K8s it really is quite easy to upgrade them using the different strategies.</p><p>As before — I’ve created a <a href="https://www.youtube.com/watch?v=vovH2RbUen4&amp;list=PLnmoGGHHJldgMBSrLO-n8B4ElpYemFBIn&amp;index=8">video</a> to go along with this post, so feel free to watch and read at the same time!</p><p>In the next and final post in this series, we’ll be looking at the Canary Strategy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4f11bf84583" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero Downtime Deployment of BusinessWorks Container Edition with Kubernetes — Part 3]]></title>
            <link>https://davidwinstone.medium.com/zero-downtime-deployment-of-businessworks-container-edition-with-kubernetes-part-3-8475319b1cbd?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8475319b1cbd</guid>
            <category><![CDATA[tibco]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[tibco-businessworks]]></category>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Thu, 16 Dec 2021 08:50:47 GMT</pubDate>
            <atom:updated>2021-12-16T08:50:47.082Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Zero Downtime Deployment of BusinessWorks Container Edition with Kubernetes — Part 3</strong></h3><h3>Ramped/Rolling Update Strategy</h3><p>In my previous two posts we created and deployed a Micro Service using TIBCO BusinessWorks Container Edition into Kubernetes (I used Minikube), and then upgraded it using the Recreate strategy.</p><p>In this post, we’re going to take the original deployment of Version 1.0 (which we rolled back to at the end of the second post) and upgrade it again to 1.1, but this time using the Rolling Update strategy.</p><p>Rolling Updates, also known as Ramped Updates are actually the default deployment strategy in Kubernetes, so if you don’t make any changes to your manifest file — this is the strategy that would be used.</p><p>Of course — you can make changes so that you have a little more control over how the deployment strategy is employed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*3Luf02GnmUXi7o2n" /></figure><p>In the extract above from my yaml manifest file, maxSurge defines how many new Pods will be created at any one time, whilst maxUnavailable defines how many Pods can be unavailable during the update. The full manifest file is <a href="https://github.com/davewins/BWK8s/blob/master/greeting1.1.ROLLING.yml">here</a>.</p><p>To execute the Rolling Update — all we need to do is to execute the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*OUHJKbvaGOgkGE3t" /></figure><p>As our replica count is set to 2, this means that when we start the update, 1 new Pod will be created, whilst the original 2 are still running. When the new Pod is ready (discovered through the ReadinessProbe), then 1 of the original Pods will be killed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*jC28jgtsvs8OVAI9" /><figcaption>Starting the Rolling Upgrade</figcaption></figure><p>At this point, 1 Pod will be running the new version, and 1 Pod will be on the old version. Our API requests will be shared between these two Pods with no interruption to service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*caJSzCxJk2irGEUT" /><figcaption>Requests being routed between 2 versions</figcaption></figure><p>The next stage is that another new Pod will be created, and when it is ready, the final older version will be killed and both Pods will be up and running on the new version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*fapErmPGAtmOCKtn" /><figcaption>All pods now upgraded</figcaption></figure><p>Rolling back the deployment is exactly the same as we did previously:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*wvXqMXu_LEuNBvLr" /></figure><p>However, because of the rolling update strategy — the undo is also a rolling roll-back. So we create a Pod with the old version, wait for it to be in a running state, route traffic to it, then deleting 1 of the original pods etc.</p><p>Both the Rolling Update and Rollback have zero downtime, so our little client application does not need to be restarted at any point.</p><p>Rolling Update is a great strategy for a lot of deployments that require zero downtime — but it does mean that you need to ensure compatibility between your micro services and the rest of the application for it to work properly.</p><p>Guess what? I created a <a href="https://www.youtube.com/watch?v=Dt5iD0aXSvM&amp;list=PLnmoGGHHJldgMBSrLO-n8B4ElpYemFBIn&amp;index=7">video for this post</a> too — so you can follow along!</p><p>Actually — I did the entire recording in a single take and split the recording into 5 videos to make it more consumable — I hope you like the idea!</p><p>In the next post, we’ll be looking at using the Blue/Green update strategy with TIBCO BusinessWorks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8475319b1cbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero Downtime Deployment of BusinessWorks Container Edition with Kubernetes — Part 2]]></title>
            <link>https://davidwinstone.medium.com/zero-downtime-deployment-of-businessworks-container-edition-with-kubernetes-part-2-ad839e906517?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad839e906517</guid>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Fri, 03 Dec 2021 11:42:05 GMT</pubDate>
            <atom:updated>2021-12-03T11:42:05.844Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Zero Downtime Deployment of BusinessWorks Container Edition with Kubernetes — Part 2</strong></h3><h3>Recreate Strategy</h3><p>In my first post in this series, we created a Greeting Service using TIBCO BusinessWorks Container Edition and we created manifest files and deployed our Micro Service into Minikube.</p><p>In this post, we’re going to upgrade our original version of the Micro Service to version 1.1 and we’ll use the Recreate strategy to perform the upgrade.</p><p>To do this, I’ve created a new manifest file (<a href="https://github.com/davewins/BWK8s/blob/master/greeting1.1.RECREATE.yml">here</a>) that has 2 changes to it. The first is to point it to the newer version of the Docker Image that we created earlier (v1.1), and also to add in the definition of the Recreate Strategy. The extracts from the manifest file of importance are below — but look at the full file to compare the difference:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*zy85Cj1XGj30Nb9P" /></figure><p>To perform our update, all we need to do is to apply the new version of the manifest file using the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*lRIRltie_fquQ85_" /></figure><p>The rollout will happen immediately, and has the effect of killing the current pods, whilst starting up the new versions. Looking at the dashboard, we can see that there are 2 pods in Pending status, and none running. We can also use the command below to check the rollout status from the command line:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*lxf5l9qKlcKU0w97" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*VlHlsZaMbfVfGSOv" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*mENS6lhxchHMKo_d" /><figcaption>Kubernetes Dashboard Replicate Strategy Status</figcaption></figure><p>Our command line utility that checks the Application has also stopped responding — this is because I haven’t built any error handling in the client, so I’ll just have to stop and restart the shell command, and we can now see that the app has been upgraded and using the latest version as well as the host names changing of course.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*geHdQHzOkuDCjKQP" /></figure><p>Because I had to stop my client and restart — that introduces downtime and may not be what you want (especially given the title of the article!). So we want to look at one of the other strategies.</p><h3>Deployment Rollback</h3><p>Before we go on to the next strategy — we want to put back our original version of the application, and thankfully this is really easy to do in Kubernetes!</p><p>All I need to do is to issue the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*IUoPY6YYz9d9iktH" /></figure><p>There are other handy rollout commands such as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*BHn7GSBSndQ5UEaR" /></figure><p>When I run the undo command, I can see that my command line script also stops responding as the rollout strategy was Recreate — so it stops the running Pods immediately, then deploys the new Pods.</p><p>Using the recreate upgrade strategy ensures that you have a completely renewed/refreshed application — with no incompatibilities between the APIs of different Micro Services, but it comes at the cost of some downtime during the upgrade.</p><p>As with the first post in this series, I’ve created a <a href="https://www.youtube.com/watch?v=4uY0JdvfssM&amp;list=PLnmoGGHHJldgMBSrLO-n8B4ElpYemFBIn&amp;index=6">video on YouTube</a> that you can follow along and see the recreate strategy in action.</p><p>The next post in the series will focus on Rolling Updates — so I hope you’ll come back and continue learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad839e906517" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero Downtime deployment of BusinessWorks Container Edition with Kubernetes — Part 1]]></title>
            <link>https://davidwinstone.medium.com/zero-downtime-deployment-of-businessworks-container-edition-with-kubernetes-279e79907446?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/279e79907446</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[tibco-businessworks]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[tibco]]></category>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Fri, 19 Nov 2021 11:53:54 GMT</pubDate>
            <atom:updated>2022-02-07T18:23:37.487Z</atom:updated>
            <content:encoded><![CDATA[<h3>Part 1: Creating a Micro-Service and Deploying in Minikube</h3><p>Much of the discussion about deploying applications in Containers centers around how an orchestration platform such as Kubernetes provides Elastic Scalability of your applications — allowing incoming demand to scale your application up and down to meet demand appropriately. This can be extremely cost effective when you’re paying hourly usage rates for cloud hosting, and provides one of the biggest cost savings over data center hosting when you have a proper cloud-native deployment. To do this properly, the application in your container needs to provide the appropriate metrics that can be queried by Kubernetes to determine the scaling up or down points.</p><p>After scalability, the next topic is Self-Healing — when a micro service is no longer responding, a new container is started, traffic is routed to the new container, and the old container is unceremoniously removed. To remove any downtime, this means that you need at least 2 instances of your micro service running (n+1) and that way, there should be no interruption of service.</p><p>In this post, I want to talk about another aspect of Containerisation that I think has been overlooked of late, but has a significant impact on how organisations manage platforms that are deployed in Kubernetes, and in particular, how to handle upgrades of the container runtime as well as the micro service running in the container.</p><p>In times gone by, if you had a non-containerised deployment of any application that it underpins your Business, then an upgrade of the platform takes time and planning. No-one wants to just upgrade the platform, restart the services and hope it works — so it is typical that a new platform is deployed, applications are rebuilt and deployed in Test/QA platforms before finally being deployed in Production — with the implied interruption of service at an appropriate non-busy time, with everyone on hand in case things go wrong and need to be fixed/rolled back.</p><p>Thankfully, Containers and Orchestration platforms such as Kubernetes have consigned those long nights and war rooms to the past, where they belong!</p><h3>Kubernetes Deployment Strategies</h3><p>Kubernetes supports a number of different deployment strategies and choosing the right deployment procedure depends on your needs, some of the possible strategies you can adopt are:</p><ul><li><strong>Recreate</strong>: All existing Pods are killed and new Pods are created. The entire application is redeployed — but requires downtime</li><li><strong>Ramped/Rolling Update</strong>: Release a new version, route traffic to it and terminate an existing version, then move on to the next instance. Removes any downtime whilst Pods are updated, but you have no control over traffic and you will need to ensure API compatibility across versions</li><li><strong>Blue/Green</strong>: Release a new version alongside the older version and then switch traffic. Avoids API compatibility issues, instance rollback but double the resources are required</li><li><strong>Canary</strong>: Release a new version to a subset of users. Quite easy to set up, but rollouts can be slower depending on how you manage traffic between Pods</li><li><strong>A/B</strong>: Similar to Canary, except that traffic is routed by specific conditions such as Header values. Requires the use of an intelligent load balancer</li></ul><p>In this series of posts, I’ll look at using Recreate, Ramped, Blue/Green, and Canary with a micro service created using TIBCO BusinessWorks™ Container Edition.</p><h3>Initial Set up</h3><p>I’m starting with a simple setup on Ubuntu that includes:</p><ul><li>Minikube</li><li>TIBCO BusinessWorks Container Edition</li><li>BusinessWorks <a href="https://github.com/davewins/bwce_greeting">Greeting App</a></li><li><a href="https://github.com/davewins/BWK8s">Docker and Yaml files</a></li></ul><p>The Docker and Yaml files above are included to provide some example configurations that you might like to use, and are pretty straightforward to change for your needs.</p><h3>BusinessWorks Greeting Micro Service</h3><p>I have created a simple Greeting Service in TIBCO BusinessWorks ready for deployment into a Container — as you can see it’s very simple and all it does is return a Greeting to whatever query parameter was sent to the REST service. It also returns the Version Number of the application from the Application’s Module Properties (handy for testing our rollout strategy!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*vovGP7r9hVb0-qcy" /><figcaption>Greeting Micro Service in TIBCO BusinessWorks</figcaption></figure><p>I’ve generated two versions of this micro service — 1.0 and 1.1 and generated the EAR files ready for the creation of the Docker images. I’ve also created two Docker files — one for each version.</p><p>Docker File for version 1.0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/0*21kAgQJBhOWtYU65" /></figure><p>Docker File for version 1.1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/0*vcpHIRHXMLRAr7uc" /></figure><p>You can see that I’m exposing 2 ports, 8081 is the main REST service, whilst 7777 is the port used for the Readiness Probe.</p><p>The Readiness probe is important to use as you don’t want Kubernetes to send requests to a container that isn’t able to start processing requests yet.</p><h3>Getting Minikube ready</h3><p>Once you have Minikube installed on your platform, there’s a few commands you want to keep handy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/0*VKXBJz3gYjx8DpM5" /></figure><p>Once Minikube is up and running, we need to configure our local environment to use the docker daemon within Minikube. This is done with the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*TKCKLQRsuSGAISKh" /></figure><p>We’re at a stage now where we can create our two versions of the Greeting App docker images. To do this, I’m going to use the two EAR files, and the two Docker Files and run the following commands:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*QVfUtGr7VpcE_63M" /></figure><p>We’re now at a stage where we can deploy our application into Minikube.</p><h3>Initial Deployment into Kubernetes</h3><p>To deploy into Kubernetes you need to have a manifest file that describes the deployment. I’ll be using the Yaml version of the files, although you can also create json format files, as that seems to be the most popular, and there are more examples out there.</p><p>My 1.0 version of the manifest file looks like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*fywgDr4aSkMFAhsg" /></figure><p>There’s a fair amount of detail there — but most of it is self explanatory. Couple of things I’ll point out.</p><ul><li>I’ve set up the readiness probe to start after 60 seconds to give the BusinessWorks container time to start.</li><li>I’ve also set the image to be greeting-app:1.0 — so specifying a particular version number to use in this deployment</li><li>I’ve set Replicas to 2 — this means that there will be 2 Pods deployed</li></ul><p>To create the deployment in Kubernetes, it’s a simple command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*HzUskog6pw2CFMNC" /></figure><p>Then we can switch to the Kubernetes Dashboard and watch our deployment come up</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*hqoNCEVKZTCQoXXk" /><figcaption>Kubernetes Dashboard</figcaption></figure><p>You’ll see we have 2 Pods, each with their own unique name, which BusinessWorks will use as the Hostname, so we’ll be able to see which Pod is handling our request.</p><p>In the base deployment of Minikube, it is using kube-proxy to proxy requests into the Pods themselves and so it will perform load balancing between those pods. To get the URL of my micro service, I use the command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*Nh1Seg6Nnr8CTZdC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JuA3TFAKtNqF2STO" /></figure><p>You can see that my URL would be <a href="http://192.168.49.2:30914.">http://192.168.49.2:30914.</a> From BusinessWorks, I know that my REST endpoint is /greeting and I can pass in a parameter.</p><p>So my full URL would be <a href="http://192.168.49.2:30914/greeting/Dave">http://192.168.49.2:30914/greeting/Dave</a></p><p>To make testing easier, I have a quick script that I can run on the command line:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*h0Hd3vQyWpV7vkfC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/0*OLZw6oFaO8id9hen" /><figcaption>Results from REST API</figcaption></figure><p>You can see from the screen-grab that the REST API is returning my greeting, along with the Hostname of the Pod and the Version of the application. You can see that Kubernetes is sending requests to both Pods that we saw earlier in the Kubernetes Dashboard.</p><p>Cool — Version 1.0 is up and running!</p><p>In the following posts, I’ll be going through the different upgrade strategies we discussed earlier, starting with the Recreate Strategy.</p><p>In the meantime — I’ve also created a <a href="https://www.youtube.com/watch?v=XyaA80jB_HQ&amp;list=PLnmoGGHHJldgMBSrLO-n8B4ElpYemFBIn&amp;index=5&amp;t=9s">video of this post</a>, so you can follow along and get your environment ready for the next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=279e79907446" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Kafka + TIBCO === A Better Event-Driven Architecture]]></title>
            <link>https://davidwinstone.medium.com/why-kafka-tibco-a-better-event-driven-architecture-59661837c7eb?source=rss-74fb351e5bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/59661837c7eb</guid>
            <dc:creator><![CDATA[Dave Winstone]]></dc:creator>
            <pubDate>Wed, 18 Aug 2021 13:20:02 GMT</pubDate>
            <atom:updated>2021-08-18T13:20:02.900Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SABnYfT-DtAuwGOgkqs79g.jpeg" /><figcaption>Photo by Joshua Sortino on Unsplash.com</figcaption></figure><p>Ok, where do I start … This relatively small title covers a whole gamut of concepts, technologies, and — dare I say it — a little bit of technical religion too.</p><p>Let’s start with Kafka. At its core, it’s an Open-Source Event Streaming Platform that was created by our friends here at LinkedIn. It was designed as a highly scalable distributed platform that can handle trillions of “Events” per day, allowing you to capture literally any event as it happens in real time for processing. Kafka is on every single Developer resume today, and it’s being used in nearly every Company/Project that you can think of. Super cool tech and everyone wants a piece of it.</p><p>I mentioned “Events” in the above paragraph too. What’s an Event? In its simplest form — “Something Happened, at this date/time.” It could have been a new order placed on your website, an IoT sensor reading, or a change of state — an Order moved from being Processed to Shipped for instance.</p><p>Coupling Kafka and Events together, you get the basis for an Event-Driven Architecture. Something happens — that gets published to Kafka, something picks up that message and does something with it. All in real time and as fast and scalable as you want.</p><p>And this is where it gets interesting. What do you do with those events, and how best to process them?</p><p>Kafka includes something called the Streams API, giving you the ability to write Java code to process those events, allowing you to aggregate events, create joins of data within a stream, create windowing parameters to look at time slices of events.</p><p>But at the end of the day, you have to write code, and while this is great for Developers who love to write code, this isn’t necessarily the right thing for a Business. A Business wants to be agile, respond to market changes quickly, make changes to their IT systems to cope with new business strategies overnight, and if you are relying on Developers handcrafting code, it’s never going to be as quick as the Business wants it. This leads inevitably to the great Business/IT divide that we’ve all seen.</p><p>Kafka is encouraging the developer mindset and merely helping create new ways of writing code.</p><p>So how can we do better?</p><p>When I think about Event-Driven Architectures, there are always 3 key aspects to it:</p><ul><li>Event Distribution</li><li>Simple Event Processing</li><li>Contextual Event Processing</li></ul><p><strong>Event Distribution</strong> is precisely where Kafka shines and what it was built to do. There are of course many other Messaging platforms (of which TIBCO is a notable vendor), but I would not put Kafka in quite the same bucket. There are many different types of messaging patterns such as Publish/Subscribe, Point-to-Point, Queuing, etc. and Kafka only really supports Publish/Subscribe — which is perfect for an Event-Driven Architecture. I’ll look at another blog in the future that discusses many of the patterns and which messaging platforms would support each one.</p><p><strong>Simple Event Processing</strong> starts to look at what those Events published on the Event Distribution platform actually mean. Usually implemented as simple if/this/then statements and are generally reactionary. So, if we receive an Event that says an Order is Shipped, then we might send an email to the customer.</p><p><strong>Contextual Event Processing</strong> starts to bring in other techniques to help learn more about the Event and the Action that needs to happen based on that single Event — or crucially an aggregation of Events over time, even the absence of an expected Event is classed as an Event in its own right. Quite often, this is where AI/ML algorithms also come into play.</p><p>As I mentioned previously, this is commonly achieved utilizing Kafka, the Kafka Streams API, and Java coding. (Although I’d suggest that Contextual Event Processing would be difficult to do in this scenario.)</p><p>And this is where TIBCO starts to add some real value to Businesses. Whilst TIBCO provides the same level of commercial support for core Kafka as other vendors, TIBCO also has a huge amount of experience in coupling Event Distribution with Simple and Contextual Event Processing.</p><p>In particular — all Event Processing is 100% GUI-Driven. Because all the Event Processing Capabilities provided by TIBCO are GUI-based. Developers spend less time building the business logic required than if they were handcrafting code which means that they can respond to business requirements much faster.</p><p>TIBCO also has different solutions for Simple or Contextual Event Processing depending on the complexity of requirements. One size does not fit all and we always advocate using the right technology for the job at hand. From simple rules engine implementations through to State Machine Models.</p><p>Everything in the software world these days needs to be stateless but any hardware developer will tell you, understanding the current state is absolutely vital when building real-time hardware systems and the same is true for understanding how you react to events in real time in a software system. So, having a robust state machine implementation is crucial in a full Event-Driven Architecture.</p><p>All of this brings me to my last point — Reacting to Events. I’ve kind of skirted around this already but being able to react intelligently to an Event or set of Events or even the lack of an expected Event could be crucial for a Business. We often call these Business Moments, and these usually relate directly to the Business KPIs and have an immediate impact on the Customer Experience. Think of a new Customer Order or a sensor reading that passes a threshold over the last 5 minutes. These are examples of Business Moments that we need to react to as they are happening. Even understanding that 5 minutes after we update the CRM system, we should see an email being sent to the Customer — and detecting that didn’t happen (as a non-Event) could indicate something important that we want to know about.</p><p>In fact, Events also have a valued lifetime. In most situations, the data is most valuable “right now”. But over time that value decreases. It would be great to know that we are being defrauded right now because we can stop the transaction from happening, rather than the more traditional — we were defrauded last week according to our weekly transaction report, and there’s nothing we can do about it now.</p><p>There are lots of other examples that I could point to that our customers are doing right now with Kafka (and others) + TIBCO to build out some amazing Event-Driven Architectures, check out the <a href="https://www.tibco.com/">TIBCO website</a> or look out for our annual <a href="https://now.tibco.com/">TIBCO Now</a> conference where many of our customers present their stories.</p><p>One last thought I wanted to leave you with:</p><ul><li>Kafka! = Event-Driven Architecture</li><li>Kafka ∈<strong> </strong>Event-Driven Architecture</li><li>Kafka + TIBCO === A Better Event-Driven Architecture</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59661837c7eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>