I want to create a queue within an existing exchange for reading.
Another application is publishing messages to this exchange and fanning them out to all member queues. I want my new application to be an additional subscriber to these messages.
The following creates a queue:
implicit val system = ActorSystem("my-system")
implicit val materializer = ActorMaterializer()
implicit val executionCtx: ExecutionContext = system.dispatcher
val queueName: String = s"test-queue-${System.currentTimeMillis}"
val queueDeclaration = QueueDeclaration(queueName, autoDelete = true)
val amqpSource = AmqpSource(
NamedQueueSourceSettings(AmqpConnectionUri(amqpUri), queueName)
.withDeclarations(queueDeclaration), bufferSize = 10)
And this creates a sink for an exchange
val sink = AmqpSink.simple(AmqpSinkSettings(AmqpConnectionUri(amqpUri))
.withExchange("exchange_name"))
But I'm not sure how to use them together, if that's the right approach.