You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tobias Letschka <tl...@covernet.de> on 2019/12/04 11:15:49 UTC
Change from ApacheMQ to ArtemisMQ
Hi camel riders,
I have a question. I’m trying to change my application from apacheMQ to Artemis.
I’m already using ApacheMQ and Springboot.
At the moment I use this @Configuration. Do you know a better one?
@Configuration
public class ActiveMQ {
@Value("${artemis.username}")
String username = "admin";
@Value("${artemis.password}")
String password = "admin";
private static final String QUEUE_BASE = "activemq:";
public static final String QUEUE_IN = QUEUE_BASE + "magento.product.out.related";
private static final String TOPIC_BASE = "activemq:topic:{{activemq.queue.prefix}}.";
private static final String QUEUE_BASE_NO_TX = "activemqNoTx:{{activemq.queue.prefix}}.";
private static final String TOPIC_BASE_NO_TX = "activemqNoTx:topic:{{activemq.queue.prefix}}.";
@Bean(name = "pooledConnectionFactory")
public CachingConnectionFactory createActiveMQConnectionPool(@Value("${spring.activemq.broker.url}") String brokerURL) {
ActiveMQConnectionFactory connectionFactory = new ActiveMQJMSConnectionFactory(brokerURL, username, password);
connectionFactory.setClientID(App.class.getPackage().getName());
CachingConnectionFactory connectionPool = new CachingConnectionFactory(connectionFactory);
connectionPool.setReconnectOnException(true);
return connectionPool;
}
@Bean(name = "activemq")
public ActiveMQComponent createActiveMQComponent(@Value("${spring.activemq.broker.url}") String brokerURL) {
JmsConfiguration jmsConfiguration = new JmsConfiguration(createActiveMQConnectionPool(brokerURL));
jmsConfiguration.setConcurrentConsumers(1);
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setConfiguration(jmsConfiguration);
activeMQComponent.setTransacted(false);
return activeMQComponent;
}
}
Greetings
Tobias
Re: Change from ApacheMQ to ArtemisMQ
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
spring boot has an artemis starter you can use, and then use camel's
jms or sjms components, that should be able to plugin and use that.
https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/boot-features-messaging.html#boot-features-artemis
On Wed, Dec 4, 2019 at 12:16 PM Tobias Letschka <tl...@covernet.de> wrote:
>
> Hi camel riders,
>
> I have a question. I’m trying to change my application from apacheMQ to Artemis.
> I’m already using ApacheMQ and Springboot.
>
> At the moment I use this @Configuration. Do you know a better one?
>
> @Configuration
> public class ActiveMQ {
>
> @Value("${artemis.username}")
> String username = "admin";
>
> @Value("${artemis.password}")
> String password = "admin";
>
> private static final String QUEUE_BASE = "activemq:";
>
> public static final String QUEUE_IN = QUEUE_BASE + "magento.product.out.related";
>
> private static final String TOPIC_BASE = "activemq:topic:{{activemq.queue.prefix}}.";
>
> private static final String QUEUE_BASE_NO_TX = "activemqNoTx:{{activemq.queue.prefix}}.";
>
> private static final String TOPIC_BASE_NO_TX = "activemqNoTx:topic:{{activemq.queue.prefix}}.";
>
> @Bean(name = "pooledConnectionFactory")
> public CachingConnectionFactory createActiveMQConnectionPool(@Value("${spring.activemq.broker.url}") String brokerURL) {
>
> ActiveMQConnectionFactory connectionFactory = new ActiveMQJMSConnectionFactory(brokerURL, username, password);
> connectionFactory.setClientID(App.class.getPackage().getName());
>
> CachingConnectionFactory connectionPool = new CachingConnectionFactory(connectionFactory);
> connectionPool.setReconnectOnException(true);
>
> return connectionPool;
> }
> @Bean(name = "activemq")
> public ActiveMQComponent createActiveMQComponent(@Value("${spring.activemq.broker.url}") String brokerURL) {
>
> JmsConfiguration jmsConfiguration = new JmsConfiguration(createActiveMQConnectionPool(brokerURL));
> jmsConfiguration.setConcurrentConsumers(1);
>
> ActiveMQComponent activeMQComponent = new ActiveMQComponent();
> activeMQComponent.setConfiguration(jmsConfiguration);
> activeMQComponent.setTransacted(false);
>
> return activeMQComponent;
> }
>
> }
> Greetings
>
> Tobias
>
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: Change from ApacheMQ to ArtemisMQ
Posted by ski n <ra...@gmail.com>.
Hi Tobias,
"I’m already using ApacheMQ and Springboot"
I think you are using ActiveMQ client within a Sprint boot application. For
Artemis I suggest trying the SJMS component (
https://camel.apache.org/components/latest/sjms-component.html).
Example:
org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory cf =
null;
cf = new
org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory(url,
username, password);
cf.setConnectionTTL(-1);
cf.setReconnectAttempts(-1);
cf.setRetryInterval(1000);
cf.setRetryIntervalMultiplier(2.0);
cf.setMaxRetryInterval(3600000);
component = new SjmsComponent();
component.setConnectionFactory(cf);
context.addComponent(componentName, component);
Kind regards,
Raymond
Op wo 4 dec. 2019 om 12:16 schreef Tobias Letschka <tl...@covernet.de>:
> Hi camel riders,
>
> I have a question. I’m trying to change my application from apacheMQ to
> Artemis.
> I’m already using ApacheMQ and Springboot.
>
> At the moment I use this @Configuration. Do you know a better one?
>
> @Configuration
> public class ActiveMQ {
>
> @Value("${artemis.username}")
> String username = "admin";
>
> @Value("${artemis.password}")
> String password = "admin";
>
> private static final String QUEUE_BASE = "activemq:";
>
> public static final String QUEUE_IN = QUEUE_BASE +
> "magento.product.out.related";
>
> private static final String TOPIC_BASE =
> "activemq:topic:{{activemq.queue.prefix}}.";
>
> private static final String QUEUE_BASE_NO_TX =
> "activemqNoTx:{{activemq.queue.prefix}}.";
>
> private static final String TOPIC_BASE_NO_TX =
> "activemqNoTx:topic:{{activemq.queue.prefix}}.";
>
> @Bean(name = "pooledConnectionFactory")
> public CachingConnectionFactory
> createActiveMQConnectionPool(@Value("${spring.activemq.broker.url}") String
> brokerURL) {
>
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQJMSConnectionFactory(brokerURL, username, password);
> connectionFactory.setClientID(App.class.getPackage().getName());
>
> CachingConnectionFactory connectionPool = new
> CachingConnectionFactory(connectionFactory);
> connectionPool.setReconnectOnException(true);
>
> return connectionPool;
> }
> @Bean(name = "activemq")
> public ActiveMQComponent
> createActiveMQComponent(@Value("${spring.activemq.broker.url}") String
> brokerURL) {
>
> JmsConfiguration jmsConfiguration = new
> JmsConfiguration(createActiveMQConnectionPool(brokerURL));
> jmsConfiguration.setConcurrentConsumers(1);
>
> ActiveMQComponent activeMQComponent = new ActiveMQComponent();
> activeMQComponent.setConfiguration(jmsConfiguration);
> activeMQComponent.setTransacted(false);
>
> return activeMQComponent;
> }
>
> }
> Greetings
>
> Tobias
>
>