Skip to content

Commit

Permalink
Update the client and server
Browse files Browse the repository at this point in the history
  • Loading branch information
ssorj committed Feb 22, 2024
1 parent 1fe0d6f commit 230d2b1
Show file tree
Hide file tree
Showing 12 changed files with 9,102 additions and 8,234 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ deploy the cluster and topic.
_**Private:**_

~~~ shell
kubectl create -f kafka-cluster/strimzi.yaml
kubectl apply -f kafka-cluster/cluster1.yaml
kubectl create -f server/strimzi.yaml
kubectl apply -f server/cluster1.yaml
kubectl wait --for condition=ready --timeout 900s kafka/cluster1
~~~

_Sample output:_

~~~ console
$ kubectl create -f kafka-cluster/strimzi.yaml
$ kubectl create -f server/strimzi.yaml
customresourcedefinition.apiextensions.k8s.io/kafkas.kafka.strimzi.io created
rolebinding.rbac.authorization.k8s.io/strimzi-cluster-operator-entity-operator-delegation created
clusterrolebinding.rbac.authorization.k8s.io/strimzi-cluster-operator created
Expand All @@ -178,7 +178,7 @@ customresourcedefinition.apiextensions.k8s.io/kafkaconnects.kafka.strimzi.io cre
customresourcedefinition.apiextensions.k8s.io/kafkamirrormakers.kafka.strimzi.io created
configmap/strimzi-cluster-operator created

$ kubectl apply -f kafka-cluster/cluster1.yaml
$ kubectl apply -f server/cluster1.yaml
kafka.kafka.strimzi.io/cluster1 created
kafkatopic.kafka.strimzi.io/topic1 created

Expand Down Expand Up @@ -409,8 +409,8 @@ _**Private:**_

~~~ shell
skupper delete
kubectl delete -f kafka-cluster/cluster1.yaml
kubectl delete -f kafka-cluster/strimzi.yaml
kubectl delete -f server/cluster1.yaml
kubectl delete -f server/strimzi.yaml
~~~

_**Public:**_
Expand Down
41 changes: 41 additions & 0 deletions client/.plano.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

from plano import *

image_tag = "quay.io/skupper/kafka-example-client"

@command
def build(no_cache=False):
no_cache_arg = "--no-cache" if no_cache else ""

run(f"podman build {no_cache_arg} --format docker -t {image_tag} .")

@command
def run_():
run(f"podman run --net host {image_tag}")

@command
def debug():
run(f"podman run -it --net host --entrypoint /bin/sh {image_tag}")

@command
def push():
run("podman login quay.io")
run(f"podman push {image_tag}")
35 changes: 35 additions & 0 deletions client/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

FROM docker.io/library/maven:3-eclipse-temurin-21 AS build

COPY src /root/src
COPY pom.xml /root/pom.xml

WORKDIR /root
RUN mvn package

FROM eclipse-temurin:21 AS run

RUN useradd -r fritz
USER fritz

COPY --from=build --chown=fritz:root /root/target/quarkus-app /home/fritz/quarkus-app

ENTRYPOINT ["java", "-jar", "/home/fritz/quarkus-app/quarkus-run.jar"]
22 changes: 19 additions & 3 deletions kafka-client/pom.xml → client/pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
Expand All @@ -7,10 +23,10 @@
<version>1.0.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<quarkus-plugin.version>1.13.7.Final</quarkus-plugin.version>
<quarkus-plugin.version>3.7.3</quarkus-plugin.version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.example;

import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.reactive.messaging.Channel;
import org.eclipse.microprofile.reactive.messaging.Emitter;
import org.eclipse.microprofile.reactive.messaging.Incoming;

@ApplicationScoped
@QuarkusMain
public class Client implements QuarkusApplication {
static int desired = 10;
Expand All @@ -17,6 +35,12 @@ public class Client implements QuarkusApplication {
@Channel("outgoing-messages")
Emitter<String> emitter;

@Incoming("incoming-messages")
public void receive(String message) {
System.out.println("Received " + message);
completion.countDown();
}

@Override
public int run(String... args) {
try {
Expand All @@ -42,13 +66,4 @@ public int run(String... args) {
return 1;
}
}

@ApplicationScoped
public static class Receiver {
@Incoming("incoming-messages")
public void receive(String message) {
System.out.println("Received " + message);
completion.countDown();
}
}
}
1 change: 0 additions & 1 deletion kafka-client/.gitignore

This file was deleted.

24 changes: 0 additions & 24 deletions kafka-client/.plano.py

This file was deleted.

7 changes: 0 additions & 7 deletions kafka-client/Containerfile

This file was deleted.

4 changes: 2 additions & 2 deletions kafka-cluster/cluster1.yaml → server/cluster1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: cluster1
spec:
kafka:
version: 3.4.0
version: 3.6.1
replicas: 1
listeners:
- name: plain
Expand All @@ -25,7 +25,7 @@ spec:
transaction.state.log.min.isr: 1
default.replication.factor: 1
min.insync.replicas: 1
inter.broker.protocol.version: "3.4"
inter.broker.protocol.version: "3.6"
storage:
type: ephemeral
zookeeper:
Expand Down
Loading

0 comments on commit 230d2b1

Please sign in to comment.