Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. brew install rabbitmq
  2.  
  3. rabbitmqctl add_user abhi abhi
  4. rabbitmqctl set_user_tags abhi administrator
  5. rabbitmqctl add_vhost myvhost
  6. rabbitmqctl set_permissions -p myvhost abhi ".*" ".*" ".*"
  7. rabbitmqadmin declare exchange --vhost=myvhost name=exchange1 type=direct --user=abhi --password=abhi
  8. rabbitmqadmin -u abhi -p abhi -V myvhost declare queue name=myqueue
  9. rabbitmqadmin -u abhi -p abhi -V myvhost declare binding source=exchange1 destination=myqueue routing_key=foo.bar durable=true
  10.  
  11. CONFIG_FILE=/usr/local/etc/rabbitmq/rabbitmq
  12. NODE_IP_ADDRESS=10.zz.yy.xxx
  13. NODENAME=rabbit@mydevbox
  14.  
  15. implicit val actorSystem = ActorSystem()
  16. implicit val actorMaterializer = ActorMaterializer()
  17. val queueName = "myqueue"
  18. val queueDeclaration = QueueDeclaration(queueName, durable = true)
  19. val uri = "amqp://abhi:abhi@mydevbox:5672/myvhost"
  20. val settings = AmqpSinkSettings(AmqpConnectionUri(uri)).withRoutingKey("foo.bar").withDeclarations(queueDeclaration)
  21. val amqpSink = AmqpSink.simple(settings)
  22.  
  23. val resource = getClass.getResource("/countrycapital.csv")
  24. val path = Paths.get(resource.toURI)
  25. val source = FileTailSource.lines(path, 8092, 100 millis).map{x => println(x); x}.map(ByteString(_))
  26.  
  27. val graph = RunnableGraph.fromGraph(GraphDSL.create(amqpSink){implicit builder =>
  28. s =>
  29. import GraphDSL.Implicits._
  30. source ~> s.in
  31. ClosedShape
  32. })
  33. val future = graph.run()
  34. future.onComplete{_ => actorSystem.terminate()}
  35. Await.result(actorSystem.whenTerminated, Duration.Inf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement