Just like @Robbie Gemmell pointed out in the comments.
One ConnectionFactory takes the required argument's broker URL. Then for the other ConnectionFactory we can directly instantiate it. Like so:
application.properties
# Configures the Artemis properties.
quarkus.artemis.url=tcp://localhost:61616
quarkus.artemis.username=admin
quarkus.artemis.password=admin
# Broker URL for the second ConnectionFactory
brokerURLService=tcp://remote-service:61616
CamelConfiguration
@ApplicationScoped
public class CamelConfigurationz {
@Value("${brokerURLService}")
private String brokerURLService;
@Named
public Sjms2Component sjms2(ConnectionFactory connectionFactory) {
Sjms2Component sjms2 = new Sjms2Component();
sjms2.setConnectionFactory(connectionFactory);
return sjms2;
}
@Named
public Sjms2Component sjms2Service(ConnectionFactory amqJmsServiceFactory) {
Sjms2Component sjms2Service = new Sjms2Component();
sjms2Service.setConnectionFactory(amqJmsServiceFactory);
return sjms2Service;
}
@Named
public ActiveMQJMSConnectionFactory amqJmsServiceFactory() throws JMSException {
ActiveMQJMSConnectionFactory amqJmsServiceFactory = new ActiveMQJMSConnectionFactory();
amqJmsServiceFactory.setBrokerURL(brokerURLService);
return amqJmsServiceFactory;
}
}
Routes
public class CamelRoutes extends EndpointRouteBuilder {
@Override
public void configure() throws Exception {
from(sjms2("inquarkus"))
.log("got activemq message ---------------------------------")
.to(sjms2("outquarkus"));
from(sjms2("sjms2Service", "inquarkusService"))
.log("got activemq message service ---------------------------------")
.to(sjms2("sjms2Service", "outquarkusService"));
}
}
It can be done differently thus note that I am using spring di extension as well in the example above to use @Value. Also camel-quarkus-endpointdsl to use EndpointRouteBuilder.