Back to Blogs
Back to Blogs
Announcing Ballerina Swan Lake Update 8 (2201.8.0)
Ballerina Team
22 September 2023
We are excited to announce the Ballerina Swan Lake Update 8 (2201.8.0) release, which adds many new features and improvements to the language, library, runtime, and tooling of Ballerina as described below.
Java 17 support
The Java 11 Long term Support (LTS) active support will end in September 2023. Therefore, the jBallerina runtime is now upgraded to support Java 17 LTS, which is the latest long-term support release of the Java SE platform.
You will not have an impact on the Java version upgrade except for the following.
-
If you are specifically using Java 11 to run Ballerina programs, you would have to switch to Java 17.
-
The Ballerina interoperability implementation will have an impact on Java 17 support due to any incompatible changes. As an example, Java 17 will have some restrictions on using Java reflections with internal Java packages.
-
Ballerina Update 8 Docker images will run on Java 17 JRE.
For more information, see the Java 17 release notes.
Custom package repositories support
With the Swan Lake Update 8 release, now, you can seamlessly integrate Maven repositories into the package build. This feature empowers you to publish and retrieve packages from multiple Maven repositories in addition to the Ballerina Central repository.
The steps below show an example of how you can publish a package to Github packages and retrieve it.
-
Configure the repository in the
<USER_HOME>/.ballerina/Settings.toml
file.[[repository.maven]] id = "myGitRepo" # This id is used when pushing/ pulling balas url = "https://maven.pkg.github.com/azinneera/ballerina-release" username = "<github_username>" accesstoken = "<github_accesstoken>"
-
Execute the command below to publish the package.
$ bal push --repository myGitRepo
-
Specify the dependency in the
Ballerina.toml
file to retrieve the package.[[dependency]] org = “john” name = “email” version = “0.1.0” repository = “myGitRepo”
For more information, see Use custom repositories for package management.
The bal tool
and bal profile
commands
This release introduces two new commands to the collection of Ballerina CLI commands.
The bal tool
command
The Ballerina Swan Lake distribution includes a set of bundled CLI commands for efficiently managing Ballerina source code. Additionally, Ballerina offers a collection of tools, which are CLI command implementations not bundled with the distribution but can be easily obtained from Ballerina Central and seamlessly managed using the bal tool
command.
The bal tool
command allows you to pull, remove, update, search tools, and switch between tool versions. Once pulled, these tools will behave as first-class commands.
For example, execute the command below to pull and install the Health tool.
$ bal tool pull health
For more information, see Tool commands.
The bal profile
command
The bal profile
command runs a Ballerina package, profiles it, and generates a flame graph, which shows the function call stack and the execution times of each function call. It provides the ability to find the performance bottlenecks of a Ballerina application.
An example flame graph generated by the Ballerina Profiler is shown below.
For more information, see Ballerina Profiler.
The mqtt
and java.jms
packages
This release brings two new additions to the Ballerina Library to improve the provision of messaging-related functionalities.
The mqtt
package
MQTT is a lightweight, publish-subscribe messaging protocol that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth. It is an open standard protocol that is supported by a wide variety of devices and platforms. Ballerina MQTT supports MQTTv5 with request/response, will message, and many more features.
Below is an example usage of the mqtt
package.
import ballerina/mqtt; mqtt:ClientConfiguration clientConfiguration = { connectionConfig: { username: "ballerina", password: "ballerinamqtt" } }; mqtt:Client mqttClient = check new (mqtt:DEFAULT_URL, "publisher-client-1", clientConfiguration); check mqttClient->publish("mqtt/test", {payload: "This is Ballerina MQTT client!!!".toBytes()});
For more information, see ballerina/mqtt
.
The java.jms
package
Java Message Service (JMS) is a Java-based API that provides a standardized way for applications to create, send, receive, and consume messages in a loosely coupled, reliable, and asynchronous manner. JMS is part of the Java EE (Enterprise Edition) specification and is commonly used for building distributed, decoupled, and scalable applications that need to exchange information or events between different components.
Below is an example usage of the java.jms
package.
import ballerina/log; import ballerinax/java.jms; import ballerinax/activemq.driver as _; jms:Connection connection = check new ( initialContextFactory = "org.apache.activemq.jndi.ActiveMQInitialContextFactory", providerUrl = "tcp://localhost:61616" ); jms:Session session = checkconnection->createSession(); // sending messages using JMS message producer jms:MessageProducer producer = check session.createProducer({ 'type: jms:QUEUE, name: "MyQueue" }); jms:TextMessage msg = { content: "Hello Ballerina!" }; check producer->send(msg); // consuming messages using JMS message consumer jms:MessageConsumer consumer = check session.createConsumer( destination = { 'type: jms:QUEUE, name: "MyQueue" } ); while true { jms: Message ? response = checkconsumer->receive(3000); if response is jms:TextMessage { log:printInfo ("Message received: " , content =response.toString()); } }
For more information, see ballerinax/java.jms
.
The graphql.dataloader
submodule
The Ballerina graphql
package provides the capability to batch and cache data fetched from data sources using the graphql.dataloader
submodule. This DataLoader feature helps to effectively solve the N+1 problem that commonly occurs in GraphQL services.
For an example of the usage of the graphql.dataloader
submodule, see the release note.
For more information, see the DataLoader specification.
Furthermore, this release brings a range of notable additions and improvements to the language, runtime, Ballerina library, and developer tools. For a comprehensive overview of all the new features and improvements brought by Swan Lake Update 8, see the release note.
We encourage our community to explore these features and provide feedback. Your input is invaluable in shaping the future of Ballerina and ensuring it meets your needs.
Cheers to the Ballerina community and the bright future of it!