Message:

Subscribe rss
Blog categories

In this article, we’ll talk about Backendless publish-subscribe messaging. One of the frequent questions we receive is: ‘How to get messages long after they are published.’ The default mechanism in Backendless keeps messages in the published channel for a short period of time only (around a minute). This becomes a problem if subscriber needs to have access to the messages after that time period has passed. This article describes an approach for storing published messages in Backendless database in order to keep published messages accessible even when they are no longer present in a messaging channel.

Publish-subscribe is a Backendless messaging pattern. The main idea here is to exchange data between a publisher* and subscriber** within a messaging channel***.

publisher – a program using the Publishing API to send messages to a channel.
** subscriber – a program using the Subscription API to receive messages from a channel.
*** channel – a logical intermediary “transporting” the messages.

In order to keep messages accessible for an infinite period of time – you can save messages into the Backendless database right after they were published. To accomplish this, we’ll need to combine Data service API and the afterPublish event handler which can be added to the Business Logic tab of your Backendless application.

handlerConfig 1024x565 - How to save published messages in the database

Once it’s added, just download the afterPublish handler code from ‘Download’ menu (you can select JavaScript or Java). Then open the generated project in any IDE and add the code to store published messages in a Backendless data table.

Alternatively, the afterPublish event handler can be added and deployed to cloud without any coding at all using Codeless business logic. Here are the steps of how it can be done:
1. Add new Codeless event handler Selection 143 1024x519 - How to save published messages in the database2. When the handler is saved, Codeless designer will be opened. Add the following blocks to your Codeless logic. When done – click the ‘DEPLOY MODEL’ button.
Selection 144 1024x535 - How to save published messages in the database
Voila!

To avoid nulls, every message should be published with a not null value for publisherId :

For this scenario we’ll need to create a data table (Data > APP TABLES in your Backendless application) called ‘ChatHistory’ and define the following schema in it:

  • Column publisher of type String 
  • Column messageData of type String 

dataTable 1024x557 - How to save published messages in the database

Once code for the handler is added, deploy the handler code to cloud using the following command in your IDE terminal:
./bin/Deploy.sh
Since the handler is deployed, every new message published to chatRoom channel will be stored in a dedicated data table and will be accessible at any required moment by calling an API to retrieve data from a table:

You will receive the following output:

It has not been a year since we released version 4 into GA (it went live on July 3rd, 2017). There were 48 “point” releases between then and now, but we also have been hard at work on the next major version of Backendless – version 5. The new release will be backward compatible – when the release goes live, your applications will continue to work as before. If you decide to upgrade the client-side libraries, you will get access to all the functionality in the new version. What does the roadmap for version 5 look like? See answer below:

  • Real-time Database – your app can subscribe to receive real-time updates when new objects are created in the database, or existing objects are updated or deleted.
  • Real-time Publish/Subscribe messaging – we changed the subscription model so the published messages are pushed to the client applications instead of the current “pull” model.
  • Real-time logging console – See and inspect your app’s log messages in Backendless console in real-time.
  • Remote Shared Objects (RSO) – This is a jewel of real-time messaging. Unless you had experience with RSOs in the Flash/Flex world, it will be a new concept for you. Wait for the release and be prepared to be amazed.
  • Redesigned Push Notifications Support – we have completely rebuilt support for push notifications. Virtually every push notification feature available in the latest Android and iOS versions will be supported in Backendless 5.
  • Mobile Landing Pages – We added a simple CMS (content management system) so you can create a landing page for your mobile app and host it in Backendless.
  • Zapier Integration – Connect your Backendless backend with 1000+ external services and APIs available in Zapier. Virtually every single API in Backendless would be available as a trigger or an action in Zapier.
  • Phone-based Authentication –  We added 2FA and the users of your apps will be able to login without any stored passwords.
  • Integration with External databases – This is a feature available only in Backendless Pro. It will let you connect your Backendless app with an external database (Oracle, MySQL, SQLServer, PostreSQL)
  • Docker-based architecture for Backendless Pro – Backendless Pro is changing to be based on Docker. This will allow for better management, scalability and software updates.

The real-time functionality is what slated for the 5.0 release. Other listed features will become available with the subsequent minor version releases.

We are very excited about Backendless 5 and I am sure you will love it too!

The release of Backendless 4.5.0 introduces support for file search in Backendless console. We already had search API in our SDKs (Android, iOS, JS, REST) and based on the feedback from the customers added search support in console. Here’s what you can do now in console:

Basic search

Type in a partial or full name of the file. Backendless displays a list of search results with the corresponding path. Clicking the file name in the “Name” column opens the file in a new browser tab. If the search result is a directory, clicking it will open the search result screen for that directory. There is also the “Search in subdirectories” checkbox, the meaning of which is quite self-explanatory:

basicsearch withsubs - File Search in Backendless Console

Search with a glob pattern

The search query can use the glob syntax to express patterns for file and directory names:

search with glob - File Search in Backendless Console

Search in Create a File Relation

Your database schema may include columns with the FILE REFERENCE type. Here’s an example of such data table column:

create file ref - File Search in Backendless Console

When you establish a relation with a specific file, you work with the popup shown below. As you can see, it now has an ability to perform file search:

create file ref popup - File Search in Backendless Console

Enjoy!

All available APIs for creating, updating and deleting objects in the Backendless database operate on single objects. It means when you need to store multiple objects in the database, each object requires a separate API call. This increases the number of API calls your app makes. While it is great for us (hey, our billing is based on the API calls), it is not that great for your app as it results in longer processing times and substandard user experience. Starting today, with the release of Backendless version 4.5.0 we’re introducing the new APIs which will allow you to create, update or delete multiple objects with a single API call.

Bulk Create

Saving multiple new objects in the database is now as simple as passing an array of objects to the server. The server responds with a collection of objectId values (which, for example, can be used in the createRelation  API). The bulk create API is supported in all SDKs as well as the REST interface.

Bulk Update

To update objects in the database, the API accepts a condition (where clause) which identifies a group of objects. In addition to the condition, the client must also provide an object containing the changes which should be applies to the selected objects.

Bulk Delete

Similar to “Bulk Update”, this API receives a condition which identifies a group of objects to be deleted.

All of the APIs can be extended using custom business logic’s before/after events.

You can find the documentation for these APIs in the developer guides:

If you have any smart IoT devices in your home or office and tried controlling them with Alexa, you might wonder how it actually works. In this guide you will learn about building a custom Alexa skill which will let you control a wi-fi enabled light bulb with Alexa. You will be able to turn the light on/off and change the light colors. You can see a demo of the completed project as well as an overview of its components in the video below:

The solution consists of the following components:

  • Amazon Alexa-enabled device (Amazon Echo)
  • A custom Alexa skill, which is an API service running in Backendless
  • Backendless SDK for Alexa, which provides functionality greatly reducing the amount of work you need to do when working with Alexa requests.
  • An API service which contains the logic of controlling the light bulb
  • A wi-fi enabled light bulb, for this we used a LIFX bulb.
Continue reading

mudasar 150x150 - Case study: a young entrepreneur discovers Backendless and a builds a social network for gamersHappy New Year, everyone!

Here at Backendless we hear a lot of cool and interesting stories about people using our technology to build awesome things. Every now and then we come across some truly inspiring ones. Here is a story of Mudasar Javed, a 16 year old developer from Australia who launched a social network app for gamers. It was quite exciting to learn about his path of learning about programming and how Backendless could help him with getting the app off the ground.

Click below to read the case study:

https://backendless.com/platform/ra1n-entertainment-case-study/

Posted in Case Study

This post describes the process of developing an API Service in Backendless with JavaScript. You will learn:

  • how configure your development environment
  • include NPM dependencies
  • run the service in the debug mode and test it using the Backendless console
  • deploy the service to Backendless

The service you will develop in this guide will provide APIs for controlling a LIFX wi-fi enabled light bulb. This very service is used in the article describing how to integrate Amazon Alexa with an IoT device using Backendless. This article references IntelliJ IDEA as the IDE, however, it is not required, you can use any code editor. Make sure to create a Backendless account and create an app in Backendless Cloud (the free tier or the trial option will be plenty to proceed).

Continue reading

This is Part 2 of the article about developing an Amazon Alexa skill without any coding. In Part 1 you learned the following:

  • How to create a Codeless API Service responsible for handling Amazon Alexa requests. The service completely removes the need for adding AWS Lambda functions, it also runs without any cost in the free plan of Backendless.
  • How to use the Backendless SDK for Alexa to send a response back to Alexa from a custom skill.
  • How to create a basic Alexa Skill and test it from the Amazon developer console.
  • How to invoke the skill on Alexa, process the invocation in your Codeless Backendless API service and get a response back on Alexa.

In this part of the article, you will learn the following:

  • Creating voice interaction model with “slots” – special placeholders for the “dynamic” parts of the requests for your skill
  • Processing slots in the Codeless API service in Backendless.
  • Executing codeless logic to do something useful and generate a meaningful response.

It is recommended (more like required) to go through Part 1 just so you have the basic environment setup. Also, make sure to watch the “Developing an Alexa Skill without any coding” video which shows the entire process in action.

Continue reading
Posted in Alexa, Codeless

backendless pro v4 - Backendless Pro version 4 is released

Backendless Pro, the standalone version of Backendless, is now officially released and is available for download. The new release includes the latest version of the Backendless Platform. Version 4, which was originally launched only for the Backendless Cloud product is a major improvement over the previous version.

The version 4 release includes:

  • Completely redesigned Backendless Console;
  • Support for both Java and JavaScript business logic;
  • Codeless Programming;
  • Significantly improved data querying capabilities;
  • Redesigned code generators;

The new Backendless Pro includes a free trial mode. See the Backendless Pro product page for details.

Performing a calculation on a group of database objects may be a complex task. For example, to calculate the sum of all orders for a customer would require retrieving all customer’s orders, iterating over them to calculate the mathematical sum of all amounts. This was yesterday! As of Backendless 4.4.0, you can use aggregate functions to calculate the average, sum, maximum and minimum values for a collection of objects without retrieving them from the server. Additionally, the system supports calculating object count for all records in the database or a record subset.

To use an aggregate function, simply request a property in a data retrieval request in the following format (the example below is for calculating the sum for the orderAmount  column):

The returned object includes the sum  property with the calculated value:

The name of the property can be modified by assigning an alias (using %20  to replace the spaces in the URL):

The result contains a value for the property named after the alias:

Grouping Results

Results can be grouped by a column. The column could be either in the same table or a related one. For example, the following request retrieves the sum of all orders grouped by related country:

Unlike the response above, the result for this query includes a collection of objects, each containing the sum for a related country:

It is also possible to apply a filter on the grouped values. This can be done using the having  clause. For example, the request below retrieves only the groups of countries where the total order amount is greater than 10000:

For more information about aggregate functions see the Backendless API documentation: