Hello World with Streaming Analytics service

Create a Hello World streaming application that simply prints Hello and DSX! to the PE console of the application. The application runs as a job in the Streaming Analytic service running on IBM Bluemix.


In [5]:
from streamsx.topology.topology import Topology
from streamsx.topology.context import *

topo = Topology("hello_dsx")
hw = topo.source(["Hello", "DSX!!"])
hw.print()

Now the application is submitted to the service, first we need to declare the VCAP services used to connect to the service.

This picks up the VCAP services from the file vcap_services.json create by the 'Create VCAP services' notebook. That must be run once before running this notebook.


In [6]:
service_name='debrunne-streams2'

In [7]:
import json

with open('vcap_services.json') as json_data:
    vs = json.load(json_data)

Now we submit the topo object that represents the application's topology to the ANALYTICS_SERVICE context, passing in the VCAP services information in the configuration.


In [8]:
cfg = {}
cfg[ConfigParams.VCAP_SERVICES] = vs
cfg[ConfigParams.SERVICE_NAME] = service_name
submit("ANALYTICS_SERVICE", topo, cfg)
print("Done - Submitted job!")


2017-01-24 12:45:50,063 - streamsx.topology.py_submit - INFO - Generating SPL and submitting application.
Jan 24, 2017 12:45:52 PM com.ibm.streamsx.topology.internal.context.remote.BuildServiceRemoteRESTWrapper remoteBuildAndSubmit
INFO: Submitting application to remote build.
Jan 24, 2017 12:46:24 PM com.ibm.streamsx.topology.internal.context.remote.BuildServiceRemoteRESTWrapper remoteBuildAndSubmit
INFO: The application built successfully.
Jan 24, 2017 12:46:25 PM com.ibm.streamsx.topology.internal.context.remote.BuildServiceRemoteRESTWrapper remoteBuildAndSubmit
INFO: Submitting job to remote instance.
Done - Submitted job!

More text about looking for the output.