List of usage examples for com.rabbitmq.client MessageProperties MINIMAL_PERSISTENT_BASIC
BasicProperties MINIMAL_PERSISTENT_BASIC
To view the source code for com.rabbitmq.client MessageProperties MINIMAL_PERSISTENT_BASIC.
Click Source Link
From source file:uk.ac.sanger.cgp.wwdocker.messages.Messaging.java
License:Open Source License
/** * Sends a message to the specified queue * @param queue//from w w w .j a v a 2 s . com * @param in * @param host * @throws IOException * @throws InterruptedException * @throws TimeoutException */ public void sendMessage(String queue, Object in, String host) throws IOException, InterruptedException, TimeoutException { String message; Builder propBuilder = MessageProperties.MINIMAL_PERSISTENT_BASIC.builder(); if (in.getClass().equals(String.class)) { message = (String) in; } else { message = Utils.objectToJson(in); if (in.getClass().equals(WorkerState.class)) { host = ((WorkerState) in).getResource().getHostName(); } } if (host != null) { Map<String, Object> headers = new HashMap(); headers.put("host", host); propBuilder.headers(headers); } BasicProperties mProp = propBuilder.build(); Connection connectionSend = getRmqConn(); Channel channel = connectionSend.createChannel(); channel.confirmSelect(); channel.queueDeclare(queue, true, false, false, null); channel.basicPublish("", queue, mProp, message.getBytes()); channel.waitForConfirmsOrDie(5000); logger.info(queue + " sent: " + message); channel.close(); closeRmqConn(connectionSend); }
From source file:uk.ac.sanger.cgp.wwdocker.messages.Messaging.java
License:Open Source License
public void sendFile(String queue, String host, File f) throws IOException, InterruptedException, TimeoutException { Map<String, Object> headers = new HashMap(); headers.put("host", host); BasicProperties mProp = MessageProperties.MINIMAL_PERSISTENT_BASIC.builder().headers(headers).build(); Connection connectionSend = getRmqConn(); Channel channel = connectionSend.createChannel(); channel.confirmSelect();//from ww w. j a v a 2s . c om channel.queueDeclare(queue, true, false, false, null); channel.basicPublish("", queue, mProp, Files.readAllBytes(f.toPath())); channel.waitForConfirmsOrDie(5000); logger.info(queue + " file: " + f.getAbsolutePath()); channel.close(); closeRmqConn(connectionSend); }
From source file:vn.com.uet.performance.rabbitmq.Producer.java
License:Open Source License
private void publish(byte[] msg) throws IOException { unconfirmedSet.add(channel.getNextPublishSeqNo()); channel.basicPublish(exchangeName, randomRoutingKey ? UUID.randomUUID().toString() : id, mandatory, immediate,//from w w w .j a v a 2s. c o m persistent ? MessageProperties.MINIMAL_PERSISTENT_BASIC : MessageProperties.MINIMAL_BASIC, msg); }