Advertisement
vitareinforce

nuxt kereta

Jul 25th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import amqp from 'amqplib/callback_api'
  2.  
  3. export default {
  4. components: {
  5. AppLogo
  6. },
  7. data () {
  8. return {
  9. messages: ''
  10. }
  11. },
  12. created: function() {
  13. try {
  14. amqp.connect({
  15. protocol: 'amqp',
  16. hostname: '',//isi
  17. port: 5672,
  18. username: '',//isi
  19. password: '',//isi
  20. locale: 'en_US',
  21. frameMax: 0,
  22. heartbeat: 0,
  23. vhost: '',//isi
  24. }, function(err, conn) {
  25. if(err) {
  26. console.log("Error :" + err)
  27. }
  28. if(conn) {
  29. console.log("Creating Channel")
  30. conn.createChannel(function(err, ch) {
  31. console.log("Channel Created")
  32. ch.assertExchange('amq.topic', 'topic', {durable: true});
  33. console.log("Creating Exchange")
  34. ch.assertQueue('out.topic', {exclusive: false}, function(err, q) {
  35. if(err) {
  36. console.log("Error Queue : " + err)
  37. }
  38. if(q) {
  39. console.log("Creating Queue")
  40. ch.bindQueue('out.topic', 'amq.topic', 'position')
  41. console.log("Waiting")
  42. ch.consume('out.topic', function(msg) {
  43. console.log(" [x] %s", msg.content.toString())
  44. }, {noAck: true})
  45.  
  46. }
  47. })
  48. })
  49. }
  50. })
  51. } catch (e) {
  52. console.log(e.Message);
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement