• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NotifyBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testReuse

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

    getMockEndpoint("mock:a").expectedBodiesReceived("Hello World");
    getMockEndpoint("mock:b").expectedBodiesReceived("Hello Hello World");
    getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Hello Hello World");

    template.sendBody("direct:start", "World\n");

    assertMockEndpointsSatisfied();

    assertTrue(notify.matchesMockWaitTime());

    assertEquals(2, channels.size());
    assertSame("Should reuse channel", channels.get(0), channels.get(1));
    assertFalse("And closed when routing done", channels.get(0).isOpen());
    assertFalse("And closed when routing done", channels.get(1).isOpen());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:NettyReuseChannelTest.java


示例17: testSendMultipleMessages

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

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

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

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


示例18: testMissingEndOfDataByte

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

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

    mllpServer.setExcludeEndOfDataModulus(sendMessageCount);

    for (int i = 0; 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,代码行数:20,代码来源:MllpTcpClientProducerTest.java


示例19: testMissingEndOfBlockByte

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

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

    mllpServer.setExcludeEndOfBlockModulus(sendMessageCount);

    for (int i = 0; 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,代码行数:20,代码来源:MllpTcpClientProducerTest.java


示例20: testApplicationAcceptAcknowledgement

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

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

    for (int i = 0; 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,代码行数:18,代码来源:MllpTcpClientProducerTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HttpMediaType类代码示例发布时间:2022-05-22
下一篇:
Java DTraceProviderFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap