Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP61 and EE10 update #143

Merged
merged 64 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
e32e1c8
modified dependencies in all poms
saumyapandyaa Oct 31, 2023
5bde066
applied gm candidate build
saumyapandyaa Oct 31, 2023
a93e3fd
modified classes to use jakarta ee, test containers, created client i…
saumyapandyaa Nov 3, 2023
42ad618
updating github- error setting jersey client
Nov 6, 2023
25b134b
integration test editted
Nov 7, 2023
1f657aa
code review
Nov 10, 2023
cfcaf66
pushing all recent changes
Nov 13, 2023
2875043
fixed query
Nov 14, 2023
b46a7df
Merge pull request #144 from OpenLiberty/temp-testing
saumyapandyaa Nov 14, 2023
8784b78
added resetSystems + removed unnecessary stuff
Nov 14, 2023
51125f9
fixed linter
Nov 14, 2023
c931e4b
fixed linter
Nov 14, 2023
ec44637
fixed linter except defaultrx
Nov 14, 2023
565c55f
updates scripts to remove zookeeper
Nov 14, 2023
b91c12c
updates scripts to remove zookeeper
Nov 14, 2023
53e59b3
fixed defaultrx linter
Nov 14, 2023
0dce99a
fixed linter + deleted appConfig from defaultrx
Nov 15, 2023
2dc8c2f
fixed brackets
Nov 15, 2023
d7a3d86
fixed brackets
Nov 15, 2023
58ed3e8
fixed brackets
Nov 15, 2023
efc50e7
updated start directory
Nov 15, 2023
180cbed
got rid of differences
Nov 15, 2023
4de5b3f
sone final changes
Nov 15, 2023
32f6ece
added imports to defaultrx>query>appContainerConfig
Nov 15, 2023
a3e17a3
removed unnecessary code form appContainerConfig
Nov 15, 2023
5d38a66
added dependency
Nov 16, 2023
5f92e41
added dependency to start
Nov 16, 2023
9aa7fbf
updated dependency
Nov 16, 2023
f4884e4
updated dependency
Nov 16, 2023
af7183c
updated dependency
Nov 16, 2023
e2df72b
deleted IT file from start
Nov 16, 2023
f9a20bb
removed extra spaces
Nov 16, 2023
acccd77
removed extra spaces
Nov 16, 2023
c20436e
added missing tag in pom file
Nov 16, 2023
6b9a3ff
removed print statements
Nov 16, 2023
537fc43
removed extra imports
Nov 16, 2023
5978011
testing dependency
Nov 16, 2023
348e935
final changes
Nov 16, 2023
9b5d301
readme review + linter
Nov 16, 2023
f10cfea
reverted daily build
Nov 16, 2023
8886eff
extra linter errors
Nov 16, 2023
0afbee0
Merge branch 'staging' into mp6-ee10-update
gkwan-ibm Nov 22, 2023
8d1cbac
default.http.port -> http.port
Nov 23, 2023
fd3f47d
Merge branch 'staging' into mp6-ee10-update
Ruilin-Ma Jan 19, 2024
60bf1ca
dependencies, index.xml, and devc update
Ruilin-Ma Jan 19, 2024
c170172
IT files devc update
Ruilin-Ma Jan 19, 2024
b1d68fe
query service health check update
Ruilin-Ma Jan 19, 2024
8915e80
correct typo
Ruilin-Ma Jan 22, 2024
77260cf
removed zookeeper instances
Ruilin-Ma Jan 22, 2024
cab2f90
update versions
gkwan-ibm Mar 25, 2024
b84526c
start kafka first
gkwan-ibm Mar 25, 2024
1ff6f44
remove unnecessary file
gkwan-ibm Mar 25, 2024
4f07371
remove tailing spaces
gkwan-ibm Mar 25, 2024
1ce0a58
fix linter check
gkwan-ibm Mar 25, 2024
c83b9c9
wait log message instead of healt
gkwan-ibm Mar 26, 2024
4c10afb
fix dependency error
Ruilin-Ma Mar 26, 2024
6d8f8e8
fix test failure
gkwan-ibm Mar 27, 2024
859c3b5
update the query pom.xml at the start
gkwan-ibm Mar 27, 2024
a6fe330
clean spaces
gkwan-ibm Mar 27, 2024
34bf693
clean spaces
gkwan-ibm Mar 27, 2024
974c0e4
fix hotspot file
gkwan-ibm Mar 27, 2024
fecd9bc
disable RYUK
gkwan-ibm Mar 27, 2024
edeed0e
add ryuk doc link
gkwan-ibm Mar 27, 2024
09af53b
Update README.adoc
gkwan-ibm Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020, 2023 IBM Corporation and others.
// Copyright (c) 2020, 2024 IBM Corporation and others.
// Licensed under Creative Commons Attribution-NoDerivatives
// 4.0 International (CC BY-ND 4.0)
// https://creativecommons.org/licenses/by-nd/4.0/
Expand All @@ -9,13 +9,14 @@
:page-layout: guide-multipane
:page-duration: 25 minutes
:page-releasedate: 2020-08-27
:page-majorupdateddate: 2024-04-30
:page-guide-category: microprofile
:page-essential: false
:page-description: Learn how to use a reactive JAX-RS client to asynchronously invoke RESTful microservices over HTTP.
:page-seo-title: Consuming RESTful Java microservices asynchronously using the reactive JAX-RS client
:page-seo-description: A getting started tutorial and an example on how to consume RESTful Java microservices asynchronously using reactive Java API for RESTful Web Services (JAX-RS) client with Eclipse Jersey/RxJava reactive client library.
:guide-author: Open Liberty
:page-tags: ['MicroProfile', 'Jakarta EE']
:page-tags: ['microprofile', 'jakarta-ee']
:page-permalink: /guides/{projectid}
:page-related-guides: ['microprofile-reactive-messaging', 'microprofile-rest-client-async']
:common-includes: https://raw.githubusercontent.com/OpenLiberty/guides-common/prod
Expand Down Expand Up @@ -130,7 +131,7 @@ docker build -t inventory:1.0-SNAPSHOT inventory/.
docker build -t query:1.0-SNAPSHOT query/.
```

Next, use the provided script to start the application in Docker containers. The script creates a network for the containers to communicate with each other. It creates containers for Kafka, Zookeeper, and all of the microservices in the project.
Next, use the provided script to start the application in Docker containers. The script creates a network for the containers to communicate with each other. It creates containers for Kafka and all of the microservices in the project.

include::{common-includes}/os-tabs.adoc[]

Expand Down Expand Up @@ -229,7 +230,9 @@ InventoryClient.java
include::finish/query/src/main/java/io/openliberty/guides/query/client/InventoryClient.java[]
----

The return type of the [hotspot=getSystem file=1]`getSystem()` method is now an `Observable` object instead of a `CompletionStage` interface. http://reactivex.io/RxJava/javadoc/io/reactivex/Observable.html[Observable^] is a collection of data that waits to be subscribed to before it can release any data and is part of RxJava. The [hotspot=rx file=1]`rx()` method now needs to contain `RxObservableInvoker.class` as an argument. This argument calls the specific invoker, `RxObservableInvoker`, for the `Observable` class that's provided by Jersey. In the [hotspot=getSystem file=1]`getSystem()` method,the [hotspot=register file=1]`register(RxObservableInvokerProvider)` method call registers the `RxObservableInvoker` class,which means that the client can recognize the invoker provider.
The return type of the [hotspot=getSystem file=1]`getSystem()` method is now an `Observable` object instead of a `CompletionStage` interface. http://reactivex.io/RxJava/javadoc/io/reactivex/Observable.html[Observable^] is a collection of data that waits to be subscribed to before it can release any data and is part of RxJava. The [hotspot=rx file=1]`rx()` method now needs to contain `RxObservableInvoker.class` as an argument. This argument calls the specific invoker, `RxObservableInvoker`, for the `Observable` class that's provided by Jersey.

In the [hotspot=getSystem file=1]`getSystem()` method, the [hotspot=register file=1]`register(RxObservableInvokerProvider)` method call registers the `RxObservableInvoker` class,which means that the client can recognize the invoker provider.

In some scenarios, a producer might generate more data than the consumers can handle. JAX-RS can deal with cases like these by using the RxJava `Flowable` class with backpressure. To learn more about RxJava and backpressure, see https://openliberty.io/blog/2019/04/10/jaxrs-reactive-extensions.html[JAX-RS reactive extensions with RxJava backpressure^].

Expand Down Expand Up @@ -370,12 +373,29 @@ The [hotspot=testSystemLoad file=0]`testSystemLoad()` test case verifies that th

Navigate to the `query` directory, then verify that the tests pass by running the Maven `verify` goal:

include::{common-includes}/os-tabs.adoc[]

[.tab_content.windows_section]
--
[role='command']
```
cd query
mvn verify
```
--

[.tab_content.mac_section.linux_section]
--
[role='command']
```
export TESTCONTAINERS_RYUK_DISABLED=true
cd query
mvn verify
```

For more information about disabling Ryuk, see the https://java.testcontainers.org/features/configuration/#disabling-ryuk[Testcontainers custom configuration^] document.
--

When the tests succeed, you see output similar to the following example:

[source, role='no_copy']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2020 IBM Corporation and others.
* Copyright (c) 2020, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* IBM Corporation - Initial implementation
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.query;

// JAX-RS
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

// tag::path1[]
@ApplicationPath("/")
// end::path1[]
public class QueryApplication extends Application {

}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2020 IBM Corporation and others.
* Copyright (c) 2020, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* IBM Corporation - Initial implementation
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.query;
Expand All @@ -20,19 +19,19 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import io.openliberty.guides.query.client.InventoryClient;

@ApplicationScoped
@Path("/query")
public class QueryResource {

@Inject
private InventoryClient inventoryClient;

Expand Down Expand Up @@ -92,7 +91,7 @@ private class Holder {
private volatile Map<String, Properties> values;
// end::volatile[]

public Holder() {
Holder() {
// tag::concurrentHashMap[]
this.values = new ConcurrentHashMap<String, Properties>();
// end::concurrentHashMap[]
Expand Down Expand Up @@ -122,8 +121,10 @@ private void init() {
this.values.put("lowest", new Properties());
this.values.get("highest").put("hostname", "temp_max");
this.values.get("lowest").put("hostname", "temp_min");
this.values.get("highest").put("systemLoad", new BigDecimal(Double.MIN_VALUE));
this.values.get("lowest").put("systemLoad", new BigDecimal(Double.MAX_VALUE));
this.values.get("highest")
.put("systemLoad", new BigDecimal(Double.MIN_VALUE));
this.values.get("lowest")
.put("systemLoad", new BigDecimal(Double.MAX_VALUE));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2020 IBM Corporation and others.
* Copyright (c) 2020, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* IBM Corporation - Initial implementation
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.query.client;
Expand All @@ -16,14 +15,13 @@
import java.util.Properties;
import java.util.concurrent.CompletionStage;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.HttpHeaders;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.HttpHeaders;
import org.eclipse.microprofile.config.inject.ConfigProperty;

@RequestScoped
Expand All @@ -33,13 +31,15 @@ public class InventoryClient {
@ConfigProperty(name = "INVENTORY_BASE_URI", defaultValue = "http://localhost:9085")
private String baseUri;


public List<String> getSystems() {
return ClientBuilder.newClient()
.target(baseUri)
.path("/inventory/systems")
.request()
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.get(new GenericType<List<String>>(){});
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_JSON)
.get(new GenericType<List<String>>() { });
}

// tag::getSystem[]
Expand All @@ -49,11 +49,12 @@ public CompletionStage<Properties> getSystem(String hostname) {
.path("/inventory/systems")
.path(hostname)
.request()
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_JSON)
// tag::rx[]
.rx()
// end::rx[]
.get(Properties.class);
}
// end::getSystem[]
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2020 IBM Corporation and others.
* Copyright (c) 2020, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* IBM Corporation - Initial implementation
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.query.health;

import javax.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.ApplicationScoped;

import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Liveness;

@Liveness
@ApplicationScoped
@Liveness
public class QueryLivenessCheck implements HealthCheck {

private boolean isAlive() {
Expand All @@ -29,6 +28,7 @@ private boolean isAlive() {
@Override
public HealthCheckResponse call() {
boolean up = isAlive();
return HealthCheckResponse.named(this.getClass().getSimpleName()).state(up).build();
return HealthCheckResponse
.named(this.getClass().getSimpleName()).state(up).build();
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2020 IBM Corporation and others.
* Copyright (c) 2020, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* IBM Corporation - Initial implementation
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.query.health;

import javax.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.ApplicationScoped;

import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
Expand All @@ -29,6 +28,7 @@ private boolean isAlive() {
@Override
public HealthCheckResponse call() {
boolean up = isAlive();
return HealthCheckResponse.named(this.getClass().getSimpleName()).state(up).build();
return HealthCheckResponse
.named(this.getClass().getSimpleName()).state(up).build();
}
}
4 changes: 2 additions & 2 deletions defaultrx/query/src/main/liberty/config/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<feature>mpRestClient-1.3</feature>
</featureManager>

<variable name="default.http.port" defaultValue="9080"/>
<variable name="http.port" defaultValue="9080"/>
<variable name="default.https.port" defaultValue="9443"/>

<httpEndpoint host="*" httpPort="${default.http.port}"
<httpEndpoint host="*" httpPort="${http.port}"
httpsPort="${default.https.port}" id="defaultHttpEndpoint"/>

<webApplication location="query.war" contextRoot="/"/>
Expand Down
2 changes: 1 addition & 1 deletion defaultrx/query/src/main/webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2016, 2020 IBM Corp.
Copyright (c) 2020, 2024 IBM Corp.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading
Loading