本文整理汇总了Java中org.wso2.siddhi.core.stream.StreamJunction.subscribe方法的典型用法代码示例。如果您正苦于以下问题:Java StreamJunction.subscribe方法的具体用法?Java StreamJunction.subscribe怎么用?Java StreamJunction.subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.siddhi.core.stream.StreamJunction
的用法示例。
在下文中一共展示了StreamJunction.subscribe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addStreamJunction
import org.wso2.siddhi.core.stream.StreamJunction; //导入方法依赖的package包/类
/**
* create local streamJunctions through which events received by partitionStreamReceiver, are sent to
* queryStreamReceivers
*
* @param key partitioning key
* @param queryRuntimeList queryRuntime list of the partition
*/
public void addStreamJunction(String key, List<QueryRuntime> queryRuntimeList) {
StreamJunction streamJunction = cachedStreamJunctionMap.get(streamId + key);
if (streamJunction == null) {
streamJunction = partitionRuntime.getLocalStreamJunctionMap().get(streamId + key);
if (streamJunction == null) {
streamJunction = createStreamJunction();
partitionRuntime.addStreamJunction(streamId + key, streamJunction);
}
cachedStreamJunctionMap.put(streamId + key, streamJunction);
}
for (QueryRuntime queryRuntime : queryRuntimeList) {
StreamRuntime streamRuntime = queryRuntime.getStreamRuntime();
for (int i = 0; i < queryRuntime.getInputStreamId().size(); i++) {
if ((streamRuntime.getSingleStreamRuntimes().get(i)).getProcessStreamReceiver().getStreamId().equals
(streamId + key)) {
streamJunction.subscribe((streamRuntime.getSingleStreamRuntimes().get(i))
.getProcessStreamReceiver());
}
}
}
}
示例2: addCallback
import org.wso2.siddhi.core.stream.StreamJunction; //导入方法依赖的package包/类
public void addCallback(String streamId, StreamCallback streamCallback) {
streamCallback.setStreamId(streamId);
StreamJunction streamJunction = streamJunctionMap.get(streamId);
if (streamJunction == null) {
throw new DefinitionNotExistException("No stream found with name: " + streamId);
}
streamCallback.setStreamDefinition(streamDefinitionMap.get(streamId));
streamCallback.setContext(siddhiAppContext);
streamJunction.subscribe(streamCallback);
}
示例3: JunctionToReceiverTest
import org.wso2.siddhi.core.stream.StreamJunction; //导入方法依赖的package包/类
@Test
public void JunctionToReceiverTest() throws InterruptedException {
log.info("junction to receiver");
StreamDefinition streamA = new StreamDefinition("streamA").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).
annotation(Annotation.annotation("config").element("async", "true"));
StreamJunction streamJunctionA = new StreamJunction("streamA",streamA, executorService, 1024);
StreamJunction.Publisher streamPublisherA = streamJunctionA.constructPublisher();
StreamCallback streamCallback = new StreamCallback() {
@Override
public void receive(Event[] streamEvents) {
count += streamEvents.length;
eventArrived = true;
}
};
streamJunctionA.subscribe(streamCallback);
streamJunctionA.startProcessing();
streamPublisherA.send(new StreamEvent(2, 2, 2));
streamPublisherA.send(new StreamEvent(2, 2, 2));
Thread.sleep(100);
Assert.assertTrue(eventArrived);
Assert.assertEquals(2, count);
}