apiVersion: broker.amq.io/v2alpha4
kind: ActiveMQArtemis
metadata:
name: amq-broker
application: amq-broker-app
namespace: amq-broker-demo
spec:
deploymentPlan:
size: 2
persistenceEnabled: false
requireLogin: false
messageMigration: false
managementRBACEnabled: true
journalType: nio
jolokiaAgentEnabled: false
image: placeholder
acceptors:
- name: all
protocols: all
port: 61617
Create a new file AMQBrokerIntegration.java
with the following content:
// camel-k: dependency=camel-activemq
import org.apache.camel.builder.RouteBuilder;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.BindToRegistry;
public class AMQBrokerIntegration extends RouteBuilder {
@BindToRegistry
public ActiveMQConnectionFactory registerActiveMQConnectionFactory() {
System.out.println("ActiveMQ Listener: STARTING...");
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL("tcp://ex-aao-hdls-svc:61617");
connectionFactory.setUserName("admin");
connectionFactory.setPassword("redhat");
connectionFactory.setUseAsyncSend(false);
connectionFactory.setClientID("Message Topic");
connectionFactory.setConnectResponseTimeout(300);
System.out.println("ActiveMQ Listener: STARTED");
return connectionFactory;
}
@Override
public void configure() throws Exception {
from("activemq:topic:topic.prices")
.log("body = ${body}")
;
}
}
Now run it:
oc project amq-broker-demo
kamel run AMQBrokerIntegration.java --dev
We can find the link to download the kamel
command line on the top right help icon.
Now we should see the logging of our camel route.