Introducing the all-new TIBCO Community site!

For current users, please click "Sign In" to reset your password and access the enhanced features. If you're a first-time visitor, we extend a warm welcome—click "Sign Up" to become a part of the TIBCO Community!

If you're seeking alternative community sites, explore ibi, Jaspersoft, and Spotfire.

Jump to content
  • Hybrid Database Access with TIBCO Cloud Integration


    Manoj Chaurasia

    Table of Contents

    Introduction

    Whilst every Business wants to move to a 100% cloud environment, large Enterprises are faced with a long road to realization ? they can?t just switch off their data centers 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 a move towards a Hybrid Cloud model.

    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 center and are unlikely to move to the Cloud for the foreseeable future.

    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 center. In this article, I?m using MongoDB but the same techniques work for Microsoft SQL Server, Oracle, MySQL, Postgres, etc.

    TIBCO Cloud Integration ? Hybrid Agent

    The Hybrid Agent is a lightweight app that runs on your data center to facilitate communication between on-premises apps and TIBCO Cloud? Integration. With the TIBCO Cloud Integration ? Hybrid Agent, you can:

    • 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.
    • 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).
    • Stream logs directly from a TIBCO® Cloud Integration app container.
    • 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.

    The full documentation for using the Hybrid agent can be found at this location: https://integration.cloud.tibco.com/docs/using/hybrid-agent/index.html

    The main benefit of using the Hybrid Agent is that it removes the need for organizations to open firewalls to the Internet or mess about with whitelisting ? whilst providing secure TLS-based communication between the data center and the TIBCO Cloud. Communications are also initiated from the Data Centre to create the tunnel, providing an extra layer of security.

    0_1QLtHJWbH5D8kNMg.thumb.png.c6ee1718c5aebff11c6a8a502c92956e.png

    Setting up the Hybrid Agent

    There are a few steps to get the Hybrid Agent up and running:

    • Get logged into the TIBCO Cloud (https://cloud.tibco.com ? 30-day trial available)
    • Create a Proxy Agent Access Key
    • Set up Inbound whitelist rules (if required)
    • Download the Hybrid Agent
    • Configure the Agent with your Access Key
    • Start the Agent, mapping the ports required
    • Build and Test your App (which has its own steps covered later!)

    Creating a Proxy Agent Access Key

    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:

    1_JHn7A6ibP8iWzIsM6E4igA.png.68904c9752c9a3c926fd528f590c4fc8.png

    To generate a new key ? just click on ?Generate Access Key? and give it a name (something recognizable!). 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!

    Downloading the Agent

    To download the Agent ? you?ll need to navigate to TIBCO Cloud Integration, click on ?Environment & Tools? click on ?New Agent? and choose the appropriate agent for your intended Operating System.

     

    0_8gkQgGJRfiOYEtQQ.thumb.png.1d11b3958feda4a9a3c297490ad26a49.png

    Downloading the Agent CLI

    Configuring the Agent

    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:

     ./tibagent configure agent mongodb_agent

    You will then need to provide your credentials to log into the correct account and Organisation within the TIBCO Cloud.

    Once completed, you now need to configure the Agent with the access key that you generated earlier replacing <key> with your access key, replacing <key id> with your key ID, and of course the agent name as we created above:

     ./tibagent configure connect ? accessSecret <key> ? accessKey <key id> mongodb_agent

    Starting the Agent

    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.

    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 is mapped in my Hosts file ? so that they can be accessed by name rather than IP address.

    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.

    To start the Hybrid agent, mapping the appropriate ports, we will use the following command:

     ./tibagent start agent mongodb_agent -spec 27017:mongoset1:27017 -spec 27018:mongoset2:27018 -spec 27019:mongoset3:27019

    This will start the Hybrid Agent and create the tunnel between the 3 MongoDB replicas and the TIBCO Cloud.

    You can confirm that the Hybrid Agent is running by navigating back to the TIBCO Cloud, into ?Integration Apps?, then clicking on ?Environment & Tools?, choosing ?Agents? and then on the ?Filter By? panel on the left, click ?Hybrid?:

     

    1_VVu8lm9xn3Kc3f7I6vRW-A.thumb.png.54f11697eb1e64849629f0c350df5a21.png

    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.

    Now to go and build an app to test it all out!

    Build an Application in the TIBCO Cloud

    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 center (or more accurately, my laptop!), it?s only going to be a simple application that writes to a log ? but you can take that simple app and go from there.

    Configure a connection

    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:

     

    0_WZfwIh5nY4dPQzFg.thumb.png.00b9cd79014edc30618dc47447a5595b.png

    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.

     

    0_5vDzyFJWNotcnl0N.png.63f6c8f3cc17c622de2b3f6c4a269415.png

    When you have selected the connector, you will need to configure the details:

     

    0_AdEMDTUaUV3o2Ob-.png.45e09ccc6eb6897b85b1e7b9ff0a4c7b.png

    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.

    Create the App

    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?:

    0_9oihmy-pXerU3jwi.thumb.png.18ad0d6f666f159f6c4daf025e09df36.png

    Give your new app a name, by overwriting the name that is automatically generated in the top left corner:

     

    0_2jHsM1NTmKHf7v3E.thumb.png.38d27b926871d1c70af654ef077787c2.png

    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:

     

    0_mlS-lu9gMFr9sQ7Y.png.136b2c44b944197e5a1b04fb83a0c188.png

    You?ll be asked which connection you want to use ? and select the connection you created earlier, then click ?Create?

    You will now have an empty application that is triggered by mongoDB changes ? so now we want to add some logic.

     

    0_Rz993BBtrhDZOzWa.thumb.png.b73194dc8f61bac0673a3bc27a806fa1.png

    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?:

     

    0_N4nmziPairsCZ1Qy.png.b64fa76214730b2d31145639bd68685c.png

    Select your existing trigger and press ?Continue?:

     

    0_lxVbQjVLlqw6W97m.png.286227362dd172dcb923b01cc9e25bd7.png

    Choose ?Copy Schema?:

     

    0_OQQJY7hjRju7OyZe.png.ddd9cbbf08e5f8eb4a8af08de98ab6b0.png

    You will then be taken to a screen similar to the following:

     

    0_M8bEp0rWLc1JhAJJ.thumb.png.215dc50b989c89cdc4d777b06a795d0f.png

    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 an X because there is work to do. When you click on it, you will see the following:

     

    0_-Hp63bmrB_l7SkeO.thumb.png.8e19a6f4667254877b567dd06ce48a8d.png

    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.

    I want to listen to all events, so I will leave them as default, then click on ?Save? when ready.

    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:

     

    0_oFcel7fCcgGOwyVz.thumb.png.50454cd43008fa82d4d41ebc997de926.png

    The ?Flow Input? panel is what the flow itself is expecting. On the right-hand side ? 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 center and click on ?{} output? to insert the mapping into the panel above. What you should end up with is the following:

     

    0_tbZfTnaHjib6rjlF.thumb.png.9098e7f6f37ffb16a33db3068a96a333.png

    Click ?Save? when happy and then click on the ?x? button on the top right of the dialog to close this window.

    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:

     

    0_FFZOkMgA_sCqicBI.thumb.png.3f333fdd4c4bfda458a33b0eab225891.png

    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:

     

    1_KLlTvm2Z42aS5-_znMSKEQ(1).thumb.png.263ea45defd9ea7b25a118aeab89b21f.png

    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), and 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:

     string.concat(?Received ?,$flow.output.OperationType," Event")

    Which will just output the type of trigger that we received:

     

    1_CoeE3_RzBF1hc1qwqFPq1Q.thumb.png.a23e8e0c66b726ae6c59e253eaea5bb0.png

    We?re ready to try out our application!

    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.

    Configure, Deploy & Run

    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:

     

    0_zriqk6dCBmy-twZS.thumb.png.712b00cf1a9f76587794458f3eab1c52.png

    Choose the key that you set up in Step 1 and click ?Push updates?

    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.

     

    0_xTjlCMLASHCXLsVO.thumb.png.50001be92c175c6aea01a8387c4d0673.png

    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:

     

    0_Wik5lBU2zrjRm-j4.thumb.png.c7bba166004fa84fa6cae566ef48c93f.png

    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:

     

    0_e2ATPN3ku23WdHWW.thumb.png.b6d3aed70dff19c38e743c49ba641988.png

    Look for the line:

     ?[flogo.trigger.mongodb.mongodb-event-listener] ? ===listening===? 

    This tells us that the application has successfully started and has created a connection through the tunnel into the local MongoDB application.

    If you get any failure at all ? then we will have to debug further.

    Test the App

    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 to the mongo cluster and used the following commands:

     mongodb-replicaset:PRIMARY> use customers switched to db products mongodb-replicaset:PRIMARY> db.customers.save({firstname: ?Dave?}) WriteResult({ ?nInserted? : 1 }) mongodb-replicaset:PRIMARY> db.customers.find() { ?_id? : ObjectId(?5ffdb8db3405ea9985f1e92f?), ?firstname? : ?Dave? } mongodb-replicaset:PRIMARY> db.customers.save({firstname: ?David?}) WriteResult({ ?nInserted? : 1 }) mongodb-replicaset:PRIMARY> db.customers.save({firstname: ?Davie?}) WriteResult({ ?nInserted? : 1 }) mongodb-replicaset:PRIMARY> db.customers.save({firstname: ?Davey?}) WriteResult({ ?nInserted? : 1 }) mongodb-replicaset:PRIMARY> db.customers.save({firstname: ?Abhijeet?}) WriteResult({ ?nInserted? : 1 }) mongodb-replicaset:PRIMARY>

    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.

     

    0_SYsPIrUIPgyFAVdQ.thumb.png.e386c9ceab65dd5df7861fb6a27642ab.png

    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.

    Your next task would be to expand that application to perform whatever you need in order to process the MongoDB updates.

    To find out more about TIBCO Cloud Integration ? go to https://cloud.tibco.com


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...