sendToDestination

@ExperimentalCoroutinesApi
fun ConnectionFactory.sendToDestination(destination: JmsDestination, upstream: Flow<JmsMessage>, concurrency: Int = 1, credentials: Credentials? = null): Flow<Unit>

Sends messages to a specified JMS destination from a given upstream flow of JmsMessage objects.

Return

A flow of Unit objects, indicating that a message has been sent.

Example usage:

val connectionFactory = // Obtain a JMS connection factory
val destination = JmsQueue("example-queue")
val messagesFlow = flowOf(
JmsTextMessage("Hello, River!"),
JmsTextMessage("Just go with the flow")
)

connectionFactory.sendToDestination(destination, messagesFlow)
.collect { println("Message sent") }

Parameters

destination

The JmsDestination to send messages to.

upstream

A flow of JmsMessage objects to be sent to the destination.

concurrency

The number of concurrent producers for sending messages. Defaults to 1.

credentials

Optional credentials to use for establishing the connection. Defaults to null.