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


Java NotifyBuilder类代码示例

本文整理汇总了Java中org.apache.camel.builder.NotifyBuilder的典型用法代码示例。如果您正苦于以下问题:Java NotifyBuilder类的具体用法?Java NotifyBuilder怎么用?Java NotifyBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NotifyBuilder类属于org.apache.camel.builder包,在下文中一共展示了NotifyBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRouteFileToFile

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
@Test
public void testRouteFileToFile() throws Exception {
    deleteDirectory("target/file2file");
    NotifyBuilder notify = new NotifyBuilder(context).from("activemq:queue:hello").whenDone(1).create();

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);

    template.sendBodyAndHeader("file://target/file2file/in", "Hello World", Exchange.FILE_NAME, "hello.txt");

    assertMockEndpointsSatisfied();

    notify.matchesMockWaitTime();

    File file = new File("target/file2file/out/hello.txt");
    assertTrue("The file should exists", file.exists());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:FileRouteToJmsToFileTest.java

示例2: testNoResponseOnFirstMessage

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
@Test
public void testNoResponseOnFirstMessage() throws Exception {
    int sendMessageCount = 5;
    acknowledged.setExpectedMessageCount(sendMessageCount - 1);
    timeout.expectedMessageCount(1);
    frame.setExpectedMessageCount(0);

    NotifyBuilder[] complete = new NotifyBuilder[sendMessageCount];
    for (int i = 0; i < sendMessageCount; ++i) {
        complete[i] = new NotifyBuilder(context).whenDone(i + 1).create();
    }

    mllpServer.disableResponse();

    source.sendBody(generateMessage(1));
    assertTrue("Messege 1 not completed", complete[0].matches(1, TimeUnit.SECONDS));

    mllpServer.enableResponse();

    for (int i = 1; i < sendMessageCount; ++i) {
        source.sendBody(generateMessage(i + 1));
        assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
    }

    assertMockEndpointsSatisfied(15, TimeUnit.SECONDS);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:MllpTcpClientProducerTest.java

示例3: testNotifyFrom

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
@Test
public void testNotifyFrom() throws Exception {
    // use from to indicate it should only be messages originating from the given endpoint
    NotifyBuilder notify = new NotifyBuilder(context)
            .from("seda:order").whenDone(1).create();

    template.sendBody("seda:quote", "Camel rocks");
    template.sendBody("seda:order", "123,2010-04-20'T'15:47:59,4444,5555");

    boolean matches = notify.matches(1, TimeUnit.SECONDS);
    assertTrue(matches);

    SedaEndpoint confirm = context.getEndpoint("seda:confirm", SedaEndpoint.class);
    assertEquals(1, confirm.getExchanges().size());
    assertEquals("OK,123,2010-04-20'T'15:47:59,4444,5555", confirm.getExchanges().get(0).getIn().getBody());
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:17,代码来源:NotifyTest.java

示例4: testBurstySampling

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
public void testBurstySampling() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(2);
    mock.setResultWaitTime(3000);

    List<Exchange> sentExchanges = new ArrayList<Exchange>();

    // send a burst of 5 exchanges, expecting only one to get through
    sendExchangesThroughDroppingThrottler(sentExchanges, 5);
    // sleep through a complete period
    Thread.sleep(1100);
    // send another 5 now
    sendExchangesThroughDroppingThrottler(sentExchanges, 5);

    notify.matchesMockWaitTime();
    mock.assertIsSatisfied();

    validateDroppedExchanges(sentExchanges, mock.getReceivedCounter());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:SamplingThrottlerTest.java

示例5: testZipFileUnmarshalDelete

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
public void testZipFileUnmarshalDelete() throws Exception {
    // there are 2 exchanges
    NotifyBuilder event = event().whenDone(2).create();

    getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
    template.sendBodyAndHeader("file:target/zip", "Hello World", Exchange.FILE_NAME, "hello.txt");
    assertMockEndpointsSatisfied();

    event.matchesMockWaitTime();

    File in = new File("target/zip/hello.txt");
    assertFalse("Should have been deleted " + in, in.exists());

    File out = new File("target/zip/out/hello.txt.zip");
    assertFalse("Should have been deleted " + out, out.exists());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:ZipDataFormatFileUnmarshalDeleteTest.java

示例6: xxxtestTokenPairPerformanceRoute

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
public void xxxtestTokenPairPerformanceRoute() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(size).create();

    boolean matches = notify.matches(5, TimeUnit.MINUTES);
    log.info("Processed file with " + size + " elements in: " + TimeUtils.printDuration(watch.stop()));

    log.info("Processed " + tiny.get() + " tiny messages");
    log.info("Processed " + small.get() + " small messages");
    log.info("Processed " + med.get() + " medium messages");
    log.info("Processed " + large.get() + " large messages");

    assertEquals((size / 10) * 4, tiny.get());
    assertEquals((size / 10) * 2, small.get());
    assertEquals((size / 10) * 3, med.get());
    assertEquals((size / 10) * 1, large.get());

    assertTrue("Should complete route", matches);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:TokenPairIteratorSplitChoicePerformanceTest.java

示例7: xxTestXPatPerformanceRoute

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
public void xxTestXPatPerformanceRoute() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(size).create();

    boolean matches = notify.matches(60, TimeUnit.SECONDS);
    log.info("Processed file with " + size + " elements in: " + TimeUtils.printDuration(watch.stop()));

    log.info("Processed " + tiny.get() + " tiny messages");
    log.info("Processed " + small.get() + " small messages");
    log.info("Processed " + med.get() + " medium messages");
    log.info("Processed " + large.get() + " large messages");

    assertEquals((size / 10) * 4, tiny.get());
    assertEquals((size / 10) * 2, small.get());
    assertEquals((size / 10) * 3, med.get());
    assertEquals((size / 10) * 1, large.get());

    assertTrue("Should complete route", matches);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:XPathSplitChoicePerformanceTest.java

示例8: testInOnly

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
public void testInOnly() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("seda:foo?timeout=1000");
        }
    });

    context.start();
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

    // no problem for in only as we do not expect a reply
    template.sendBody("direct:start", "Hello World");
    notify.matches(2, TimeUnit.SECONDS);

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:SedaNoConsumerTest.java

示例9: testFileConsumeDoneFileIssue

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
public void testFileConsumeDoneFileIssue() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();

    template.sendBodyAndHeader("file:target/done", "A", Exchange.FILE_NAME, "foo-a.txt");
    template.sendBodyAndHeader("file:target/done", "B", Exchange.FILE_NAME, "foo-b.txt");
    template.sendBodyAndHeader("file:target/done", "C", Exchange.FILE_NAME, "foo-c.txt");
    template.sendBodyAndHeader("file:target/done", "D", Exchange.FILE_NAME, "foo-d.txt");
    template.sendBodyAndHeader("file:target/done", "E", Exchange.FILE_NAME, "foo-e.txt");
    template.sendBodyAndHeader("file:target/done", "E", Exchange.FILE_NAME, "foo.done");

    assertTrue("Done file should exists", new File("target/done/foo.done").exists());

    getMockEndpoint("mock:result").expectedBodiesReceivedInAnyOrder("A", "B", "C", "D", "E");

    context.startRoute("foo");

    assertMockEndpointsSatisfied();
    assertTrue(notify.matchesMockWaitTime());

    Thread.sleep(250);

    // the done file should be deleted
    assertFalse("Done file should be deleted", new File("target/done/foo.done").exists());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:FileConsumeDoneFileIssueTest.java

示例10: testPollFileAndShouldBeDeletedAtThirdPoll

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
public void testPollFileAndShouldBeDeletedAtThirdPoll() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();

    template.sendBodyAndHeader("file://target/deletefile", body, Exchange.FILE_NAME, "hello.txt");
    context.startRoute("FromFilePollThirdTimeOkTest");

    getMockEndpoint("mock:result").expectedBodiesReceived(body);

    assertMockEndpointsSatisfied();
    assertTrue(notify.matchesMockWaitTime());
    assertEquals(3, counter);

    // assert the file is deleted
    File file = new File("target/deletefile/hello.txt");
    assertFalse("The file should have been deleted", file.exists());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:FromFilePollThirdTimeOkTest.java

示例11: testJmsToJdbcJmsCommit

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
@Test
public void testJmsToJdbcJmsCommit() throws Exception {
    checkInitialState();

    // use a notify to know when the message is done
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

    // use mock during testing as well
    getMockEndpoint("mock:a").expectedMessageCount(1);
    getMockEndpoint("mock:b").expectedMessageCount(1);

    template.sendBodyAndHeader("activemq:queue:inbox", "A", "uid", 123);

    // assert mock and wait for the message to be done
    assertMockEndpointsSatisfied();
    assertTrue("Should complete 1 message", notify.matchesMockWaitTime());

    // check that there is a message in the database and JMS queue
    assertEquals(new Integer(1), jdbcTemplate.queryForObject("select count(*) from CAMEL_MESSAGEPROCESSED", Integer.class));
    Object out = consumer.receiveBody("activemq:queue:outbox", 3000);
    assertEquals("DONE-A", out);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:FromJmsToJdbcIdempotentConsumerToJmsTest.java

示例12: testFilterIdempotent

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
@Test
public void testFilterIdempotent() throws Exception {
    checkInitialState();

    // use a notify to know when the message is done
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(3).create();

    // use mock during testing as well
    getMockEndpoint("mock:a").expectedMessageCount(3);
    // there should be 1 duplicate
    getMockEndpoint("mock:b").expectedMessageCount(2);

    template.sendBodyAndHeader("activemq:queue:inbox", "D", "uid", 111);
    template.sendBodyAndHeader("activemq:queue:inbox", "E", "uid", 222);
    template.sendBodyAndHeader("activemq:queue:inbox", "D", "uid", 111);

    // assert mock and wait for the message to be done
    assertMockEndpointsSatisfied();
    assertTrue("Should complete 3 messages", notify.matchesMockWaitTime());

    // check that there is two messages in the database and JMS queue
    assertEquals(new Integer(2), jdbcTemplate.queryForObject("select count(*) from CAMEL_MESSAGEPROCESSED", Integer.class));
    assertEquals("DONE-D", consumer.receiveBody("activemq:queue:outbox", 3000));
    assertEquals("DONE-E", consumer.receiveBody("activemq:queue:outbox", 3000));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:FromJmsToJdbcIdempotentConsumerToJmsTest.java

示例13: testFromFileToFtpDelete

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
@Test
public void testFromFileToFtpDelete() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);

    template.sendBodyAndHeader("file:target/delete", "Hello World", Exchange.FILE_NAME, "hello.txt");

    assertMockEndpointsSatisfied();
    assertTrue(notify.matchesMockWaitTime());

    // file should be deleted
    File file = new File("target/delete/hello.txt");
    assertFalse("File should be deleted", file.exists());

    // file should exists on ftp server
    file = new File(FTP_ROOT_DIR + "/hello.txt");
    assertTrue("File should exist on ftp server", file.exists());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:FromFileToFtpDeleteTest.java

示例14: testZipkinRoute

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
@Test
public void testZipkinRoute() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }

    MBeanServer mbeanServer = getMBeanServer();
    ObjectName on = new ObjectName("org.apache.camel:context=camel-1,type=services,name=ZipkinTracer");
    assertNotNull(on);
    assertTrue(mbeanServer.isRegistered(on));

    Float rate = (Float) mbeanServer.getAttribute(on, "Rate");
    assertEquals("Should be 1.0f", 1.0f, rate.floatValue(), 0.1f);

    NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();

    for (int i = 0; i < 5; i++) {
        template.sendBody("seda:dude", "Hello World");
    }

    assertTrue(notify.matches(30, TimeUnit.SECONDS));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:ManagedZipkinSimpleRouteTest.java

示例15: testXPathSTaXPerformanceRoute

import org.apache.camel.builder.NotifyBuilder; //导入依赖的package包/类
@Test
public void testXPathSTaXPerformanceRoute() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(size).create();

    boolean matches = notify.matches(60, TimeUnit.SECONDS);
    log.info("Processed file with " + size + " elements in: " + TimeUtils.printDuration(watch.stop()));

    log.info("Processed " + tiny.get() + " tiny messages");
    log.info("Processed " + small.get() + " small messages");
    log.info("Processed " + med.get() + " medium messages");
    log.info("Processed " + large.get() + " large messages");

    assertEquals((size / 10) * 4, tiny.get());
    assertEquals((size / 10) * 2, small.get());
    assertEquals((size / 10) * 3, med.get());
    assertEquals((size / 10) * 1, large.get());

    assertTrue("Should complete route", matches);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:StAXXPathSplitChoicePerformanceTest.java


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