Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Code snippets for channel caching in Spring AMQP (RabbitMQ)
- CachingConnectionFactory connectionFactory = new CachingConnectionFactory("somehost");
- connectionFactory.setUsername("guest");
- connectionFactory.setPassword("guest");
- connectionFactory.setChannelCacheSize(30); //caching 30 channels
- AmqpTemplate amqpTemplate = new RabbitTemplate(connectionFactory);
- amqpTemplate.setExchange("exchange.name");
- amqpTemplate.setRoutingKey("routing.key");
- amqpTemplate.send(new Message("Your_String_Message".getBytes());
- //If you want to see headers and properties on the message, you can use the builder pattern
- Message message = MessageBuilder.withBody("some_message".getBytes())
- .setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
- .setMessageId("123")
- .setHeader("bar", "baz")
- .build();
Add Comment
Please, Sign In to add comment