Java 类org.apache.camel.component.infinispan.InfinispanConstants 实例源码

项目:wildfly-camel    文件:InfinispanIntegrationTest.java   
@Test
public void testCachePut() throws Exception {

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:put")
            .to("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&command=PUT");
        }
    });

    camelctx.start();
    try {
        Map<String, Object> headers = new HashMap<>();
        headers.put(InfinispanConstants.KEY, CACHE_KEY_NAME);
        headers.put(InfinispanConstants.VALUE, CACHE_VALUE_KERMIT);

        ProducerTemplate template = camelctx.createProducerTemplate();
        template.requestBodyAndHeaders("direct:put", null, headers);

        String name = (String) cacheContainer.getCache().get(CACHE_KEY_NAME);
        Assert.assertEquals("Kermit", name);
    } finally {
        camelctx.stop();
    }
}
项目:JBoss-Developers-Guide    文件:AFProcessor.java   
public void process(Exchange exchange) throws Exception {

    Message in = exchange.getIn();
    Map<String,Object> tuple= (Map<String, Object>) in.getBody();
    MoneyTransfer mt = new  MoneyTransfer();
    mt.setId((Long)tuple.get(MoneyTransfer.FIELD_ID));
    mt.setKeycode((String)tuple.get(MoneyTransfer.FIELD_KEYCODE));
    mt.setPaymentMethod((String)tuple.get(MoneyTransfer.FIELD_PAYMENT_METHOD));
    mt.setAmount_hf_sender_currency((BigDecimal)tuple.get(MoneyTransfer.FIELD_AMOUNT_HF_SENDER_CUR));
    mt.setStatus((String)tuple.get(MoneyTransfer.FIELD_STATUS));
    in.setBody(mt);
    in.setHeader(InfinispanConstants.KEY, mt.getKeycode());

}
项目:Camel    文件:InfinispanRemoteOperation.java   
public static Query buildQuery(InfinispanConfiguration configuration, BasicCache<Object, Object> cache, Message message) {
    InfinispanQueryBuilder queryBuilder = message.getHeader(InfinispanConstants.QUERY_BUILDER, InfinispanQueryBuilder.class);
    if (queryBuilder == null) {
        queryBuilder = configuration.getQueryBuilder();
    }

    return buildQuery(queryBuilder, cache);
}
项目:wildfly-camel    文件:InfinispanIntegrationTest.java   
@Test
public void testCacheGet() throws Exception {

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:get")
            .to("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&command=GET")
            .to("mock:end");
        }
    });

    cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);

    camelctx.start();
    try {
        Map<String, Object> headers = new HashMap<>();
        headers.put(InfinispanConstants.KEY, CACHE_KEY_NAME);

        ProducerTemplate template = camelctx.createProducerTemplate();
        String name = template.requestBodyAndHeaders("direct:get", null, headers, String.class);

        Assert.assertEquals("Kermit", name);
    } finally {
        camelctx.stop();
    }
}
项目:wildfly-camel    文件:InfinispanIntegrationTest.java   
@Test
public void testCacheRemove() throws Exception {

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:remove")
            .to("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&command=REMOVE");
        }
    });

    cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);

    camelctx.start();
    try {
        Assert.assertTrue(cacheContainer.getCache().containsKey(CACHE_KEY_NAME));

        Map<String, Object> headers = new HashMap<>();
        headers.put(InfinispanConstants.KEY, CACHE_KEY_NAME);

        ProducerTemplate template = camelctx.createProducerTemplate();
        template.requestBodyAndHeaders("direct:remove", null, headers);

        Assert.assertFalse(cacheContainer.getCache().containsKey(CACHE_KEY_NAME));
    } finally {
        camelctx.stop();
    }
}
项目:wildfly-camel    文件:InfinispanIntegrationTest.java   
@Test
public void testCacheEntryCreatedEvent() throws Exception {

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&sync=false&eventTypes=CACHE_ENTRY_CREATED")
            .to("mock:result");
        }
    });

    camelctx.start();
    try {
        cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);
        cacheContainer.getCache().put(CACHE_KEY_AGE, CACHE_VALUE_AGE);

        MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
        mockEndpoint.expectedMessageCount(4);

        mockEndpoint.message(0).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_CREATED");
        mockEndpoint.message(0).outHeader(InfinispanConstants.IS_PRE).isEqualTo(true);
        mockEndpoint.message(0).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);

        mockEndpoint.message(1).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_CREATED");
        mockEndpoint.message(1).outHeader(InfinispanConstants.IS_PRE).isEqualTo(false);
        mockEndpoint.message(1).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);

        mockEndpoint.message(2).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_CREATED");
        mockEndpoint.message(2).outHeader(InfinispanConstants.IS_PRE).isEqualTo(true);
        mockEndpoint.message(2).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_AGE);

        mockEndpoint.message(3).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_CREATED");
        mockEndpoint.message(3).outHeader(InfinispanConstants.IS_PRE).isEqualTo(false);
        mockEndpoint.message(3).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_AGE);

        mockEndpoint.assertIsSatisfied();
    } finally {
        camelctx.stop();
    }
}
项目:wildfly-camel    文件:InfinispanIntegrationTest.java   
@Test
public void testCacheEntryRemovedEvent() throws Exception {

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&sync=false&eventTypes=CACHE_ENTRY_REMOVED")
            .to("mock:result");
        }
    });

    cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);
    cacheContainer.getCache().put(CACHE_KEY_AGE, CACHE_VALUE_AGE);

    camelctx.start();
    try {
        MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
        mockEndpoint.expectedMessageCount(2);

        mockEndpoint.message(0).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_REMOVED");
        mockEndpoint.message(0).outHeader(InfinispanConstants.IS_PRE).isEqualTo(true);
        mockEndpoint.message(0).outHeader(InfinispanConstants.CACHE_NAME).isNotNull();
        mockEndpoint.message(0).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);

        mockEndpoint.message(1).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_REMOVED");
        mockEndpoint.message(1).outHeader(InfinispanConstants.IS_PRE).isEqualTo(false);
        mockEndpoint.message(1).outHeader(InfinispanConstants.CACHE_NAME).isNotNull();
        mockEndpoint.message(1).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);

        cacheContainer.getCache().remove("name");

        mockEndpoint.assertIsSatisfied();
    } finally {
        camelctx.stop();
    }
}
项目:wildfly-camel    文件:InfinispanIntegrationTest.java   
@Test
public void testCacheEntryModifiedEvent() throws Exception {

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&sync=false&eventTypes=CACHE_ENTRY_MODIFIED")
            .to("mock:result");
        }
    });

    cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);

    camelctx.start();
    try {
        MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
        mockEndpoint.expectedMessageCount(2);

        mockEndpoint.message(0).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_MODIFIED");
        mockEndpoint.message(0).outHeader(InfinispanConstants.IS_PRE).isEqualTo(true);
        mockEndpoint.message(0).outHeader(InfinispanConstants.CACHE_NAME).isNotNull();
        mockEndpoint.message(0).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);

        mockEndpoint.message(1).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_MODIFIED");
        mockEndpoint.message(1).outHeader(InfinispanConstants.IS_PRE).isEqualTo(false);
        mockEndpoint.message(1).outHeader(InfinispanConstants.CACHE_NAME).isNotNull();
        mockEndpoint.message(1).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);

        cacheContainer.getCache().replace(CACHE_KEY_NAME, CACHE_VALUE_BOB);

        mockEndpoint.assertIsSatisfied();
    } finally {
        camelctx.stop();
    }
}