[
https://issues.apache.org/jira/browse/CAMEL-9589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15243885#comment-15243885
]
Fernando Matias Balieiro commented on CAMEL-9589:
-------------------------------------------------
Hello, maybe something like this?
{code:java}
import java.net.URI;
import javax.jms.ConnectionFactory;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsConfiguration;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ArtemisComponentExampleTest extends CamelTestSupport {
private static final Logger LOG =
LoggerFactory.getLogger(ArtemisComponentExampleTest.class);
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
JmsComponent component = createArtemisComponent();
camelContext.addComponent("artemis", component);
return camelContext;
}
private JmsComponent createArtemisComponent() {
JmsComponent component = new JmsComponent();
try {
ConnectionFactory factory = createFactory("localhost", 61616,
"name", "username", "passwd");
JmsConfiguration configuration = new JmsConfiguration();
configuration.setConnectionFactory(factory);
component = new JmsComponent(configuration);
} catch (Exception e) {
LOG.error("Error when creating Factory: {}.", e.getMessage(), e);
}
return component;
}
private ConnectionFactory createFactory(final String host, final Integer
port, final String name, final String username, final String password)
throws Exception {
URI uri = new URI("tcp", null, host, port, null, "httpEnabled=true",
null);
ActiveMQConnectionFactory factory =
ActiveMQJMSClient.createConnectionFactory(uri.toString(), name);
factory.setUser(username);
factory.setPassword(password);
return factory;
}
}
{code}
Regards.
> Apache Artemis example with Camel
> ---------------------------------
>
> Key: CAMEL-9589
> URL: https://issues.apache.org/jira/browse/CAMEL-9589
> Project: Camel
> Issue Type: New Feature
> Components: examples
> Reporter: Claus Ibsen
>
> We should have an example that uses Camel with ActiveMQ Artemis as the
> broker. For example we have the widget-gadget that uses regular ActiveMQ. We
> could create an example with something similar or something else.
> The idea is to show Camel as a client connecting to a remote Artemis broker.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)