io.kestra.plugin.solace.Produce Maven / Gradle / Ivy
package io.kestra.plugin.solace;
import com.solace.messaging.MessagingService;
import com.solace.messaging.resources.Topic;
import io.kestra.core.models.annotations.Example;
import io.kestra.core.models.annotations.Plugin;
import io.kestra.core.models.annotations.PluginProperty;
import io.kestra.core.models.executions.metrics.Counter;
import io.kestra.core.models.tasks.Output;
import io.kestra.core.models.tasks.RunnableTask;
import io.kestra.core.runners.RunContext;
import io.kestra.plugin.solace.client.MessagingServiceFactory;
import io.kestra.plugin.solace.data.InputStreamProvider;
import io.kestra.plugin.solace.serde.Serde;
import io.kestra.plugin.solace.serde.Serdes;
import io.kestra.plugin.solace.service.publisher.AbstractSolaceDirectMessagePublisher;
import io.kestra.plugin.solace.service.publisher.DeliveryModes;
import io.kestra.plugin.solace.service.publisher.SolaceDirectMessagePublisher;
import io.kestra.plugin.solace.service.publisher.SolacePersistentMessagePublisher;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;
import jakarta.validation.constraints.NotNull;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* The {@link RunnableTask} can be used for producing messages to a Solace Broker.
*/
@Plugin(examples = {
@Example(
title = "Publish a file as messages into a Solace Broker.",
full = true,
code = {
"""
id: SendMessagesIntoSolaceBroker
namespace: company.team
inputs:
- type: FILE
name: file
description: a CSV file with columns id, username, tweet, and timestamp
tasks:
- id: readCsvFile
type: io.kestra.plugin.serdes.csv.CsvReader
from: "{{ inputs.file }}"
- id: transformRowToJson
type: io.kestra.plugin.scripts.nashorn.FileTransform
from: "{{ outputs.readCsvFile.uri }}"
script: |
var result = {
"payload": {
"username": row.username,
"tweet": row.tweet
},
"properties": {
"correlationId": "42"
}
};
row = result
- id: sendMessageToSolace
type: io.kestra.plugin.solace.Produce
from: "{{ outputs.transformRowToJson.uri }}"
topicDestination: /test
host: localhost:55555
username: admin
password: admin
vpn: default
messageSerializer: "JSON"
"""
}
)
})
@Schema(
title = "Publish messages to a Solace Broker."
)
@Slf4j
@SuperBuilder
@NoArgsConstructor
@Getter
public class Produce extends AbstractSolaceTask implements RunnableTask
© 2015 - 2025 Weber Informatics LLC | Privacy Policy