当前位置: 首页>>代码示例>>Java>>正文


Java StreamJunction.subscribe方法代码示例

本文整理汇总了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());
            }
        }
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:29,代码来源:PartitionStreamReceiver.java

示例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);
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:11,代码来源:SiddhiAppRuntime.java

示例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);

}
 
开发者ID:sacjaya,项目名称:siddhi-3,代码行数:28,代码来源:JunctionTestCase.java


注:本文中的org.wso2.siddhi.core.stream.StreamJunction.subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。