當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。