Guest User

Untitled

a guest
Jul 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. //Code snippets for channel caching in Spring AMQP (RabbitMQ)
  2.  
  3. CachingConnectionFactory connectionFactory = new CachingConnectionFactory("somehost");
  4. connectionFactory.setUsername("guest");
  5. connectionFactory.setPassword("guest");
  6. connectionFactory.setChannelCacheSize(30); //caching 30 channels
  7.  
  8. AmqpTemplate amqpTemplate = new RabbitTemplate(connectionFactory);
  9. amqpTemplate.setExchange("exchange.name");
  10. amqpTemplate.setRoutingKey("routing.key");
  11. amqpTemplate.send(new Message("Your_String_Message".getBytes());
  12.  
  13.  
  14. //If you want to see headers and properties on the message, you can use the builder pattern
  15. Message message = MessageBuilder.withBody("some_message".getBytes())
  16. .setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
  17. .setMessageId("123")
  18. .setHeader("bar", "baz")
  19. .build();
Add Comment
Please, Sign In to add comment