Test Reappt on IBM Bluemix

Share this post:

With Reappt, you can build reactive apps with extreme speed and scale. Getting started with Reappt is easy, once you are signed up, it is time to test it out. The quickest way to create topics and publish to them is by using the TEST CLIENT tab on the Reappt Dashboard:

Reappt Test Client

To get started with testing, follow the steps below:

  • Connect the test client. For the Reappt service, use the ‘admin’ user you created in Getting started with Reappt. This user has the permission needed to create and publish to topics. Put the username and password in the Login Details fields and click ‘Connect’. The Console on the right shows you what’s going on.
  • Create a topic. Put a topic path in the ‘Topic Path’ field of the Topic Control section. The topic path is the address of the topic. For this example, call the topic first_topic. Click ‘Add topic’ to create the topic on your Reappt service.
  • Subscribe to your topic. Put first_topic in the Topic Path field of the Subscription section and click ‘Subscribe’ to subscribe to data published on your topic.
  • Publish some data. In the Topic Control section, with first_topic in the Topic Path field, type your data into the Topic Data field, how about “Hello world!”. Click ‘Update Topic’.

The data is published to the Reappt topic, and because the test client is also subscribed to that topic, it receives the update and displays it in the console. Publishing data with Reappt is that easy!

Code for publish/subscribe clients

Time to write your own clients. You can write a client in Java, .NET, JavaScript, iOS, Flash or Silverlight. We’re going to use JavaScript to create one client that publishes and another that subscribes.

Publishing client

First let’s get that data on a Reappt topic. How about a simple incrementing counter?

Create a Reappt JavaScript client as a Node.js application. For the purposes of this example, I’m assuming that you have Node.js and npm set up on your development system.

Install the Diffusion JavaScript library on your development system:

npm install diffusion

Create the JavaScript file that will be your publisher. For example, publisher.js. In the client file, require the Diffusion library:

var diffusion = require('diffusion');

Connect to Reappt:

host :'',
principal :'admin',
credentials :'password'

Replace service-name with the name of your Reappt service. Use the admin user that you created earlier. This user has the permissions required to create and update topics. The credentials value, password, is the admin user’s password.

Create a topic called foo/counter and set its initial value to 0:


Every second update the value of the topic with the value of a counter:


That’s your publishing client written. Use Node.js to run it from the command line:

node publisher.js

The client will publish a new value every second until it reaches 1000. Go to the Test Client tab on the Reappt dashboard and subscribe to foo/counter to watch the data being published in real-time.

Grab the full code of the example here: publisher.js

Subscribing client

Now that you have a client that publishes to topics, the other half of the story is a client that subscribes to topics. Again we’re going to use JavaScript, but in this case the client is going to be a browser client that displays the topic data in a web page.

Create an HTML page which will display the data:

<title>JavaScript example</title>
<span>The value of foo/counter is: </span>
<span id="update">Unknown</span>

If you open the page in a web browser, it looks like this:

JavaScript Example

Include the Reappt JavaScript library in thesection of your index.html file:

<title>JavaScript example</title>
<script type="text/javascript" src=""></script>

Create a connection from the page to the Reappt service. Add a script element to the body element:

<span>The value of foo/counter is: </span>
<span id="update">Unknown</span>
<script type="text/javascript">
// Edit this line to include the URL of your Reappt service
host : '',
// To connect anonymously you can leave out the following parameters
principal : 'client',
credentials : 'password'
}).then(function(session) {
alert('Connected: ' + session.isConnected());

Where service-name is the name of your Reappt service. Use the client user that you created earlier. This user has the permissions required to subscribe to a topic. The credentials value, password, is the client user’s password.

Now, when you open the page in a web browser it pops up an alert box to let you know that the connection was successful:

JavaScript Alert

Subscribe to the foo/counter topic and receive data from it by adding this function before the diffusion.connect() call:

function subscribeToTopic(session) {
.on('update', function(data) {
document.getElementById('update').innerHTML = data;

The subscribe() method of the session object takes the name of the topic to subscribe to and emits an update event. The attached function takes the data from the topic and updates the update element of the web page with the topic data.

Change the function that is called on connection to the subscribeToTopic function you just created:


That’s it. You’ve created a client that subscribes to a topic and prints out the value to a web page:

JavaScript Example 2

The web page is updated every time the value of the foo/counter topic is updated. Run your publishing client and watch the subscribing client web page to see your two clients working together.

Grab the full code of the example here: index.html

What next?

You’ve tried out Reappt’s pub-sub capabilities, now it’s time to go further. With Reappt you can also:

  • Send messages directly to and from individual clients
  • Send messages directly to sets of clients based on their properties
  • Subscribe other clients to topics
  • Use authentication handlers to authenticate your users’ client sessions
  • Use clients to manage the security configuration of your Reappt service
  • Manage the flow of data through your Reappt service.

With all these tools at your disposal, you’ll be creating your dream app in no time. If you want more information on Reappt or to stay up to date with product news, register here.

More How-tos stories
May 3, 2019

Kubernetes Tutorials: 5 Ways to Get You Building Fast

Ready to start working with Kubernetes? Want to build your Kubernetes skills? The five tutorials in this post will teach you everything you need to know about how to manage your containerized apps with Kubernetes.

Continue reading

May 3, 2019

Using Portworx to Deploy and Manage an HA MySQL Cluster on IBM Cloud Kubernetes Service

This tutorial is a walkthrough of the steps involved in deploying and managing a highly available MySQL cluster on IBM Cloud Kubernetes Service.

Continue reading

May 2, 2019

Kubernetes v1.14.1 Now Available in IBM Cloud Kubernetes Service

We are excited to announce the availability of Kubernetes v1.14.1 for your clusters that are running in IBM Cloud Kubernetes Service. IBM Cloud Kubernetes Service continues to be the first public managed Kubernetes service to support the latest upstream versions from the community.

Continue reading