use of com.ibm.streamsx.health.hapi.internal.HapiMessageSupplier in project streamsx.health by IBMStreams.
the class AdtIngest method run.
@Override
public void run() {
Topology topology = new Topology("AdtIngest");
AdtToModelMapper mapper = new AdtToModelMapper();
addDependencies(topology);
HapiMessageSupplier supplier = new HapiMessageSupplier(getPort());
supplier.setMessageClass(ADT_AXX.class);
TStream<Message> messages = topology.endlessSource(supplier);
// transform message to ADTEvent object
TStream<ADTEvent> adtEvents = messages.multiTransform(message -> {
return mapper.messageToModel(message);
});
// publish data as JSON
PublishAdtEvent.publish(adtEvents, getTopic());
try {
StreamsContextFactory.getStreamsContext(StreamsContext.Type.DISTRIBUTED).submit(topology);
} catch (Exception e) {
TRACE.error("Unable to submit topology", e);
}
}
use of com.ibm.streamsx.health.hapi.internal.HapiMessageSupplier in project streamsx.health by IBMStreams.
the class OruR01Ingest method run.
@Override
public void run() {
Topology topology = new Topology("OruR01Ingest");
ObxToSplMapper mapper = new ObxToSplMapper();
addDependencies(topology);
TStream<Message> messages = topology.endlessSource(new HapiMessageSupplier(getPort()));
// transform message to Observation object
TStream<Observation> observationStream = messages.multiTransform(message -> {
return mapper.messageToModel(message);
});
StreamSchema schema = Type.Factory.getStreamSchema(Observation.OBSERVATION_SCHEMA_SPL);
@SuppressWarnings("serial") SPLStream splObservations = SPLStreams.convertStream(observationStream, new BiFunction<Observation, OutputTuple, OutputTuple>() {
@Override
public OutputTuple apply(Observation observation, OutputTuple outTuple) {
return mapper.modelToSpl(observation, outTuple);
}
}, schema);
splObservations.print();
splObservations.publish(getTopic());
try {
StreamsContextFactory.getStreamsContext(StreamsContext.Type.DISTRIBUTED).submit(topology);
} catch (Exception e) {
TRACE.error("Unable to submit topology", e);
}
}
Aggregations