Hi all – I’m attempting to surface some output directly to the existing Apex 
dashboard. Based on the Twitter example here:
https://github.com/DataTorrent/Malhar/blob/release-2.0.0/demos/twitter/src/main/java/com/datatorrent/demos/twitter/TwitterTrendingHashtagsApplication.java

With the API here:

https://www.datatorrent.com/docs/guides/DTGatewayAPISpecification.html#h.gsxbm0ivxe5y

I am defining a PubSub socket as such:


public static Operator.InputPort<Object> getWebOutput(DAG dag,
                                                      String operatorName) {
    ConsoleOutputOperator operator = dag.addOperator(operatorName, new 
ConsoleOutputOperator());
    operator.setStringFormat(operatorName + ": %s");
    return operator.input;
}

public static Operator.InputPort<Object> getWebOutput(DAG dag,
                                                      String operatorName,
                                                      String topic) {
    String gatewayAddress = dag.getValue(DAG.GATEWAY_CONNECT_ADDRESS);
    if (!StringUtils.isEmpty(gatewayAddress)) {
        URI uri = URI.create("ws://" + gatewayAddress + "/pubsub");
        LOG.info("WebSocket with gateway at: " + gatewayAddress);
        PubSubWebSocketOutputOperator<Object> wsOut = 
dag.addOperator(operatorName,
                new PubSubWebSocketOutputOperator<>());
        wsOut.setUri(uri);
        wsOut.setTopic(topic);
        return wsOut.input;
    }

    return getWebOutput(dag, operatorName);
}

I however see the following error:
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py",
 line 338, in loads
    return _default_decoder.decode(s)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py",
 line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py",
 line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

An example of the JSON object I’m outputting is below:
{"type":"data", "topic":"test1", "data":["Elapsed":"1234", "Max 
(30s)":"5678ms", "Avg (30s)":"2000.00"ms, "Msgs/sec":"5000"]}


Any thoughts on what’s going on here or how I can debug this? The job does not 
ever appear to even launch. Thanks!
________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to 
Capital One and/or its affiliates and may only be used solely in performance of 
work or services for Capital One. The information transmitted herewith is 
intended only for use by the individual or entity to which it is addressed. If 
the reader of this message is not the intended recipient, you are hereby 
notified that any review, retransmission, dissemination, distribution, copying 
or other use of, or taking of any action in reliance upon this information is 
strictly prohibited. If you have received this communication in error, please 
contact the sender and delete the material from your computer.

Reply via email to