forked from apache/camel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added an ActiveMQ component which is automatically pre-configured to …
…work well with Apache ActiveMQ. For more details see http://cwiki.apache.org/CAMEL/activemq.html git-svn-id: https://svn.apache.org/repos/asf/activemq/camel/trunk@540547 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
20 changed files
with
605 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?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. | ||
--> | ||
|
||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>camel-activemq</artifactId> | ||
<name>Camel :: ActiveMQ</name> | ||
<description>Camel ActiveMQ support</description> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-jms</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.activemq</groupId> | ||
<artifactId>apache-activemq</artifactId> | ||
</dependency> | ||
|
||
|
||
<!-- testing --> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-core</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
|
||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<childDelegation>false</childDelegation> | ||
<useFile>true</useFile> | ||
<excludes> | ||
<!-- TODO - FIXME ASAP --> | ||
<exclude>**/JmsRouteUsingSpringWithAutoWireTest.*</exclude> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
</project> |
72 changes: 72 additions & 0 deletions
72
...s/camel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* | ||
* 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.activemq; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.component.jms.JmsComponent; | ||
import org.apache.camel.component.jms.JmsConfiguration; | ||
|
||
/** | ||
* The <a href="http://activemq.apache.org/camel/activemq.html">ActiveMQ Component</a> | ||
* | ||
* @version $Revision: 1.1 $ | ||
*/ | ||
public class ActiveMQComponent extends JmsComponent { | ||
/** | ||
* Creates an <a href="http://activemq.apache.org/camel/activemq.html">ActiveMQ Component</a> | ||
* | ||
* @return the created component | ||
*/ | ||
public static ActiveMQComponent activeMQComponent() { | ||
return new ActiveMQComponent(); | ||
} | ||
|
||
/** | ||
* Creates an <a href="http://activemq.apache.org/camel/activemq.html">ActiveMQ Component</a> | ||
* connecting to the given broker URL | ||
* | ||
* @param brokerURL the URL to connect to | ||
* @return the created component | ||
*/ | ||
public static ActiveMQComponent activeMQComponent(String brokerURL) { | ||
ActiveMQComponent answer = new ActiveMQComponent(); | ||
answer.getConfiguration().setBrokerURL(brokerURL); | ||
return answer; | ||
} | ||
|
||
public ActiveMQComponent() { | ||
} | ||
|
||
public ActiveMQComponent(CamelContext context) { | ||
super(context); | ||
} | ||
|
||
public ActiveMQComponent(ActiveMQConfiguration configuration) { | ||
super(configuration); | ||
} | ||
|
||
@Override | ||
public ActiveMQConfiguration getConfiguration() { | ||
return (ActiveMQConfiguration) super.getConfiguration(); | ||
} | ||
|
||
@Override | ||
protected JmsConfiguration createConfiguration() { | ||
return new ActiveMQConfiguration(); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...mel-activemq/src/main/java/org/apache/camel/component/activemq/ActiveMQConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* | ||
* 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.activemq; | ||
|
||
import org.apache.activemq.pool.PooledConnectionFactory; | ||
import org.apache.activemq.spring.ActiveMQConnectionFactory; | ||
import org.apache.camel.component.jms.JmsConfiguration; | ||
|
||
import javax.jms.ConnectionFactory; | ||
|
||
/** | ||
* @version $Revision: 1.1 $ | ||
*/ | ||
public class ActiveMQConfiguration extends JmsConfiguration { | ||
private String brokerURL = ActiveMQConnectionFactory.DEFAULT_BROKER_URL; | ||
|
||
public ActiveMQConfiguration() { | ||
} | ||
|
||
public String getBrokerURL() { | ||
return brokerURL; | ||
} | ||
|
||
/** | ||
* Sets the broker URL to use to connect to ActiveMQ using the | ||
* <a href="http://activemq.apache.org/configuring-transports.html">ActiveMQ URI format</a> | ||
* | ||
* @param brokerURL the URL of the broker. | ||
*/ | ||
public void setBrokerURL(String brokerURL) { | ||
this.brokerURL = brokerURL; | ||
} | ||
|
||
@Override | ||
public ActiveMQConnectionFactory getListenerConnectionFactory() { | ||
return (ActiveMQConnectionFactory) super.getListenerConnectionFactory(); | ||
} | ||
|
||
@Override | ||
public void setListenerConnectionFactory(ConnectionFactory listenerConnectionFactory) { | ||
if (listenerConnectionFactory instanceof ActiveMQConnectionFactory) { | ||
super.setListenerConnectionFactory(listenerConnectionFactory); | ||
} | ||
else { | ||
throw new IllegalArgumentException("ConnectionFactory " + listenerConnectionFactory | ||
+ " is not an instanceof " + ActiveMQConnectionFactory.class.getName()); | ||
} | ||
} | ||
|
||
@Override | ||
protected ConnectionFactory createListenerConnectionFactory() { | ||
ActiveMQConnectionFactory answer = new ActiveMQConnectionFactory(); | ||
answer.setBrokerURL(getBrokerURL()); | ||
return answer; | ||
} | ||
|
||
@Override | ||
protected ConnectionFactory createTemplateConnectionFactory() { | ||
return new PooledConnectionFactory(getListenerConnectionFactory()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
components/camel-activemq/src/main/java/org/apache/camel/component/activemq/package.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!-- | ||
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. | ||
--> | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
|
||
Defines the <a href="http://activemq.apache.org/camel/activemq.html">ActiveMQ Component</a> | ||
|
||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
...s/camel-activemq/src/main/resources/META-INF/services/org/apache/camel/component/activemq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class=org.apache.camel.component.activemq.ActiveMQComponent |
60 changes: 60 additions & 0 deletions
60
...mel-activemq/src/test/java/org/apache/camel/component/activemq/ActiveMQConfigureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.camel.component.activemq; | ||
|
||
import org.apache.activemq.pool.PooledConnectionFactory; | ||
import org.apache.activemq.spring.ActiveMQConnectionFactory; | ||
import org.apache.camel.ContextTestSupport; | ||
import org.apache.camel.Endpoint; | ||
import org.apache.camel.component.jms.JmsConsumer; | ||
import org.apache.camel.component.jms.JmsEndpoint; | ||
import org.apache.camel.component.jms.JmsProducer; | ||
import org.apache.camel.processor.Logger; | ||
import org.springframework.jms.core.JmsTemplate; | ||
import org.springframework.jms.listener.AbstractMessageListenerContainer; | ||
|
||
/** | ||
* @version $Revision: 538973 $ | ||
*/ | ||
public class ActiveMQConfigureTest extends ContextTestSupport { | ||
|
||
public void testJmsTemplateUsesPoolingConnectionFactory() throws Exception { | ||
JmsEndpoint endpoint = resolveMandatoryEndpoint("activemq:test.foo"); | ||
JmsProducer producer = endpoint.createProducer(); | ||
|
||
JmsTemplate template = assertIsInstanceOf(JmsTemplate.class, producer.getTemplate()); | ||
assertIsInstanceOf(PooledConnectionFactory.class, template.getConnectionFactory()); | ||
assertEquals("pubSubDomain", false, template.isPubSubDomain()); | ||
} | ||
|
||
public void testListenerContainerUsesSpringConnectionFactory() throws Exception { | ||
JmsEndpoint endpoint = resolveMandatoryEndpoint("activemq:topic:test.foo"); | ||
JmsConsumer consumer = endpoint.createConsumer(new Logger()); | ||
|
||
AbstractMessageListenerContainer listenerContainer = consumer.getListenerContainer(); | ||
assertIsInstanceOf(ActiveMQConnectionFactory.class, listenerContainer.getConnectionFactory()); | ||
assertEquals("pubSubDomain", true, listenerContainer.isPubSubDomain()); | ||
|
||
} | ||
|
||
@Override | ||
protected JmsEndpoint resolveMandatoryEndpoint(String uri) { | ||
Endpoint endpoint = super.resolveMandatoryEndpoint(uri); | ||
return assertIsInstanceOf(JmsEndpoint.class, endpoint); | ||
} | ||
} |
Oops, something went wrong.