Skip to content

Instantly share code, notes, and snippets.

data class SseModel(val event: String? = null, val data: String = "", val id: String? = null, val retry: Number? = null) {
override fun toString(): String {
val sseStrings = arrayListOf<String>()
if(event != null) sseStrings.add("event: $event")
sseStrings.add("data: $data")
if(id != null) sseStrings.add("id: $id")
if(retry != null) sseStrings.add("retry: $retry")
sseStrings.add("\n")
@Controller
class RestEndpoint {
var streamResponse: CSVStreamResponseOutput
constructor(csvStreamResponseOutput: CSVStreamResponseOutput) {
this.streamResponse = csvStreamResponseOutput
}
@GetMapping(path = ["stream"], produces = [MediaType.APPLICATION_STREAM_JSON_VALUE])
@Component
class CSVStreamResponseOutput : StreamingResponseBody {
var dataProvider: DataProvider
constructor(dataProvider: DataProvider) {
this.dataProvider = dataProvider
}
/**
@Component
class DataProvider {
/**
* create flowable from sampledata.csv
* @return every 100ms one line
*/
fun getDataStream(): Flowable<String> {
val csvFile = this::class.java.getResource("/static/sampledata.csv").openStream()
wget https://pysparksampledata.blob.core.windows.net/sampledata/sampledata.csv > sampledata.csv
wrk -c 400 -d 10 - latency - timeout 1s http://localhost:8080/cars-locust
FROM jboss/wildfly
ADD helloworld.war /opt/jboss/wildfly/standalone/deployments/
ARG WILDFLY_NAME
ARG CLUSTER_PW
ENV WILDFLY_NAME=${WILDFLY_NAME}
ENV CLUSTER_PW=${CLUSTER_PW}
...
wildfly1_1 | ... INFO [org.infinispan.CLUSTER] (MSC service thread 1-3) ISPN000094: Received new cluster view for channel ejb: [wildfly_2_test|1] (2) [wildfly_2_test, wildfly_1_test]
wildfly1_1 | ... INFO [org.infinispan.CLUSTER] (MSC service thread 1-5) ISPN000094: Received new cluster view for channel ejb: [wildfly_2_test|1] (2) [wildfly_2_test, wildfly_1_test]
wildfly1_1 | ... INFO [org.infinispan.CLUSTER] (MSC service thread 1-1) ISPN000094: Received new cluster view for channel ejb: [wildfly_2_test|1] (2) [wildfly_2_test, wildfly_1_test]
wildfly1_1 | ... INFO [org.infinispan.CLUSTER] (MSC service thread 1-7) ISPN000094: Received new cluster view for channel ejb: [wildfly_2_test|1] (2) [wildfly_2_test, wildfly_1_test]
...
wildfly2_1 | ... INFO [org.infinispan.CLUSTER] (remote-thread--p6-t2) [Context=client-mappings] ISPN100002: Starting rebalance with members [wildfly_2_test, wildfly_1_test], phase READ_OLD_WRITE_ALL, topology id 2
version: '3.5'
services:
wildfly1:
build:
context: .
args:
WILDFLY_NAME: wildfly_1_test
CLUSTER_PW: secret_password
image: wildfly_1_test
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]