-
Notifications
You must be signed in to change notification settings - Fork 1
/
SampleClient.php
executable file
·48 lines (33 loc) · 1.42 KB
/
SampleClient.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
error_reporting(E_ALL);
include_once __DIR__ . '/vendor/autoload.php';
use org\wso2\carbon\databridge\commons\thrift\service\general\ThriftEventTransmissionServiceClient;
use publisher\Publisher;
use publisher\Event;
use publisher\PublisherConfiguration;
use publisher\PublisherConstants;
$receiverURL = 'tcp://10.100.5.198:7611';;
$authenticationURL = 'https://localhost:9443';
$username = 'admin';
$password = 'admin';
try {
$configuration = new PublisherConfiguration(true, PublisherConstants::CAFILE_PATH);
$publisher = new Publisher($receiverURL, $username, $password, $authenticationURL, $configuration);
echo $publisher->findStream ( "online_news_stats", "1.0.0" );
$streamDefinition = "{ 'name':'test_stream_definition', "
."'version':'2.0.3', "
."'metaData':[{'name':'publisherIP','type':'STRING'}],"
."'payloadData':[ {'name':'message','type':'STRING'},"
."{'name':'from','type':'STRING'} ] }";
$streamId = $publisher->addStreamDefinition($streamDefinition);
$event = new Event($streamId, time());
$metaData = ['1.2.3.4'];
$payloadData = ['Test Message','Pub'];
$arbitraryDataMap = ['x'=>'arb1','y'=>'arb2'];
$event->setMetaData($metaData);
$event->setPayloadData($payloadData);
$event->setArbitraryDataMap($arbitraryDataMap);
$publisher->publish($event);
}catch(Exception $e){
echo $e->getMessage();
}