Outcome message examples

This section describes the data in the message that the system produces when you use a Queue data source connector for Outcomes. It also provides code samples for consuming an Outcome message.

Outcome message format using the Queue data source connector

When you use a Queue data source connector for the Outcome data source the message has the format shown in the following table.

In addition, the following rules apply.

  • System-defined field names are camel case.
  • Data types start with a capital letter.
  • Valid data types are String, Integer, Double, Currency, Boolean, Date, and Tabular.
  • Values for Date and String data types are surrounded with double quotes.
  • Values for Integer, Double, Currency, Boolean, and Tabular data types are not surrounded with double quotes.

For AMQP, all the fields below except data are part of the AMQP custom header. Data is the payload part of the message.

Table 1. Message format for Outcome data
Name Value
producerName OpportunityDetect
clientID If you have multiple Opportunity Detect installations, enter the ID of the installation where this Queue data source connector is used, as defined in the clientId property under the IBM Opportunity Detect And Interact Adv Patterns | System category on the Settings > Configuration page. If you have a single Opportunity Detect installation, this value should be default.
actionName The name of the Action component that produced the Outcome.
workspaceName The name of the workspace.
deploymentName The name of the deployment that is running the workspace.
outputVersion The output version number entered on the Properties tab of the deployment configuration.
data The data you have specified in the Action component for your Outcome, plus the data that is included in every Outcome.

Outcome data always includes the audience ID, audience level, the ID of the Action component, and a time-stamp.

Time-stamps have this format:

yyyy-MM-dd HH:mm:ss

Additional fields that you specify in the Action component are output with the label you give the field in the Action component, the value, and the data type. This data can be a single value (scalar), or a row in a data record stored in a Container or Select component (tabular).

Sample code for consuming the Outcome message from JMS queue servers

This section applies to JMS servers. The way you use the Outcome message can vary depending on your needs. The following code snippet is a basic example.

Line breaks have been added for readability.


@Override
   public void listenforOutput() throws QueueConnectorException {
      try {
            Message message = consumer.receive(timeout);
            if (message != null) {
                        formatOutputMessage((MapMessage) message);
            } else {
                        System.out.println("No More messages on Queue!\n");
            }
       } catch (JMSException jmsex) {
            recordFailure(jmsex);
            destroy();
       }
	return;
    }

Sample code for consuming the Outcome message from AMQP queue servers

The way you use the Outcome message can vary depending on your needs. The following code snippet is a basic example.

Line breaks have been added for readability.


String queueName = channel.queueDeclare().getQueue();
channel.queueBind(queueName, queueConfiguration.getDestinationName(), "");
   Consumer consumer = new DefaultConsumer(channel) {
      @Override
      public void handleDelivery(String consumerTag, Envelope envelope, 
      AMQP.BasicProperties properties, byte[] body) throws IOException 
      {
         String message = new String(body, "UTF-8");
         System.out.println("Received :\n " + ": " + message + "\nHeader : 
         \n"+properties);			
      }
   };
   channel.basicConsume(queueName, true, consumer);

Example of the Outcome message from a JMS queue server

Here is an example of a message produced by the system when you use a Queue data source connector for an Outcome.

Line breaks have been added for readability.


producerName: OpportunityDetect,
clientID :default,
actionName:  "Name of Action component"
workspaceName :  "Name of workspace"
deploymentName : "Name of deployment"
outputVersion: "Version", 

data = [
  { 
    "message": {
        "value": "Pass", 
        "dataType": "String"
        } 
  },
  { 
    "audienceId": {
        "value": "acc333", 
        "dataType": "String"
        } 
  },
  { 
    "audienceLevel": {
        "value": "audienceLevelvalue", 
        "dataType": "String"
        } 
  },
  { 
    "componentId": {
        "value": "AA123344555666", 
        "dataType": "String"
        } 
  },
  { 
    "firingtime": {
       "value": "2014-04-01 05:40:01", 
       "dataType": "Date"
        } 
  },
  { 
    "fieldName1": {
        "value": 333, 
        "dataType": "Integer"
        } 
  },
  { 
    "fieldName2": {
        "value": "2014-04-01 05:40:01", 
        "dataType": "Date"
        } 
  },
  {
    "fieldName3": {
        "value": {
            "header" : [
                {
                    "tablefield1": {
                     "dataType": "String"
                    },
                }
                {
                    "tablefield2": {
                     "dataType": "Date"
                    }
                },
            ]
            rows : [
                    { 
                      "values" : ["value1","value2"]
                    },
                    { 
                      "values" : ["value1","value2"]
                    },
                    { 
                      "values" : ["value1","value2"]
                    },
              ]
         }, 
         "dataType": "Tabular" 
      }
   } 
]

Example of the Outcome message from an AMQP queue server

Output is sent to the queue server as durable message.


[ { "componentId" : 
    { "value" : "457e7bba-ae6a-4776-828e-f2d4ba174a06" , "dataType" : "String" } 
  },
  { "audienceId" : 
    { "value" : "Trans_ID" , "dataType" : "String" } 
  }, 
  { "audienceLevel" : 
    { "value" : "f2c9770b-44b0-46d1-b068-c9e9dcffbc60" , 
       "dataType" : "String" } 
    }, 
  { "firingtime" : 
    { "value" : "2014-08-15 04:40:10" , "dataType" : "Date" } 
  }, 
  { "message" : 
    { "value" : "This is outcome" , "dataType" : "String" } 
  }, 
  { "l1" : 
    { "value" : 100 , "dataType" : "Integer" } 
  } , 
  { "l2" : 
    { "value" : "Trans_ID" , "dataType" : "String" } 
  } , 
  { "Number" : 
    { "value" : 0 , "dataType" : "Integer" } 
  } , 
  { "string" : 
    { "value" : "" , "dataType" : "String" } 
  } , 
  { "double" : 
    { "value" : 0 , "dataType" : "Double" } 
} ]