mirror of https://github.com/apache/activemq.git
added a test case showing how to set a property using a Processor http://www.nabble.com/setting-JMSXGroupId-property-from-within-a-processor-tp15706825s22882p15706825.html
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@631509 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e404981736
commit
5075fb9dea
|
@ -201,6 +201,11 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- database testing -->
|
<!-- database testing -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<person user="james">
|
||||||
|
<firstName>James</firstName>
|
||||||
|
<lastName>Strachan</lastName>
|
||||||
|
<city>London</city>
|
||||||
|
</person>
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.activemq.camel;
|
||||||
|
|
||||||
|
import org.apache.camel.Exchange;
|
||||||
|
import org.apache.camel.Processor;
|
||||||
|
import org.apache.camel.Message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version $Revision: 1.1 $
|
||||||
|
*/
|
||||||
|
public class SetGroupIdProcessor implements Processor {
|
||||||
|
public void process(Exchange exchange) throws Exception {
|
||||||
|
// lets copy the IN to the OUT message
|
||||||
|
Message out = exchange.getOut();
|
||||||
|
out.copyFrom(exchange.getIn());
|
||||||
|
|
||||||
|
// now lets set a header
|
||||||
|
out.setHeader("JMSXGroupID", "ABC");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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.activemq.camel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.camel.component.mock.MockEndpoint;
|
||||||
|
import org.apache.camel.EndpointInject;
|
||||||
|
import org.apache.camel.CamelContext;
|
||||||
|
import org.apache.camel.Exchange;
|
||||||
|
import org.apache.camel.util.ObjectHelper;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version $Revision: 1.1 $
|
||||||
|
*/
|
||||||
|
@ContextConfiguration
|
||||||
|
public class SetHeaderTest extends AbstractJUnit38SpringContextTests {
|
||||||
|
private static final transient Log LOG = LogFactory.getLog(SetHeaderTest.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected CamelContext camelContext;
|
||||||
|
|
||||||
|
@EndpointInject(uri = "mock:results")
|
||||||
|
protected MockEndpoint expectedEndpoint;
|
||||||
|
|
||||||
|
public void testMocksAreValid() throws Exception {
|
||||||
|
// lets add more expectations
|
||||||
|
expectedEndpoint.expectedMessageCount(1);
|
||||||
|
expectedEndpoint.message(0).header("JMSXGroupID").isEqualTo("ABC");
|
||||||
|
|
||||||
|
MockEndpoint.assertIsSatisfied(camelContext);
|
||||||
|
|
||||||
|
// lets dump the received messages
|
||||||
|
List<Exchange> list = expectedEndpoint.getReceivedExchanges();
|
||||||
|
for (Exchange exchange : list) {
|
||||||
|
Object body = exchange.getIn().getBody();
|
||||||
|
LOG.debug("Received: body: " + body + " of type: " + ObjectHelper.className(body) + " on: " + exchange);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!-- START SNIPPET: example -->
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||||
|
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
|
||||||
|
">
|
||||||
|
|
||||||
|
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
|
||||||
|
<route>
|
||||||
|
<from uri="file://src/test/data?noop=true"/>
|
||||||
|
<to uri="activemq:testQ-input"/>
|
||||||
|
</route>
|
||||||
|
<route>
|
||||||
|
<from uri="activemq:testQ-input"/>
|
||||||
|
<process ref="groupIdInsertionProcessor"/>
|
||||||
|
<to uri="activemq:testQ-output"/>
|
||||||
|
</route>
|
||||||
|
<route>
|
||||||
|
<from uri="activemq:testQ-output"/>
|
||||||
|
<to uri="mock:results"/>
|
||||||
|
</route>
|
||||||
|
</camelContext>
|
||||||
|
|
||||||
|
<bean id="groupIdInsertionProcessor" class="org.apache.activemq.camel.SetGroupIdProcessor"/>
|
||||||
|
|
||||||
|
<bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
|
||||||
|
<property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
||||||
|
<!-- END SNIPPET: example -->
|
8
pom.xml
8
pom.xml
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<version>5.1-SNAPSHOT</version>
|
<version>5.1-SNAPSHOT</version>
|
||||||
<spring-version>2.0.6</spring-version>
|
<spring-version>2.5.1</spring-version>
|
||||||
<activesoap-version>1.3</activesoap-version>
|
<activesoap-version>1.3</activesoap-version>
|
||||||
<annogen-version>0.1.0</annogen-version>
|
<annogen-version>0.1.0</annogen-version>
|
||||||
<ant-version>1.6.2</ant-version>
|
<ant-version>1.6.2</ant-version>
|
||||||
|
@ -539,6 +539,12 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<version>${spring-version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Optional Derby support-->
|
<!-- Optional Derby support-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.derby</groupId>
|
<groupId>org.apache.derby</groupId>
|
||||||
|
|
Loading…
Reference in New Issue