Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
name: js-java-async-helidon
name: archive/js-java-async-helidon
on:
push:
paths:
- 'js-java-async-helidon/**'
- '.github/workflows/js-java-async-helidon.yml'
- 'archive/js-java-async-helidon/**'
- '.github/workflows/archive-js-java-async-helidon.yml'
pull_request:
paths:
- 'js-java-async-helidon/**'
- '.github/workflows/js-java-async-helidon.yml'
schedule:
- cron: "0 0 1 * *" # run every month
- 'archive/js-java-async-helidon/**'
- '.github/workflows/archive-js-java-async-helidon.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
run:
name: Run 'js-java-async-helidon'
name: Run 'archive/js-java-async-helidon'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand All @@ -26,9 +24,9 @@ jobs:
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
- name: Run 'js-java-async-helidon'
- name: Run 'archive/js-java-async-helidon'
run: |
cd js-java-async-helidon
cd archive/js-java-async-helidon
mvn --no-transfer-progress clean package
mvn exec:exec &
sleep 10
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ cd graalvm-demos
</tbody>
</table>

### Helidon
### Scala

<table>
<thead>
Expand All @@ -181,8 +181,8 @@ cd graalvm-demos
</thead>
<tbody>
<tr>
<td align="left" width="30%"><a href="/js-java-async-helidon/">js-java-async-helidon</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/js-java-async-helidon.yml"><img alt="js-java-async-helidon" src="https://github.com/graalvm/graalvm-demos/actions/workflows/js-java-async-helidon.yml/badge.svg" /></a></td>
<td align="left" width="70%">An HTTP web service that demonstrates how multiple JavaScript contexts can be executed in parallel to handle asynchronous operations with Helidon in Java <br><strong>Technologies: </strong>Native Image, Helidon, Native Build Tools Maven plugin <br><strong>Reference: </strong><a href="https://medium.com/graalvm/asynchronous-polyglot-programming-in-graalvm-javascript-and-java-2c62eb02acf0">Asynchronous Polyglot Programming in GraalVM Using Helidon and JavaScript</a></td>
<td align="left" width="30%"><a href="/scalac-native/">scalac-native</a></td>
<td align="left" width="70%">Demonstrates how to build a native executable of the Scala compiler. The resulting binary has no dependencies on the JDK. <br><strong>Technologies: </strong>Scala 2.12.x, Native Image <br><strong>Reference: </strong><a href="https://medium.com/graalvm/compiling-scala-faster-with-graalvm-86c5c0857fa3">Compiling Scala Faster with GraalVM</a></td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,44 @@

This is a polyglot Helidon HTTP web service that demonstrates how multiple JavaScript `Context`s can be executed in parallel to handle asynchronous operations with [Helidon](https://helidon.io/), mixing JavaScript `Promise` and Java `CompletableFuture` objects.

## Prerequisites
* [GraalVM](http://graalvm.org)

## Preparation

1. Download and install the latest GraalVM JDK using [SDKMAN!](https://sdkman.io/).
```bash
sdk install java 21.0.1-graal
sdk install java 21.0.5-graal
```

2. Download or clone the repository and navigate into the `js-java-async-helidon` directory:
```bash
git clone https://github.com/graalvm/graalvm-demos
```
```bash
cd graalvm-demos/js-java-async-helidon
cd graalvm-demos/archive/js-java-async-helidon
```

3. Build the application using Maven:
```bash
mvn clean package
```

Now you are all set to run the polyglot Helidon Web service.
Now you are all set to run the polyglot Helidon web service.

## Running the Application

You can run this Helidon HTTP web service with the following command:
You can run this Helidon application with the following command:
```bash
mvn exec:exec
```

The application will create a new HTTP web service accepting requests on port `8080`.
The application accepts requests on port `8080`.
Open [http://localhost:8080/greet?request=42](http://localhost:8080/greet?request=42) in the browser to send a request.

To demonstrate error handling, the application will not accept requests with `request` smaller than `42`.
For example, the following requests will return an error message:
```bash
curl http://localhost:8080/greet?request=41
```
```bash
curl http://localhost:8080/greet?request=foo
```

Expand All @@ -56,3 +55,5 @@ wrk -c 100 -t 10 -d 100 http://localhost:8080/greet?request=42

This is a sample application that, for brevity, contains reasonably large snippets of code inside the strings.
This is not the best approach for structuring polyglot apps, but the easiest to show in a compact way.

Read more about asynchronous programming across multiple languages in this post [Asynchronous polyglot programming with Java and JavaScript on GraalVM](https://medium.com/graalvm/asynchronous-polyglot-programming-in-graalvm-javascript-and-java-2c62eb02acf0).
File renamed without changes.
Loading