This documentation is for WSO2 Business Activity Monitor 2.0.0. View documentation for the latest release.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

 

This REST API sample will help you to understand how you can send events to BAM through the REST API. 

Prerequisites

You need to have curl installed and availale to the command line path

 

SAMPLE GUIDE 

 

1. Start the WSO2 BAM Server.

2. Go to $WSO2_BAM_HOME/samples/rest-api directory via console.

3. Execute the rest-api.sh script with command: ./rest-api.sh, When you do that, followings stream definitions and events will be published to BAM. 

 

Stream definition 1 (streamdefn1.json)

{
  "name":"stockquote.stream",
  "version": "1.0.2",
  "nickName": "Stock Quote Information",
  "description": "Some Desc",
  "tags":["foo", "bar"],
  "metaData":[
   {
     "name":"ipAdd",
     "type":"STRING"
   }
  ],
  "payloadData":[
  { 
    "name":"symbol",
    "type":"string"
  },
  {
    "name":"price",
    "type":"double"
  },
  {
    "name":"volume",
    "type":"int"
  },
  {
    "name":"max",
    "type":"double"
  },
  {
    "name":"min",
    "type":"double"
  }
 ]
}


  • curl command for saving stream definition 1, definition reads from streamdefn1.json file. 
curl -k --user admin:admin https://localhost:9443/datareceiver/1.0.0/streams/ --data @streamdefn1.json -H "Accept: application/json" -H "Content-type: application/json" -X POST

 


Events 1 (events1.json)

[
 {
   "payloadData" : ["IBM", 26.0, 848, 43.33, 2.3] ,
   "metaData" : ["123.233.0.1"] ,
   "timeStamp" : 1312345432
 },
 {
  "payloadData" : ["MSFT", 22.0, 233, 22.22, 4.3] ,
  "metaData" : ["5.211.1.1"]
 }
]


Stream definition 2 (streamdefn2.json)

{
   "name":"stockquote.stream.2",
   "version": "2.0.0",
   "nickName": "Stock Quote Information",
   "description": "Some Desc",
   "tags":["foo", "bar"],
   "metaData":[
  {
   "name":"ipAdd",
   "type":"STRING"
  }
 ],
  "payloadData":[
  {
   "name":"symbol",
   "type":"string"
  },
  {
   "name":"price",
   "type":"double"
  },
  {
   "name":"volume",
   "type":"int"
  },
  {
   "name":"max",
   "type":"double"
  },
  {
   "name":"min",
   "type":"double"
  }
 ],
  "correlationData": [
  {
   "name":"activityId",
   "type":"string"
  }
 ]
}


Events 2 (events2.json)


[
 {
   "payloadData" : ["IBM", 26.0, 848, 43.33, 2.3] ,
   "metaData" : ["123.233.0.1"] ,
   "correlationData" : ["2213-2324-2ffs-2444"],
   "timeStamp" : 1312345432
 },
 {
   "payloadData" : ["MSFT", 22.0, 233, 22.22, 4.3] ,
   "metaData" : ["5.211.1.1"],
   "correlationData" : ["1243-eeef-2969-3566"],
 }
]




 

  • No labels