List of usage examples for com.rabbitmq.client MessageProperties PERSISTENT_TEXT_PLAIN
BasicProperties PERSISTENT_TEXT_PLAIN
To view the source code for com.rabbitmq.client MessageProperties PERSISTENT_TEXT_PLAIN.
Click Source Link
From source file:ThreadWorkers.java
private static String doWork(String task) throws InterruptedException, IOException { //for (char ch: task.toCharArray()) { // if (ch == '.') Thread.sleep(1000); //}/* w w w .ja v a 2 s . c o m*/ String result = "empty result"; long threadId = Thread.currentThread().getId(); System.out.println("in thread>>>>" + threadId); if (task.equalsIgnoreCase("")) return result; if (task == null) return result; //if(task.charAt(0)=='f' || task.charAt(0)=='1') return result; if (task.charAt(0) == 'f') result = "factorial of " + task.substring(1) + ">>" + factor(task.substring(1)).toString(); else if (task.charAt(0) == 'p') { if (isPrime(task.substring(1).toString())) result = task.substring(1).toString() + " is prime"; else result = task.substring(1).toString() + " is not prime"; } else { result = "exponent " + task.substring(1) + ">>" + exp(task.substring(1)).toString(); } // sending result ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDeclare(TASK_QUEUE_REPLY_NAME, true, false, false, null); //String[] msg= {"10","second",".........."}; //String[] msg= {"1","second","."}; //String message ="rvr";// getMessage(msg); channel.basicPublish("", TASK_QUEUE_REPLY_NAME, MessageProperties.PERSISTENT_TEXT_PLAIN, result.getBytes()); System.out.println(" [x] Sent reply to client:: '" + result + "'"); channel.close(); connection.close(); return result; }
From source file:SenderUtil.java
public void sendMessage(String msg) throws IOException { ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDeclare(TASK_QUEUE_NAME, true, false, false, null); //String[] msg= {"10","second",".........."}; //String[] msg= {"1","second","."}; String message = msg;//getMessage(msg); channel.basicPublish("", TASK_QUEUE_NAME, MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes()); System.out.println(" [x] Sent '" + message + "'"); channel.close();// w w w. ja v a2 s. co m connection.close(); }
From source file:Client.SMActivity.java
License:Open Source License
public void publish(final String exchangeName, final String routingKey, final String msg) { try {//from w ww. ja v a 2 s. co m mChannel.basicPublish(exchangeName, routingKey, MessageProperties.PERSISTENT_TEXT_PLAIN, msg.getBytes()); mLogger.debug(" [" + getName() + "] Sent '" + routingKey + "':'" + msg + "'"); } catch (IOException e) { mLogger.error("Failure sending '" + routingKey + "':'" + msg + "' (" + e.toString() + ")"); } }
From source file:Client.SMActivity.java
License:Open Source License
public void publish(final String routingKey, final String msg) { try {// w ww . j av a 2 s .c om mChannel.basicPublish(DATA_EXCHANGE_NAME, routingKey, MessageProperties.PERSISTENT_TEXT_PLAIN, msg.getBytes()); mLogger.debug(" [" + getName() + "] Sent '" + routingKey + "':'" + msg + "'"); } catch (IOException e) { mLogger.error("Failure sending '" + routingKey + "':'" + msg + "' (" + e.toString() + ")"); } }
From source file:com.abiquo.commons.amqp.util.ProducerUtils.java
License:Open Source License
/** * Publish a message NonMandatory and NonImmediate. * //from w w w.j a va 2 s . c o m * @param channel The AMQ Channel to use. * @param exchange The exchange to publish the message to * @param routingKey The routing key * @param body The message, not null! * @throws IOException If an error is encountered */ public static void publishPersistentText(Channel channel, String exchange, String routingKey, byte[] body) throws IOException { channel.basicPublish(exchange, routingKey, MessageProperties.PERSISTENT_TEXT_PLAIN, body); }
From source file:com.bbxpc.pub.Pub.java
public static void queue(String msg) { if (null == msg || msg.length() <= 0) { return;/* w ww . ja v a 2 s. c om*/ } try { channel.basicPublish("", TASK_QUEUE_NAME, MessageProperties.PERSISTENT_TEXT_PLAIN, msg.getBytes()); System.out.println(">>>>>>>:" + msg + "\t" + System.currentTimeMillis()); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:com.digispherecorp.enterprise.rabbitmq.ra.cci.interatn.OutboundMessageInteractionSpec.java
@Override public Record execute(Record input) throws ResourceException { try {/*www.j a va 2 s .c o m*/ RabbitMQMessageRecord messageRecord = ((RabbitMQMessageRecord) input); connection = connectionFactory.newConnection(); channel = connection.createChannel(); if (messageRecord.getExchangeType() != null && !messageRecord.getExchangeType().isEmpty()) { channel.exchangeDeclare(((RabbitMQConnectionRequestInfo) connectionRequestInfo).getExchangeName(), messageRecord.getExchangeType(), true); } channel.basicPublish(((RabbitMQConnectionRequestInfo) connectionRequestInfo).getExchangeName(), ((RabbitMQConnectionRequestInfo) connectionRequestInfo).getRoutingKey(), MessageProperties.PERSISTENT_TEXT_PLAIN, messageRecord.getMessageByte()); } catch (IOException | TimeoutException ex) { Logger.getLogger(OutboundMessageInteractionSpec.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); throw new ResourceException(ex); } return null; }
From source file:com.gettec.fsnip.fsn.web.controller.rest.deal.DealProblemRESTService.java
/** * ?//from w w w . j a v a 2s . c om * @param name * @param model * @return */ @RequestMapping(method = RequestMethod.POST, value = "/editDealToProblem/{id}") public View editDealToProblem(@PathVariable(value = "id") long id, Model model, HttpServletRequest req, HttpServletResponse resp) { try { AuthenticateInfo info = SSOClientUtil.validUser(req, resp); RabbitMQUtil rabbitMQUtil = new RabbitMQUtil(); Channel channel = rabbitMQUtil.connect(); channel.exchangeDeclare(SUPERVISE_JG, SUPERVISE_DIRECT, true); channel.queueDeclare(SUPERVISE_JG, true, false, false, null); channel.queueBind(SUPERVISE_JG, SUPERVISE_JG, SUPERVISE_KEY); JSONObject jsonObject = dealToProblemService.getDealProblemLogVO(id, info); channel.basicPublish("", SUPERVISE_JG, MessageProperties.PERSISTENT_TEXT_PLAIN, jsonObject.toString().getBytes("UTF-8")); model.addAttribute("status", true); } catch (Exception e) { model.addAttribute("status", false); e.printStackTrace(); } return JSON; }
From source file:com.gettec.fsnip.fsn.web.controller.rest.deal.DealProblemRESTService.java
@RequestMapping(method = RequestMethod.GET, value = "/notice/{id}/{status}/{pageStatus}") public View notice(@PathVariable("id") long id, @PathVariable("status") long status, @PathVariable("pageStatus") long pageStatus, Model model, HttpServletRequest request, HttpServletResponse response) {/*from w w w . j a va 2s . c o m*/ try { DealProblem sendproblem = dealProblemService.noticeComplainById(id, status); if (status == 0) { //??RabbitMQ, RabbitMQUtil rabbitMQUtil = new RabbitMQUtil(); Channel channel = rabbitMQUtil.connect(); channel.exchangeDeclare(SUPERVISE_JG, SUPERVISE_DIRECT, true); channel.queueDeclare(SUPERVISE_JG, true, false, false, null); channel.queueBind(SUPERVISE_JG, SUPERVISE_JG, SUPERVISE_KEY); JSONObject jsonObject = dealToProblemService.getJsonDealToProblem(sendproblem, pageStatus); channel.basicPublish("", SUPERVISE_JG, MessageProperties.PERSISTENT_TEXT_PLAIN, jsonObject.toString().getBytes("UTF-8")); } else if (status == 1) { //? dealToProblemService.getNoticeDealToProblem(sendproblem); } } catch (Exception e) { e.printStackTrace(); } return JSON; }
From source file:com.kenshoo.flume.rabbitmq.SimpleRabbitMqProducer.java
License:Apache License
public void publish(String routingKey, byte[] msg) throws IOException { channel.basicPublish(EXCHANGE_NAME, routingKey, MessageProperties.PERSISTENT_TEXT_PLAIN, msg); logger.debug("published successfully with key: {}", routingKey); }