Skip to content

AMQ Broker (Artemis) and AMQ Streams (Kafka) Demo

Notifications You must be signed in to change notification settings

luszczynski/amq-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AMQ Broker/AMQ Streams Demo

Demo showing Kafka and Artemis on top of OpenShift.

3 8 2021 11 42 55 AM

Pre-req

For this demonstration, we will need:

  • OpenShift 4.8.x

AMQ Broker Demo (Artemis)

Creating AMQ Broker project

3 8 2021 10 39 05 AM
3 8 2021 10 40 04 AM

Deploying AMQ Broker Operator

3 8 2021 10 41 59 AM
3 8 2021 10 42 30 AM
3 8 2021 10 43 05 AM
3 8 2021 10 43 33 AM

Switch to developer console

3 8 2021 10 50 15 AM

We should see the container Operator

3 8 2021 10 51 07 AM

Deploying AMQ Broker

3 8 2021 10 53 25 AM
3 8 2021 10 53 50 AM
3 8 2021 10 54 09 AM
3 8 2021 11 01 15 AM
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
3 8 2021 11 06 46 AM

Deploying producer and consumer

Producer

Right click on topology page

3 8 2021 11 16 37 AM
3 8 2021 11 19 02 AM
3 8 2021 11 19 54 AM
3 8 2021 11 28 50 AM

We can check the logs to see if the producer app is working properly.

3 8 2021 11 31 09 AM
3 8 2021 11 32 16 AM

Consumer

Right click on topology page

3 8 2021 11 16 37 AM
3 8 2021 11 34 29 AM
3 8 2021 11 36 03 AM
3 8 2021 11 41 19 AM

We can check the logs to see if the consumer app is working properly.

3 8 2021 11 43 33 AM
3 8 2021 11 51 26 AM

Camel K Demo

Deploying Camel K Operator

3 8 2021 11 52 54 AM
3 8 2021 12 05 52 PM
3 8 2021 12 06 23 PM
3 8 2021 12 08 47 PM

Deploying Camel K integration

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.

3 8 2021 12 13 52 PM

Now we should see the logging of our camel route.

3 8 2021 12 20 04 PM
3 8 2021 12 24 10 PM

AMQ Streams Demo (Kafka)

kubectl -n amq-streams-demo run kafka-producer-topic1 -it --image=quay.io/strimzi/kafka:0.25.0-kafka-2.7.0 --rm=true --restart=Never — bin/kafka-console-producer.sh --broker-list my-cluster-kafka-bootstrap.amq-streams-demo.svc:9092 --topic my-topic