在每条消息成功发送到 JMS 或失败后如何进行回调?
val jmsSink = JmsSink.textSink(
JmsSinkSettings(connectionFactory).withQueue("My_Queue")
)
Source(Stream.from(1))
.map(_.toString)
.runWith(jmsSink)
更具体的例子
// creating a sourceQueue which is bound to jmsSink
val sourceQueue: SourceQueueWithComplete[String] =
Source.queue[String](bufferSize, OverflowStrategy.backpressure)
.to(jmsSink)
.run()
客户将项目发送到sourceQueue
:
val result: Future[QueueOfferResult] = sourceQueue offer "my-item"
val result
是插入项目的结果,sourceQueue
并不意味着它已经发送到JMS。当项目通过接收器过程并插入到 JMS 队列时,我需要触发一个事件。