Skip to the main content.
Downloads Try Thriftly
Downloads Try Thriftly
Group 762

Migrate and run DataFlex applications with Oracle, MS SQL Server, PostgreSQL, MySQL &  MariaDB.

flex2Crystal

Stuck in Crystal XI?  Upgrade and use the latest versions of Crystal Reports with DataFlex applications. 

BTR2SQL

Convert from Btrieve / P.SQL / Actian transactional engines to Oracle, MS SQL Server, and PostgreSQL

thriftly-1

Quickly build multi-protocol web services with the same API. Supports JSON-RPC, REST, SOAP,  Thrift, and gRPC.

 Group 671-1

 

Why Mertech?

6 min read

Connecting your desktop application to the cloud through a Thriftly API

Connecting your desktop application to the cloud through a Thriftly API

The cloud—It’s the movement that is revolutionizing the way we interact with our data, our customers, and with each other.

And yet, as enticing as that sounds, and as much as you want your business to be “in the cloud,” you’re sitting on top of years and years of custom software development, and it’s right where you want it to be. The reality is that your organization isn’t alone in this conundrum. Organizations around the world face the same problem—desire to benefit from moving into the cloud, and hesitation at the prospect of losing investments made. There is a solution, however, and we’re going to talk about it in this article.

I’d like to introduce you to an alternative that offers the benefits of cloud computing, and at the same time leverages the software you already have. I’ll briefly explain what the cloud is and what an application programming interface (or API) is. I’ll then look at how Thriftly.io can help you integrate to the cloud using APIs. We’ll also discuss the security of your data, and other solutions that you might want to consider.

What Exactly is “The Cloud”?

Let’s begin with a quick primer on the meaning of the cloud. You’re probably familiar with the concept already, but the cloud can mean different things to different people, so it’s worth clarifying what it means for our purposes.

Here, we’re defining the cloud broadly. Essentially, whenever an organization moves its applications to the cloud, it means that the company’s applications can be accessed from anywhere in the world. It challenges the paradigm of workers assigned to a desktop computer connected to a corporate network and replaces it with the idea that an employee can access applications and data from any device, anywhere in the world.

Application Programming Interfaces (APIs)

Next, let’s define what an application programming interface, or API, is.

In layman's terms, an API is an interface between two computer programs that allows each program to exchange information with the other one. The API has a clear description of what kind of data can be passed through it, and how it should be constructed. One of the biggest benefits to using an API is that you can connect two systems that might have been written in different software languages and running on different operating systems.

Installing Thriftly Developer

If you want to connect multiple applications together via the cloud, an API is a preferred way to do it. And rather than trying to build a solution from scratch, you can take advantage of Thriftly, a commercial implementation of Apache Thrift. (Thrift itself is an API engine that originated at Facebook and is now an open source project.)

Below, I’ll explain how to set up Thriftly and get started using it.

First, you should be aware of the installation requirements:

installation-requirements-for-thriftly-developer

You will need to complete the following steps.

  • Create a new Thriftly.io account here.
  • Log in and then click on "Get a Trial License" to get your key. Thriftly offers a six-month trial.
  • Download the latest development version by clicking on the Download icon.
  • Install Thriftly, and register it with your Trial License.

Now we’re ready to play!

Thriftly provides development guides for DataFlex, .NET - C#, and Java. Each guide walks you through the setup required to use Thriftly Developer with the specific language, walks you through an example application, and then guides you through creating a new application from the ground up and how to test it.

Anatomy of a Thriftly Application

The overall structure of the application is agnostic to the language used to create it. I’ll be referencing Java code examples as we continue through this journey, and while there are nuances in the syntax, the same concepts used in the Java application apply to both C# and DataFlex.

standard-structure-of-thriftly-application

All Thriftly applications have a similar structure. Services are objects which define the data and associated interactions. These objects define the connections to the data sources and underlying business logic and provide a series of functions to allow interactions with the object.

Defining Objects and Functions

The example application includes one of these services which defines an Item. Here, we want one to retrieve an item.

function-to-retrieve-an-item-record-with-the-item-service-thriftly

Additional functions in this service specify how to search for a particular item, how to add an item, and how to edit an item.

Each of these services is registered with the Thriftly Server. The Thriftly Server is an object which is instantiated when the application is started. It is the server that controls the communication between the cloud, and the underlying code.

starting-the-thriftly-server-and-registering-all-of-the-services-main-java

Creating the service objects is the most complicated part of the process. There are two ways to achieve it. One is to convert an existing object or function into an API. This is the approach you’d have to take traditionally. It requires a fair amount of work.

The other possible solution is to create an write a new function or object from scratch, and let Thriftly handle the hard work of making it function as an API. Thriftly allows you to do this by simply writing a function or object. Thriftly will then expose your new function or object as a web API that supports multiple protocols, all of which run on the same process thread. Thriftly’s ability to support multiple protocols on one thread is a handy feature, because it means you can write a function once and reuse it in multiple applications -- for instance, in a desktop application as well as a Web app.

Once the services are created and registered with the server object, your application will be ready to test.

Testing with the API Testing Framework

Thriftly Developer includes an API testing framework. The Developer Guide contains a very thorough description of the testing tools available, instructions on how to use them, and an assortment of troubleshooting tools. If you would like to experience the testing framework, that can be easily done with the example applications. For the java example, this is as simple as running a batch file, run.bat in the root folder of the application. As above, I used the PropertyTracker application that came bundled with the Developer package.

Clicking on run.bat, or executing it from the command line will bring up the Thriftly Developer control panel. On this panel you have the option to select the communication protocol, selecting a port, encoding and choosing from a list of services. The control panel is displayed as a modal window, and so you don’t have to worry about losing it behind your other windows.

thriftly-developer-control-panel

Clicking on the “Start Thriftly” button will launch the Thriftly server on your local machine. The Thriftly server includes an intuitive environment to test the developed services. Some of the features I like with the testing utility are the ability to select from any of the methods defined in each service and select unique id’s to pass in. I also really like the “Raw” button which is located at the top right of the page. The “Raw” display shows the exact format of the request and response coming in and out of the service. You can view a screenshot of this information below the testing interface. As a developer, being able to view this information in its raw form is an invaluable tool in the development of web applications which will use this API. As may be noted in the images below, it is clear that I have come across a problem with the id I used to query the API.

thriftly-developer-apeye-testing-resource

thriftly-raw-request-and-response-from-the-preview-interaction-in-the-testing-portal

Next Steps

Once your application has been outfitted with Thriftly and tested, the next step is to deploy it to the cloud. Thriftly provides the necessary software tools and interfaces to do this. An application called the Thriftly Dispatcher connects the application on your local computer or data center to the Production Gateway. Once this connection has been made, and the application has been registered with the Gateway, you’ll then be able to interact with your APIs from the cloud.

Interacting with your APIs will require some web development to provide remote users with an interface through which to access your application. These web pages can be written in any scripting language suitable for the creation of web pages. The overwhelming benefit is that the web pages won’t need to implement any business logic or be concerned with the storage of data for the application. In using the API contract for the application, they are providing an interface for, they can leave all of the processing and data storage to the original application.

What Are the Risks?

The ability to provide users with an application platform that they can interact with—anywhere they have an Internet connection—will have an exponentially positive effect on your organization. However, this doesn’t come without the need to assume some risk. The type of data your application handles will have an impact on the amount of time and resources you devote to ensuring safety in the cloud. The developer guidebook provides an excellent starting point for a discussion about the security of your data. Topics covered include encryption, isolation and session management.

Another potential concern which organizations might have when publishing their APIs is the potential for an inadvertent exposure of an access point to the Internet. For APIs which are published through the Thriftly Gateway, the connections between the gateway and any on-premise computers are provided using an SSH Remote Port Forwarder. APIs may also be hosted within the local network of an organization, utilizing the existing security measure which may already be in place.

Are There Other Approaches I Should Consider?

The most obvious approach to moving your applications to the cloud is to rewrite them and move them onto a platform such as Amazon AWS, or Microsoft Azure. There are companies which take this approach, but they do so at great expense and with additional investment in application development.

Similar approaches to the one offered by Thriftly are also available. Companies such as LSQ, DreamFactory, and Nanoscale.io all offer a similar approach with unique differences. Whereas Thriftly offers an API development tool, and a platform to connect those APIs to the Internet, LSQ and Nanoscale employ an approach creating your APIs, together with a series of microservices, which can then be deployed on a platform such as those offered by Amazon and Microsoft.

Determining which approach will work best for your company will require careful research and consideration on cost, time investment and long-term viability. One thing is for certain—Given the speed at which the world of information technology is evolving, the decision to wait and see is not an option.

Learn how to transform your Windows Desktop Application into
a Hybrid Cloud Application with Thriftly.io

New call-to-action

Legacy Application Modernization: Key Steps, Benefits & Best Practices

Legacy Application Modernization: Key Steps, Benefits & Best Practices

This blog post was co-authored with Riaz Merchant, President and CEO at Mertech. In the fast-paced software world, 'legacy' often signals a warning.

Read More
Hybrid Cloud Migration: Plan, Process and Advantages

Hybrid Cloud Migration: Plan, Process and Advantages

This post was co-authored with Riaz Merchant, President/CEO at Mertech Data Systems, Inc.

Read More
Financial Benefits of Cloud Migration & Hybrid Cloud Applications

Financial Benefits of Cloud Migration & Hybrid Cloud Applications

Shifting from your traditional legacy systems to the Cloud can be a game changer, as the benefits of cloud migration are numerous. Cloud computing...

Read More