Senior Lead - Solutions Engineer, WSO2
File Processing and Websockets with
Ballerina
Chanaka Fernando
File Processing with Ballerina
• File-based data transfers are here to stay
• Cloud and on premise
• Extract, Transform, Load (ETL) requirements
• Different file formats
• Streaming large files
• Securely transfer files
File based data sharing
• File I/O as part of the Ballerina I/O
• Fine grained file access (Bytes, Characters)
• Coarse grained file access (Records)
• Large file transfer through streaming
• Connect with remote file systems (FTP,
SFTP, SMB, etc..)
File Processing with Ballerina
• Open
• List
• Create directory
• Copy
• Move
• Create new file
• Delete
Ballerina File API - Operations
function main (string[] args) {
file:File target = {path:"/tmp/result.txt"};
target.open(file:W);
boolean b = target.exists();
println("file exists: " + b);
file:File source = {path:"/tmp/result.txt"};
file:File destination = {path:"/tmp/copy.txt"};
file:copy(source, destination);
println("file copied: /tmp/result.txt to /tmp/copy.txt");
destination.delete();
println("file deleted: /tmp/copy.txt");
destination = {path:"/tmp/move.txt"};
file:move(source, destination);
}
Ballerina File API - Example
Open
Exists
Copy
Delete
Move
Ballerina I/O API
I/O APIs
Record I/O
RecordsCharacters
Bytes
I/O Channels: Files, Sockets, Devices, ….
BytesI/O
CharactersI/O
Console
I/O
DataI/O
Different record formats
• Read byte by byte
• Character by character
• Record by record
• Canonical byte representation
• Console I/O, Data I/O (Future)
Ballerina I/O API - Files
Read Characters From File
Read a Record From File
• Support connecting with remote file systems
over FTP/SMB/SFTP (in-development)
• Secure file transfer through encryption
Future Improvements
Websockets with Ballerina
• Modern applications (especially web)
consumes large amount of data in real time
• Request-Response pattern no longer
sufficient
• HTTP (1.1 and prior) lives with hacks (AJAX
long polling, Streaming, etc.)
Why Websockets?
• Long-lived connections
• Bi-directional messaging (full-duplex)
• Low usage of headers (save bandwidth)
• Co-exists with HTTP
With Websockets
• Support for different frame types (text, binary,
ping, pong)
• Sub protocol support
• SSL support
• Live alongside HTTP
Websockets in Ballerina
• Expose ballerina service through websockets
• Executes different logic based on message
type (text, binary, ping, pong)
• Can configure base path and port which is
exposing
Websockets Server connector
Websockets Server Connector
Websockets service definition
Client initiates a connection
Client connected
Text frame received
Connection closed
Service configuration
Websockets Client Connector
• Creates a connection with a websocket service
• Supports sub protocols
• Text, Binary, Ping, Pong message types
• Supports security
• Visit Ballerina website
https://ballerinalang.org/
• Start with examples
https://ballerinalang.org/docs/by-example/
• Contribute
https://github.com/ballerinalang
Download and getting started
19
wso2.com

More Related Content

PDF
[WSO2Con EU 2017] Ballerina: Exploring Data Integration
PDF
[WSO2Con EU 2017] Introduction to Ballerina
PDF
[WSO2Con EU 2017] Manipulating XML, JSON and SQL Data Types with Ballerina
PPTX
10 domino integration
PDF
Introduction to Restful Web Services
PDF
[WSO2Con EU 2017] Exploring Ballerina Toolset
PPTX
Drop acid
PDF
Linux Hosting Training Course [Level 1] - Lec 7
[WSO2Con EU 2017] Ballerina: Exploring Data Integration
[WSO2Con EU 2017] Introduction to Ballerina
[WSO2Con EU 2017] Manipulating XML, JSON and SQL Data Types with Ballerina
10 domino integration
Introduction to Restful Web Services
[WSO2Con EU 2017] Exploring Ballerina Toolset
Drop acid
Linux Hosting Training Course [Level 1] - Lec 7

What's hot (17)

PPTX
Ntg web services
PDF
LSC@LDAPCon 2011
PPT
Zing Database – Distributed Key-Value Database
PDF
Couchbase@live person meetup july 22nd
PPTX
Languages and tools for web programming
PDF
Why we love ArangoDB. The hunt for the right NosQL Database
PDF
Ballerina- A programming language for the networked world
KEY
Designing a RESTful web service
PDF
Membase Intro from Membase Meetup San Francisco
PPTX
Using database object relational storage
PDF
Couchdb + Membase = Couchbase
PPTX
Introduction to Apache HBase
PPTX
SSIS: Flow tasks, containers and precedence constraints
PPTX
Web services
PDF
Tutorial: Leveraging Globus in your Research Applications
PPTX
Building Ext JS Using HATEOAS - Jeff Stano
Ntg web services
LSC@LDAPCon 2011
Zing Database – Distributed Key-Value Database
Couchbase@live person meetup july 22nd
Languages and tools for web programming
Why we love ArangoDB. The hunt for the right NosQL Database
Ballerina- A programming language for the networked world
Designing a RESTful web service
Membase Intro from Membase Meetup San Francisco
Using database object relational storage
Couchdb + Membase = Couchbase
Introduction to Apache HBase
SSIS: Flow tasks, containers and precedence constraints
Web services
Tutorial: Leveraging Globus in your Research Applications
Building Ext JS Using HATEOAS - Jeff Stano
Ad

Viewers also liked (20)

PDF
[WSO2Con EU 2017] WSO2 Integration Cloud: End-to-End Demonstration Including ...
PDF
[WSO2Con EU 2017] Fraud Prevention and Compliance in Financial Sector with WS...
PDF
[WSO2Con EU 2017] WSO2 Unleashed: Full Stack Automation, Pitfalls and Solutions
PDF
[WSO2Con EU 2017] Container-native Architecture
PDF
[WSO2Con EU 2017] Microservices for Enterprises
PDF
[WSO2Con EU 2017] Keynote: Mobile Identity in the Digital Economy
PDF
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
PDF
[WSO2Con EU 2017] Digital Architecture: A Reference Architecture for a Digita...
PDF
[WSO2Con EU 2017] Darwin Ate My App
PDF
[WSO2Con EU 2017] Cloud-Native API Management
PDF
[WSO2Con EU 2017] Jump to the Next Curve with DevOps
PDF
[WSO2Con EU 2017] Extending Your Enterprise Integration Patterns Beyond ESBs
PDF
[WSO2Con EU 2017] How to Learn and Contribute to Ballerina
PDF
[WSO2Con EU 2017] From the Trenches: IoT Customer Stories
PDF
[WSO2Con EU 2017] Integration Platform Strategy for Digital Transformation
PDF
[WSO2Con EU 2017] Transforming the Way We Deliver Operational Technology
PDF
[WSO2Con EU 2017] Building Smarter Cities: Examples from Deployments Across t...
PDF
[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...
PDF
[WSO2Con EU 2017] Creating Composite Services Using Ballerina
PDF
[WSO2Con EU 2017] How API Management at Suva is Helping in Reducing Costs to ...
[WSO2Con EU 2017] WSO2 Integration Cloud: End-to-End Demonstration Including ...
[WSO2Con EU 2017] Fraud Prevention and Compliance in Financial Sector with WS...
[WSO2Con EU 2017] WSO2 Unleashed: Full Stack Automation, Pitfalls and Solutions
[WSO2Con EU 2017] Container-native Architecture
[WSO2Con EU 2017] Microservices for Enterprises
[WSO2Con EU 2017] Keynote: Mobile Identity in the Digital Economy
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
[WSO2Con EU 2017] Digital Architecture: A Reference Architecture for a Digita...
[WSO2Con EU 2017] Darwin Ate My App
[WSO2Con EU 2017] Cloud-Native API Management
[WSO2Con EU 2017] Jump to the Next Curve with DevOps
[WSO2Con EU 2017] Extending Your Enterprise Integration Patterns Beyond ESBs
[WSO2Con EU 2017] How to Learn and Contribute to Ballerina
[WSO2Con EU 2017] From the Trenches: IoT Customer Stories
[WSO2Con EU 2017] Integration Platform Strategy for Digital Transformation
[WSO2Con EU 2017] Transforming the Way We Deliver Operational Technology
[WSO2Con EU 2017] Building Smarter Cities: Examples from Deployments Across t...
[WSO2Con EU 2017] Continuous Integration, Delivery and Deployment: Accelerate...
[WSO2Con EU 2017] Creating Composite Services Using Ballerina
[WSO2Con EU 2017] How API Management at Suva is Helping in Reducing Costs to ...
Ad

Similar to [WSO2Con EU 2017] File Processing and Websockets with Ballerina (20)

PDF
[ApacheCon NA 2019] Conquering Network Distributed Applications Using the Bal...
PDF
[Cloud-Native and Kubernetes Meetup in Silicon Valley] Ballerina - Cloud Nati...
PDF
Ballerina - Cloud Native Programming Language
PDF
[ApacheCon NA 2019] Re-inventing Middleware in a Programming Language
PDF
Effective microservices development with ballerina
PDF
[WSO2 Integration Summit Bern 2019] Ballerina — Cloud-native Middleware as a ...
PDF
[WSO2 Integration Summit San Francisco 2019] Ballerina - Cloud Native Middlew...
PDF
Ballerina cloud native middleware as a programming language | Yenlo - WSO2 In...
PDF
[WSO2Con EU 2017] Keynote: Ballerina Plans and Futures
PDF
[DeveloperWeek 2020] Conquering Network Distributed Applications Using Ballerina
PDF
Ballerina – An Open-Source, Cloud-Native Programming Language for Microservices
PDF
Integration Microservices
PDF
[Java Colombo Meetup] The better java for Java microservices developers
PDF
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
PDF
WebSockets wiith Scala and Play! Framework
PDF
[WSO2 Integration Summit New York 2019] Ballerina - Cloud Native Middleware a...
PDF
Ballerina: Cloud Native Programming Language
PDF
Serverless Ballerina
PDF
Ballerina- A programming language for the networked world
PDF
Ballerina connectors for seamless integration
[ApacheCon NA 2019] Conquering Network Distributed Applications Using the Bal...
[Cloud-Native and Kubernetes Meetup in Silicon Valley] Ballerina - Cloud Nati...
Ballerina - Cloud Native Programming Language
[ApacheCon NA 2019] Re-inventing Middleware in a Programming Language
Effective microservices development with ballerina
[WSO2 Integration Summit Bern 2019] Ballerina — Cloud-native Middleware as a ...
[WSO2 Integration Summit San Francisco 2019] Ballerina - Cloud Native Middlew...
Ballerina cloud native middleware as a programming language | Yenlo - WSO2 In...
[WSO2Con EU 2017] Keynote: Ballerina Plans and Futures
[DeveloperWeek 2020] Conquering Network Distributed Applications Using Ballerina
Ballerina – An Open-Source, Cloud-Native Programming Language for Microservices
Integration Microservices
[Java Colombo Meetup] The better java for Java microservices developers
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WebSockets wiith Scala and Play! Framework
[WSO2 Integration Summit New York 2019] Ballerina - Cloud Native Middleware a...
Ballerina: Cloud Native Programming Language
Serverless Ballerina
Ballerina- A programming language for the networked world
Ballerina connectors for seamless integration

More from WSO2 (20)

PDF
Demystifying CMS-0057-F - Compliance Made Seamless with WSO2
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
PDF
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
PDF
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
PDF
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
PDF
Platformless Modernization with Choreo.pdf
PDF
Application Modernization with Choreo for the BFSI Sector
PDF
Choreo - The AI-Native Internal Developer Platform as a Service: Overview
PDF
[Roundtable] Choreo - The AI-Native Internal Developer Platform as a Service
PPTX
WSO2Con 2025 - Building AI Applications in the Enterprise (Part 1)
PPTX
WSO2Con 2025 - Building Secure Business Customer and Partner Experience (B2B)...
PPTX
WSO2Con 2025 - Building Secure Customer Experience Apps
PPTX
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
PPTX
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
PPTX
WSO2Con 2025 - Unified Management of Ingress and Egress Across Multiple API G...
PPTX
WSO2Con 2025 - How an Internal Developer Platform Lets Developers Focus on Code
PPTX
WSO2Con 2025 - Architecting Cloud-Native Applications
PDF
Mastering Intelligent Digital Experiences with Platformless Modernization
PDF
Accelerate Enterprise Software Engineering with Platformless
PDF
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
Demystifying CMS-0057-F - Compliance Made Seamless with WSO2
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Platformless Modernization with Choreo.pdf
Application Modernization with Choreo for the BFSI Sector
Choreo - The AI-Native Internal Developer Platform as a Service: Overview
[Roundtable] Choreo - The AI-Native Internal Developer Platform as a Service
WSO2Con 2025 - Building AI Applications in the Enterprise (Part 1)
WSO2Con 2025 - Building Secure Business Customer and Partner Experience (B2B)...
WSO2Con 2025 - Building Secure Customer Experience Apps
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
WSO2Con 2025 - Unified Management of Ingress and Egress Across Multiple API G...
WSO2Con 2025 - How an Internal Developer Platform Lets Developers Focus on Code
WSO2Con 2025 - Architecting Cloud-Native Applications
Mastering Intelligent Digital Experiences with Platformless Modernization
Accelerate Enterprise Software Engineering with Platformless
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation

Recently uploaded (20)

PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Hybrid model detection and classification of lung cancer
PDF
Architecture types and enterprise applications.pdf
PPT
What is a Computer? Input Devices /output devices
PDF
Unlock new opportunities with location data.pdf
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Getting Started with Data Integration: FME Form 101
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Hindi spoken digit analysis for native and non-native speakers
Taming the Chaos: How to Turn Unstructured Data into Decisions
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Benefits of Physical activity for teenagers.pptx
Hybrid model detection and classification of lung cancer
Architecture types and enterprise applications.pdf
What is a Computer? Input Devices /output devices
Unlock new opportunities with location data.pdf
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
O2C Customer Invoices to Receipt V15A.pptx
Web Crawler for Trend Tracking Gen Z Insights.pptx
A review of recent deep learning applications in wood surface defect identifi...
A comparative study of natural language inference in Swahili using monolingua...
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
DP Operators-handbook-extract for the Mautical Institute
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Module 1.ppt Iot fundamentals and Architecture
Getting Started with Data Integration: FME Form 101

[WSO2Con EU 2017] File Processing and Websockets with Ballerina

  • 1. Senior Lead - Solutions Engineer, WSO2 File Processing and Websockets with Ballerina Chanaka Fernando
  • 3. • File-based data transfers are here to stay • Cloud and on premise • Extract, Transform, Load (ETL) requirements • Different file formats • Streaming large files • Securely transfer files File based data sharing
  • 4. • File I/O as part of the Ballerina I/O • Fine grained file access (Bytes, Characters) • Coarse grained file access (Records) • Large file transfer through streaming • Connect with remote file systems (FTP, SFTP, SMB, etc..) File Processing with Ballerina
  • 5. • Open • List • Create directory • Copy • Move • Create new file • Delete Ballerina File API - Operations
  • 6. function main (string[] args) { file:File target = {path:"/tmp/result.txt"}; target.open(file:W); boolean b = target.exists(); println("file exists: " + b); file:File source = {path:"/tmp/result.txt"}; file:File destination = {path:"/tmp/copy.txt"}; file:copy(source, destination); println("file copied: /tmp/result.txt to /tmp/copy.txt"); destination.delete(); println("file deleted: /tmp/copy.txt"); destination = {path:"/tmp/move.txt"}; file:move(source, destination); } Ballerina File API - Example Open Exists Copy Delete Move
  • 7. Ballerina I/O API I/O APIs Record I/O RecordsCharacters Bytes I/O Channels: Files, Sockets, Devices, …. BytesI/O CharactersI/O Console I/O DataI/O Different record formats
  • 8. • Read byte by byte • Character by character • Record by record • Canonical byte representation • Console I/O, Data I/O (Future) Ballerina I/O API - Files
  • 10. Read a Record From File
  • 11. • Support connecting with remote file systems over FTP/SMB/SFTP (in-development) • Secure file transfer through encryption Future Improvements
  • 13. • Modern applications (especially web) consumes large amount of data in real time • Request-Response pattern no longer sufficient • HTTP (1.1 and prior) lives with hacks (AJAX long polling, Streaming, etc.) Why Websockets?
  • 14. • Long-lived connections • Bi-directional messaging (full-duplex) • Low usage of headers (save bandwidth) • Co-exists with HTTP With Websockets
  • 15. • Support for different frame types (text, binary, ping, pong) • Sub protocol support • SSL support • Live alongside HTTP Websockets in Ballerina
  • 16. • Expose ballerina service through websockets • Executes different logic based on message type (text, binary, ping, pong) • Can configure base path and port which is exposing Websockets Server connector
  • 17. Websockets Server Connector Websockets service definition Client initiates a connection Client connected Text frame received Connection closed Service configuration
  • 18. Websockets Client Connector • Creates a connection with a websocket service • Supports sub protocols • Text, Binary, Ping, Pong message types • Supports security
  • 19. • Visit Ballerina website https://ballerinalang.org/ • Start with examples https://ballerinalang.org/docs/by-example/ • Contribute https://github.com/ballerinalang Download and getting started 19