List of usage examples for org.springframework.amqp.core MessageProperties CONTENT_TYPE_TEXT_PLAIN
String CONTENT_TYPE_TEXT_PLAIN
To view the source code for org.springframework.amqp.core MessageProperties CONTENT_TYPE_TEXT_PLAIN.
Click Source Link
From source file:org.springframework.amqp.rabbit.listener.SimpleMessageListenerWithRabbitMQ.java
public static void main(String[] args) throws InterruptedException { CachingConnectionFactory connectionFactory = new CachingConnectionFactory("localhost"); connectionFactory.setHost("localhost"); connectionFactory.setUsername("guest"); connectionFactory.setPassword("guest"); assertNotNull(connectionFactory);/* w w w . jav a 2 s.c o m*/ MessageConverter messageConverter = new SimpleMessageConverter(); MessageProperties messageProperties = new MessageProperties(); messageProperties.setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setQueueNames("foo"); container.setPrefetchCount(1000); container.setTxSize(500); container.setAcknowledgeMode(AcknowledgeMode.AUTO); container.setConcurrentConsumers(20); container.setMessageListener(new MessageListenerAdapter(new SimpleAdapter(), messageConverter)); container.start(); RabbitTemplate template = new RabbitTemplate(connectionFactory); template.setMessageConverter(messageConverter); List<BlockingQueue<?>> queues = getQueues(container); Thread.sleep(10000); int n = 0; while (true) { for (int i = 1; i <= 200; i++) { template.send("foo", "", new Message( "foo # ID: id".replace("#", String.valueOf(i)) .replace("id", java.util.UUID.randomUUID().toString()).getBytes(), messageProperties)); } Thread.sleep(1000); if (++n % 10 == 0) { logger.warn(count(queues)); } } }