Repository: camel Updated Branches: refs/heads/master 31a2795f5 -> 20a3b67ed
CAMEL-9128: Camel-Hazelcast: Add a Ringbuffer producer Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/20a3b67e Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/20a3b67e Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/20a3b67e Branch: refs/heads/master Commit: 20a3b67ed010f158fbe49e792422ed07bb704066 Parents: 31a2795 Author: Andrea Cosentino <anco...@gmail.com> Authored: Thu Sep 10 12:30:15 2015 +0200 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Fri Sep 11 13:36:17 2015 +0200 ---------------------------------------------------------------------- .../component/hazelcast/HazelcastCommand.java | 2 +- .../component/hazelcast/HazelcastComponent.java | 14 ++- .../hazelcast/HazelcastComponentHelper.java | 5 + .../component/hazelcast/HazelcastConstants.java | 6 ++ .../ringbuffer/HazelcastRingbufferEndpoint.java | 40 +++++++ .../ringbuffer/HazelcastRingbufferProducer.java | 95 +++++++++++++++++ .../hazelcast/HazelcastErrorMessagesTest.java | 2 +- ...azelcastRingbufferProducerForSpringTest.java | 79 ++++++++++++++ .../HazelcastRingbufferProducerTest.java | 106 +++++++++++++++++++ .../spring/test-camel-context-ringbuffer.xml | 67 ++++++++++++ 10 files changed, 412 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastCommand.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastCommand.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastCommand.java index f97d017..1b7bab2 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastCommand.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastCommand.java @@ -18,6 +18,6 @@ package org.apache.camel.component.hazelcast; public enum HazelcastCommand { - map, multimap, queue, topic, seda, set, atomicvalue, instance, list, replicatedmap + map, multimap, queue, topic, seda, set, atomicvalue, instance, list, replicatedmap, ringbuffer } http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponent.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponent.java index 94a09aa..a0a4308 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponent.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponent.java @@ -32,6 +32,7 @@ import org.apache.camel.component.hazelcast.map.HazelcastMapEndpoint; import org.apache.camel.component.hazelcast.multimap.HazelcastMultimapEndpoint; import org.apache.camel.component.hazelcast.queue.HazelcastQueueEndpoint; import org.apache.camel.component.hazelcast.replicatedmap.HazelcastReplicatedmapEndpoint; +import org.apache.camel.component.hazelcast.ringbuffer.HazelcastRingbufferEndpoint; import org.apache.camel.component.hazelcast.seda.HazelcastSedaConfiguration; import org.apache.camel.component.hazelcast.seda.HazelcastSedaEndpoint; import org.apache.camel.component.hazelcast.set.HazelcastSetEndpoint; @@ -147,10 +148,19 @@ public class HazelcastComponent extends UriEndpointComponent { endpoint.setCommand(HazelcastCommand.set); } + + if (remaining.startsWith(HazelcastConstants.RINGBUFFER_PREFIX)) { + // remaining is anything (name it foo ;) + remaining = removeStartingCharacters(remaining.substring(HazelcastConstants.RINGBUFFER_PREFIX.length()), '/'); + endpoint = new HazelcastRingbufferEndpoint(hzInstance, uri, this, remaining); + endpoint.setCommand(HazelcastCommand.ringbuffer); + } + if (endpoint == null) { - throw new IllegalArgumentException(String.format("Your URI does not provide a correct 'type' prefix. It should be anything like 'hazelcast:[%s|%s|%s|%s|%s|%s|%s|%s|%s]name' but is '%s'.", + throw new IllegalArgumentException(String.format("Your URI does not provide a correct 'type' prefix. It should be anything like " + + "'hazelcast:[%s|%s|%s|%s|%s|%s|%s|%s|%s|%s]name' but is '%s'.", HazelcastConstants.MAP_PREFIX, HazelcastConstants.MULTIMAP_PREFIX, HazelcastConstants.ATOMICNUMBER_PREFIX, HazelcastConstants.INSTANCE_PREFIX, HazelcastConstants.QUEUE_PREFIX, - HazelcastConstants.SEDA_PREFIX, HazelcastConstants.LIST_PREFIX, HazelcastConstants.REPLICATEDMAP_PREFIX, HazelcastConstants.SET_PREFIX, uri)); + HazelcastConstants.SEDA_PREFIX, HazelcastConstants.LIST_PREFIX, HazelcastConstants.REPLICATEDMAP_PREFIX, HazelcastConstants.SET_PREFIX, HazelcastConstants.RINGBUFFER_PREFIX, uri)); } if (defaultOperation != -1) { http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponentHelper.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponentHelper.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponentHelper.java index 114fac5..a2d63e9 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponentHelper.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastComponentHelper.java @@ -125,6 +125,11 @@ public final class HazelcastComponentHelper { // topic addMapping("publish", HazelcastConstants.PUBLISH_OPERATION); + + // ringbuffer + addMapping("capacity", HazelcastConstants.GET_CAPACITY_OPERATION); + addMapping("readonceHead", HazelcastConstants.READ_ONCE_HEAD_OPERATION); + addMapping("readonceTail", HazelcastConstants.READ_ONCE_TAIL_OPERATION); } private void addMapping(String operationName, int operationNumber) { http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java index edc1090..e4e8405 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java @@ -31,6 +31,7 @@ public final class HazelcastConstants { public static final String SEDA_PREFIX = "seda:"; public static final String LIST_PREFIX = "list:"; public static final String SET_PREFIX = "set:"; + public static final String RINGBUFFER_PREFIX = "ringbuffer:"; /* * incoming header properties @@ -95,6 +96,11 @@ public final class HazelcastConstants { // topic public static final int PUBLISH_OPERATION = 37; + + // ring_buffer + public static final int READ_ONCE_HEAD_OPERATION = 38; + public static final int READ_ONCE_TAIL_OPERATION = 39; + public static final int GET_CAPACITY_OPERATION = 40; /* * header values http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/HazelcastRingbufferEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/HazelcastRingbufferEndpoint.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/HazelcastRingbufferEndpoint.java new file mode 100644 index 0000000..6b0df4a --- /dev/null +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/HazelcastRingbufferEndpoint.java @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hazelcast.ringbuffer; + +import com.hazelcast.core.HazelcastInstance; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.hazelcast.HazelcastDefaultEndpoint; + +public class HazelcastRingbufferEndpoint extends HazelcastDefaultEndpoint { + + public HazelcastRingbufferEndpoint(HazelcastInstance hazelcastInstance, String uri, Component component, final String cacheName) { + super(hazelcastInstance, uri, component, cacheName); + } + + public Consumer createConsumer(Processor processor) throws Exception { + throw new UnsupportedOperationException("You cannot send messages to this endpoint: " + getEndpointUri()); + } + + public Producer createProducer() throws Exception { + return new HazelcastRingbufferProducer(hazelcastInstance, this, cacheName); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/HazelcastRingbufferProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/HazelcastRingbufferProducer.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/HazelcastRingbufferProducer.java new file mode 100644 index 0000000..a1c35a5 --- /dev/null +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/HazelcastRingbufferProducer.java @@ -0,0 +1,95 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hazelcast.ringbuffer; + +import java.util.Map; + +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.ringbuffer.Ringbuffer; + +import org.apache.camel.Exchange; +import org.apache.camel.component.hazelcast.HazelcastComponentHelper; +import org.apache.camel.component.hazelcast.HazelcastConstants; +import org.apache.camel.component.hazelcast.HazelcastDefaultEndpoint; +import org.apache.camel.component.hazelcast.HazelcastDefaultProducer; + +public class HazelcastRingbufferProducer extends HazelcastDefaultProducer { + + private final Ringbuffer<Object> ringbuffer; + + public HazelcastRingbufferProducer(HazelcastInstance hazelcastInstance, HazelcastDefaultEndpoint endpoint, String cacheName) { + super(endpoint); + this.ringbuffer = hazelcastInstance.getRingbuffer(cacheName); + } + + public void process(Exchange exchange) throws Exception { + + Map<String, Object> headers = exchange.getIn().getHeaders(); + + int operation = lookupOperationNumber(exchange); + + switch (operation) { + + case HazelcastConstants.READ_ONCE_HEAD_OPERATION: + this.readOnceHead(exchange); + break; + + case HazelcastConstants.READ_ONCE_TAIL_OPERATION: + this.readOnceTail(exchange); + break; + + case HazelcastConstants.GET_CAPACITY_OPERATION: + this.getCapacity(exchange); + break; + + case HazelcastConstants.REMAINING_CAPACITY_OPERATION: + this.getRemainingCapacity(exchange); + break; + + case HazelcastConstants.ADD_OPERATION: + this.add(exchange); + break; + + default: + throw new IllegalArgumentException(String.format("The value '%s' is not allowed for parameter '%s' on the RINGBUFFER.", operation, HazelcastConstants.OPERATION)); + } + + // finally copy headers + HazelcastComponentHelper.copyHeaders(exchange); + } + + private void readOnceHead(Exchange exchange) throws InterruptedException { + exchange.getOut().setBody(this.ringbuffer.readOne(ringbuffer.headSequence())); + } + + private void readOnceTail(Exchange exchange) throws InterruptedException { + exchange.getOut().setBody(this.ringbuffer.readOne(ringbuffer.tailSequence())); + } + + private void getCapacity(Exchange exchange) throws InterruptedException { + exchange.getOut().setBody(this.ringbuffer.capacity()); + } + + private void getRemainingCapacity(Exchange exchange) throws InterruptedException { + exchange.getOut().setBody(this.ringbuffer.remainingCapacity()); + } + + private void add(Exchange exchange) { + final Object body = exchange.getIn().getBody(); + exchange.getOut().setBody(ringbuffer.add(body)); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java index 63f454c..ec365e6 100644 --- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java @@ -36,7 +36,7 @@ public class HazelcastErrorMessagesTest extends HazelcastCamelTestSupport { } catch (Exception e) { assertTrue(e.getMessage().contains( "Your URI does not provide a correct 'type' prefix. It should be anything like " - + "'hazelcast:[map:|multimap:|atomicvalue:|instance:|queue:|seda:|list:|replicatedmap:|set:]name' but is 'hazelcast://error:foo")); + + "'hazelcast:[map:|multimap:|atomicvalue:|instance:|queue:|seda:|list:|replicatedmap:|set:|ringbuffer:]name' but is 'hazelcast://error:foo")); } } http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastRingbufferProducerForSpringTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastRingbufferProducerForSpringTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastRingbufferProducerForSpringTest.java new file mode 100644 index 0000000..fbc4c8e --- /dev/null +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastRingbufferProducerForSpringTest.java @@ -0,0 +1,79 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hazelcast; + +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.ringbuffer.Ringbuffer; + +import org.junit.Test; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class HazelcastRingbufferProducerForSpringTest extends HazelcastCamelSpringTestSupport { + + @Mock + private Ringbuffer<Object> ringbuffer; + + @Override + protected void trainHazelcastInstance(HazelcastInstance hazelcastInstance) { + when(hazelcastInstance.getRingbuffer("foo")).thenReturn(ringbuffer); + } + + @Override + protected void verifyHazelcastInstance(HazelcastInstance hazelcastInstance) { + verify(hazelcastInstance, atLeastOnce()).getRingbuffer("foo"); + } + + @Override + protected AbstractApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("/META-INF/spring/test-camel-context-ringbuffer.xml"); + } + + @Test + public void testReadTail() throws InterruptedException { + when(ringbuffer.readOne(Matchers.anyLong())).thenReturn("pippo"); + Object result = template.requestBody("direct:readonceTail", 12L, String.class); + assertEquals("pippo", result); + } + + @Test + public void testAdd() throws InterruptedException { + when(ringbuffer.add(Matchers.anyLong())).thenReturn(13L); + Object result = template.requestBody("direct:add", 12L, Long.class); + assertEquals(13L, result); + } + + @Test + public void testCapacity() throws InterruptedException { + when(ringbuffer.capacity()).thenReturn(13L); + Object result = template.requestBody("direct:capacity", 12L, Long.class); + assertEquals(13L, result); + } + + @Test + public void testRemainingCapacity() throws InterruptedException { + when(ringbuffer.remainingCapacity()).thenReturn(2L); + Object result = template.requestBody("direct:remainingCapacity", "", Long.class); + assertEquals(2L, result); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastRingbufferProducerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastRingbufferProducerTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastRingbufferProducerTest.java new file mode 100644 index 0000000..2d5bb5f --- /dev/null +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastRingbufferProducerTest.java @@ -0,0 +1,106 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hazelcast; + +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.ringbuffer.Ringbuffer; + +import org.apache.camel.builder.RouteBuilder; +import org.junit.Test; +import org.mockito.Matchers; +import org.mockito.Mock; + +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class HazelcastRingbufferProducerTest extends HazelcastCamelTestSupport { + + @Mock + private Ringbuffer<Object> ringbuffer; + + @Override + protected void trainHazelcastInstance(HazelcastInstance hazelcastInstance) { + when(hazelcastInstance.getRingbuffer("foo")).thenReturn(ringbuffer); + } + + @Override + protected void verifyHazelcastInstance(HazelcastInstance hazelcastInstance) { + verify(hazelcastInstance, atLeastOnce()).getRingbuffer("foo"); + } + + @Test + public void testReadHead() throws InterruptedException { + when(ringbuffer.readOne(Matchers.anyLong())).thenReturn("pippo"); + Object result = template.requestBody("direct:readonceHead", 12L, String.class); + assertEquals("pippo", result); + } + + @Test + public void testReadTail() throws InterruptedException { + when(ringbuffer.readOne(Matchers.anyLong())).thenReturn("pippo"); + Object result = template.requestBody("direct:readonceTail", 12L, String.class); + assertEquals("pippo", result); + } + + @Test + public void testAdd() throws InterruptedException { + when(ringbuffer.add(Matchers.anyLong())).thenReturn(13L); + Object result = template.requestBody("direct:add", 12L, Long.class); + assertEquals(13L, result); + } + + @Test + public void testCapacity() throws InterruptedException { + when(ringbuffer.capacity()).thenReturn(13L); + Object result = template.requestBody("direct:capacity", 12L, Long.class); + assertEquals(13L, result); + } + + @Test + public void testRemainingCapacity() throws InterruptedException { + when(ringbuffer.remainingCapacity()).thenReturn(2L); + Object result = template.requestBody("direct:remainingCapacity", "", Long.class); + assertEquals(2L, result); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + + from("direct:readonceHead").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.READ_ONCE_HEAD_OPERATION)).to( + String.format("hazelcast:%sfoo", HazelcastConstants.RINGBUFFER_PREFIX)); + + from("direct:readonceTail").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.READ_ONCE_TAIL_OPERATION)).to( + String.format("hazelcast:%sfoo", HazelcastConstants.RINGBUFFER_PREFIX)); + + from("direct:add").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.ADD_OPERATION)).to( + String.format("hazelcast:%sfoo", HazelcastConstants.RINGBUFFER_PREFIX)); + + from("direct:capacity").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_CAPACITY_OPERATION)).to( + String.format("hazelcast:%sfoo", HazelcastConstants.RINGBUFFER_PREFIX)); + + from("direct:remainingCapacity").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REMAINING_CAPACITY_OPERATION)).to( + String.format("hazelcast:%sfoo", HazelcastConstants.RINGBUFFER_PREFIX)); + + } + }; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/20a3b67e/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-ringbuffer.xml ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-ringbuffer.xml b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-ringbuffer.xml new file mode 100644 index 0000000..982d9bf --- /dev/null +++ b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-ringbuffer.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> + + <camelContext xmlns="http://camel.apache.org/schema/spring"> + + <route> + <from uri="direct:add" /> + <setHeader headerName="CamelHazelcastOperationType"> + <constant>add</constant> + </setHeader> + <to uri="hazelcast:ringbuffer:foo" /> + </route> + + <route> + <from uri="direct:readonceHead" /> + <setHeader headerName="CamelHazelcastOperationType"> + <constant>readonceHead</constant> + </setHeader> + <to uri="hazelcast:ringbuffer:foo" /> + </route> + + <route> + <from uri="direct:readonceTail" /> + <setHeader headerName="CamelHazelcastOperationType"> + <constant>readonceTail</constant> + </setHeader> + <to uri="hazelcast:ringbuffer:foo" /> + </route> + + <route> + <from uri="direct:capacity" /> + <setHeader headerName="CamelHazelcastOperationType"> + <constant>capacity</constant> + </setHeader> + <to uri="hazelcast:ringbuffer:foo" /> + </route> + + <route> + <from uri="direct:remainingCapacity" /> + <setHeader headerName="CamelHazelcastOperationType"> + <constant>remainingCapacity</constant> + </setHeader> + <to uri="hazelcast:ringbuffer:foo" /> + </route> + </camelContext> + +</beans>