Skip to content

Submitting to the Analytics Service (Bluemix)

Dan Debrunner edited this page Mar 29, 2016 · 1 revision

Submitting to the Analytics Service (Bluemix)

A topology can be submitted directly to the Streaming Analytics Service running on Bluemix.

Example submission code

Here's Java code that submits to the Streaming Analytic Service fred-streams taking the VCAP information from the file in /home/streamsadmin/vcap/streams. This file needs to contain a copy of the VCAP_SERVICES for your Bluemix account.

        Map<String,Object> config = new HashMap<>();
        config.put(AnalyticsServiceProperties.SERVICE_NAME, "fred-streams");
        config.put(AnalyticsServiceProperties.VCAP_SERVICES, new File("/home/streamsadmin/vcap/streams"));
        StreamsContextFactory.getStreamsContext(Type.ANALYTICS_SERVICE).submit(topology, config);

There are three options for specifying the location of the VCAP_SERVICES JSON

  • Environment variable VCAP_SERVICES containing the VCAP services JSON information.
  • Setting config parameter topology.service.vcap to a File object with the path of a file containing the VCAP services JSON information (example above)
  • Setting config parameter topology.service.vcap to a JSONObject containing the VCAP services JSON information

Using credentials as shown on the Streaming Analytics Dashboard

When the functionality was first added the credentials for the service were only available if an application was bound to the service. Since then the credentials are available directly from the dashboard in their JSON form. However they do not match what is required for jobs submission which is expecting the full VCAP_SERVICES JSON object.

The format required is this:

{
"streaming-analytics": [
{
  "name": "name-streams",
  "credentials": {
    "password": "XXXXXXXXXXXXXXXXXXXXX",
    "rest_port": "443",
    "bundles_path": "/jax-rs/bundles/service_instances/...",
    "statistics_path": "/jax-rs/streams/statitics/service_instances/...",
    "resources_path": "/jax-rs/resources/service_instances/...",
    "stop_path": "/jax-rs/streams/stop/service_instances/...",
    "rest_host": "streams-app-service.ng.bluemix.net",
    "jobs_path": "/jax-rs/jobs/service_instances/...",
    "start_path": "/jax-rs/streams/start/service_instances/...",
    "rest_url": "https://streams-app-service.ng.bluemix.net",
    "userid": "xxxxxxxxxxxxxxxxxxxxxxx",
    "status_path": "/jax-rs/streams/status/service_instances/..."
  }
}
]
}
  • name-streams is replaced by the name of your streaming analytic service, e.g. fred-streams
  • the credentials object is taken directly from your dashboard, this is one with the specific credential information removed