Skip to content

Instantly share code, notes, and snippets.

View riyafa's full-sized avatar

Riyafa Abdul Hameed riyafa

View GitHub Profile
SELECT VALUE {"Length": st_length(geo.myGeometry), "Boundary":st_boundary(geo.myGeometry)} FROM Geometries geo WHERE geometry_type(geo.myGeometry)="LineString" OR geometry_type(geo.myGeometry)="MultiLineString";
@riyafa
riyafa / rafactor.bal
Last active March 20, 2018 09:28
Compiling websocket code
import ballerina.net.http;
import ballerina.io;
import ballerina.runtime;
endpoint http:ServiceEndpoint ep1 {
port:9090
};
@http:WebSocketServiceConfig {
basePath:"/basic/ws"
@riyafa
riyafa / client_connector.bal
Last active October 2, 2018 02:34
A working ballerina code using theWebSocket client connector
import ballerina/io;
import ballerina/log;
import ballerina/http;
int currentCaseId = 0;
int caseCounts = 0;
string ws_uri = "ws://localhost:9001";
public function main() {
openWebSocket(ws_uri + "/getCaseCount");
//openWebSocket(ws_uri + "/updateReports?agent=ballerinax");
@riyafa
riyafa / upgradeWebSocket.bal
Created March 12, 2018 10:11
Websocket upgrade from HTTP
import ballerina.net.http;
import ballerina.io;
import ballerina.runtime;
endpoint<http:Service> passthruEP {
port:9090
}
endpoint< http:Client> backendClientEP {
serviceUri: "http://www.mocky.io"
@riyafa
riyafa / http_client.bal
Last active March 21, 2018 09:40
working http client
import ballerina.net.http;
import ballerina.io;
endpoint http:ServiceEndpoint passthruEP {
port:9090
};
endpoint http:ClientEndpoint httpClient {
targets: [{uri: "http://www.mocky.io"}]};
import ballerina/log;
import ballerina/http;
@final string NAME = "NAME";
@final string AGE = "AGE";
endpoint http:WebSocketListener ep {
port:9090
};
@http:ServiceConfig {
@riyafa
riyafa / client_in_main.bal
Created April 20, 2018 06:02
Websocket Client endpoint in main method
import ballerina/io;
import ballerina/http;
import ballerina/runtime;
@final string REMOTE_BACKEND_URL = "ws://localhost:15500/websocket";
boolean isComplete = false;
function main(string[] args) {
http:WebSocketClient wsClientEp;
http:WebSocketClientEndpointConfig wsConfig = {
@riyafa
riyafa / websocket_client.bal
Last active June 13, 2019 08:51
Ballerina Websocket client in main function
import ballerina/io;
import ballerina/http;
public function main() {
http:WebSocketClient wsClientEp = new("ws://echo.websocket.org", config = {callbackService: ClientService});
checkpanic wsClientEp->pushText("hello");
}
service ClientService =@http:WebSocketServiceConfig {} service {
//This resource is triggered when a new text frame is received from the remote backend.
@riyafa
riyafa / secure_websocket_client.bal
Last active October 14, 2019 13:16
A secure WebSocket client using Ballerina
import ballerina/io;
import ballerina/http;
string ping = "ping";
byte[] pingData = ping.toBytes();
public function main() {
http:WebSocketClient wsClientEp = new("wss://echo.websocket.org", config={secureSocket: {
trustedCertFile:"/home/riyafa/websocketorg.crt"
@riyafa
riyafa / Consumer.java
Created February 21, 2019 13:49
JMS Asynchronous Receiver for ActiveMQ artemis
package riyafa.jms;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Message;