0

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.

Synesso
  • 37,610
  • 35
  • 136
  • 207
  • could you please clarify your end goal? You just mentioned you want to create a queue within an exchange. What do you want to do with this queue? – Stefano Bonetti Jun 23 '17 at 21:53
  • Added the second paragraph to clarify intent. @StefanoBonetti – Synesso Jun 23 '17 at 22:23
  • Have you read http://developer.lightbend.com/docs/alpakka/latest/amqp.html#using-pub-sub-with-an-amqp-server ? Please try creating a source as described in that section, and if it doesn't work, describe what failed. – lutzh Jun 24 '17 at 13:28
  • Also, take a look at the tests for the Alpakka connectors if you need more extensive examples https://github.com/akka/alpakka/tree/master/amqp/src/test/scala/akka/stream/alpakka/amqp – Stefano Bonetti Jun 24 '17 at 13:39
  • Thanks @StefanoBonetti, the examples were helpful. What I needed was `TemporaryQueueSourceSettings` instead of `NamedQueueSourceSettings`, as the former allows for an exchange name. – Synesso Jun 24 '17 at 23:40

0 Answers0