List of usage examples for com.rabbitmq.client Channel basicPublish
void basicPublish(String exchange, String routingKey, BasicProperties props, byte[] body) throws IOException;
From source file:workqueue.NewTask.java
public static void main(String[] argv) throws Exception { ConnectionFactory factory = new ConnectionFactory(); factory.setHost("datdb.cphbusiness.dk"); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDeclare(TASK_QUEUE_NAME, true, false, false, null); String message = getMessage(argv); channel.basicPublish("", TASK_QUEUE_NAME, MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes("UTF-8")); System.out.println(" [x] Sent '" + message + "'"); channel.close();/*w w w.j av a 2s.c o m*/ connection.close(); }
From source file:wunderrabbit.RabbitConnection.java
License:Apache License
@Override public void send(Endpoint endpoint, byte[] content, String contentType, Map<SendOption, Object> options) throws Exception { Options<SendOption> opts = new Options<>(options); Channel channel = null; try {/*from w w w . j a v a 2s. co m*/ channel = this.connection.createChannel(); declareQueue(channel, endpoint); BasicProperties props = new BasicProperties().builder().contentType(contentType) .headers((Map<String, Object>) opts.get(SendOption.HEADERS)).build(); channel.basicPublish("", (String) endpoint.implementation(), props, content); } finally { if (channel != null) { channel.close(); } } }
From source file:zipkin2.collector.rabbitmq.RabbitMQCollectorRule.java
License:Apache License
void publish(byte[] message) throws IOException, TimeoutException { Channel channel = collector.connection.get().createChannel(); try {/* w w w.ja va2s .c o m*/ channel.basicPublish("", collector.queue, null, message); } finally { channel.close(); } }