List of usage examples for com.rabbitmq.client MessageProperties PERSISTENT_BASIC
BasicProperties PERSISTENT_BASIC
To view the source code for com.rabbitmq.client MessageProperties PERSISTENT_BASIC.
Click Source Link
From source file:org.elasticsoftware.elasticactors.rabbitmq.cpt.LocalMessageQueue.java
License:Apache License
private AMQP.BasicProperties createProps(InternalMessage message) { if (message.getTimeout() < 0) { return message.isDurable() ? MessageProperties.PERSISTENT_BASIC : MessageProperties.BASIC; } else {//from ww w . j a v a 2 s. c om if (message.isDurable()) { return new AMQP.BasicProperties.Builder().contentType("application/octet-stream").deliveryMode(2) .priority(0).expiration(String.valueOf(message.getTimeout())).build(); } else { return new AMQP.BasicProperties.Builder().contentType("application/octet-stream").deliveryMode(1) .priority(0).expiration(String.valueOf(message.getTimeout())).build(); } } }
From source file:org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNode.java
License:Apache License
private static AMQP.BasicProperties convert(String name) throws TbNodeException { switch (name) { case "BASIC": return MessageProperties.BASIC; case "TEXT_PLAIN": return MessageProperties.TEXT_PLAIN; case "MINIMAL_BASIC": return MessageProperties.MINIMAL_BASIC; case "MINIMAL_PERSISTENT_BASIC": return MessageProperties.MINIMAL_PERSISTENT_BASIC; case "PERSISTENT_BASIC": return MessageProperties.PERSISTENT_BASIC; case "PERSISTENT_TEXT_PLAIN": return MessageProperties.PERSISTENT_TEXT_PLAIN; default:// w ww . j ava 2 s. c o m throw new TbNodeException("Message Properties: '" + name + "' is undefined!"); } }
From source file:org.thingsboard.server.extensions.rabbitmq.plugin.RabbitMqMsgHandler.java
License:Apache License
private static AMQP.BasicProperties convert(String name) throws RuleException { switch (name) { case "BASIC": return MessageProperties.BASIC; case "TEXT_PLAIN": return MessageProperties.TEXT_PLAIN; case "MINIMAL_BASIC": return MessageProperties.MINIMAL_BASIC; case "MINIMAL_PERSISTENT_BASIC": return MessageProperties.MINIMAL_PERSISTENT_BASIC; case "PERSISTENT_BASIC": return MessageProperties.PERSISTENT_BASIC; case "PERSISTENT_TEXT_PLAIN": return MessageProperties.PERSISTENT_TEXT_PLAIN; default://from w ww.ja v a 2 s.c o m throw new RuleException("Message Properties: '" + name + "' is undefined!"); } }
From source file:org.trpr.mule.transport.rabbitmq.RabbitDispatcher.java
License:Apache License
/** * Abstract method implementation. Dispatches the specified MuleEvent using the RPC client * @see org.mule.transport.AbstractMessageDispatcher#doDispatch(org.mule.api.MuleEvent) *//*from w w w.j a v a 2 s . co m*/ protected void doDispatch(MuleEvent event) throws Exception { MuleMessage msg = event.getMessage(); AMQP.BasicProperties msgProps = EndpointUtils.getDurable(endpoint) ? MessageProperties.PERSISTENT_BASIC : MessageProperties.BASIC; rpcClient.publish(msgProps, msg.getPayloadAsBytes()); dispatchedMessageCount++; // commit the message if the endpoint is durable and the commit count is reached. // The channel should and would have been created with txSelect in the RabbitConnector if (EndpointUtils.getDurable(endpoint) && (dispatchedMessageCount % ((RabbitConnector) connector).getDurableMessageCommitCount() == 0)) { // synchronized on the channel to avoid the below RabbitMQ client exception, caused in multi-threaded execution using the same channel: // java.lang.IllegalStateException: cannot execute more than one synchronous AMQP command at a time synchronized (channel) { channel.txCommit(); } } }
From source file:org.trpr.platform.integration.impl.messaging.RabbitMQMessagePublisherImpl.java
License:Apache License
/** * Publishes on a provided connection as per the connection configuration index. * If the connection is null or if publishing fails it throws an Exception. * @param message//from w w w . j a v a 2 s .c o m * @param connectionIndex * @throws Exception */ protected void publishToConnection(Object message, int connectionIndex) throws Exception { RabbitMQConfiguration rabbitMQConfiguration = rabbitMQConfigurations.get(connectionIndex); if (this.rabbitConnectionHolders[connectionIndex] == null) { throw new MessagingException("Connection not initialized"); } boolean isMessageOfTypeString = (message instanceof String); byte[] body = isMessageOfTypeString ? ((String) message).getBytes(ENCODING) : PlatformUtils.toBytes(message); AMQP.BasicProperties msgProps = rabbitMQConfiguration.isDurable() ? (isMessageOfTypeString ? MessageProperties.PERSISTENT_TEXT_PLAIN : MessageProperties.PERSISTENT_BASIC) : (isMessageOfTypeString ? MessageProperties.TEXT_PLAIN : MessageProperties.BASIC); if (rabbitMQConfiguration.isDurable()) { synchronized (this.rabbitConnectionHolders[connectionIndex].getChannel()) { // synchronized on the channel to avoid the below RabbitMQ client exception, caused in multi-threaded execution using the same channel: // java.lang.IllegalStateException: cannot execute more than one synchronous AMQP command at a time this.rabbitConnectionHolders[connectionIndex].getChannel().basicPublish( rabbitMQConfiguration.getExchangeName(), rabbitMQConfiguration.getRoutingKey(), msgProps, body); // Commit the message if it is durable and the commit count is reached. // The channel should and would be in txSelect mode when it was created using the RabbitMQConfiguration details // increment totNoOfMessagesQueued by 1 and check as it is post incremented after publishing the message if ((totNoOfMessagesQueued + 1) % rabbitMQConfiguration.getDurableMessageCommitCount() == 0) { if (rabbitMQConfiguration.isDisableTX()) { // error out, as explicitly disabling TX will not make the message durable LOGGER.error( "Configuration conflict. TX disabled for message publishing on durable queue. Message will not be published."); return; } this.rabbitConnectionHolders[connectionIndex].getChannel().txCommit(); } } } else { this.rabbitConnectionHolders[connectionIndex].getChannel().basicPublish( rabbitMQConfiguration.getExchangeName(), rabbitMQConfiguration.getRoutingKey(), msgProps, body); } }
From source file:org.wso2.siddhi.debs2017.input.DebsBenchmarkSystem.java
License:Open Source License
private void send(byte[] bytes) { Channel channel = outputQueue.getChannel(); try {//w w w . jav a 2s. c o m channel.basicPublish("", outputQueue.getName(), MessageProperties.PERSISTENT_BASIC, bytes); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.wso2.siddhi.debs2017.output.AlertGenerator.java
License:Open Source License
/** * generate the rdf model and publish to rabbitmq *//*from w w w .j a v a2s . c o m*/ public void generateAlert(Event event) { this.probThresh = Double.parseDouble(event.getData()[3].toString()); //this.timestamp = transformTimestamp((String) event.getData()[1]); this.timestamp = (String) event.getData()[1]; this.dimension = (String) event.getData()[2]; this.machineNumber = (String) event.getData()[0]; this.dispatchedTime = event.getTimestamp(); Model model = ModelFactory.createDefaultModel(); String anomalyName = "Anomaly_" + anomalyCount; Resource r1 = model.createResource(anomaly + anomalyName); Property type = model.createProperty(rdf + "type"); Resource r2 = model.createResource(ar + "Anomaly"); Property threshProb = model.createProperty(ar + "hasProbabilityOfObservedAbnormalSequence"); Property time = model.createProperty(ar + "hasTimeStamp"); Resource r4 = model.createResource(debs + timestamp); Property dim = model.createProperty(ar + "inAbnormalDimension"); Resource r5 = model.createResource(wmm + dimension); Property machine = model.createProperty(i40 + "machine"); Resource r6 = model.createResource(wmm + machineNumber); model.add(r1, threshProb, model.createTypedLiteral(probThresh)).add(r1, time, r4).add(r1, dim, r5) .add(r1, machine, r6).add(r1, type, r2); anomalyCount++; String str = "N-TRIPLES"; out = new StringWriter(); model.write(out, str); Channel channel = rabbitMQPublisher.getChannel(); try { channel.basicPublish("", rabbitMQPublisher.getName(), MessageProperties.PERSISTENT_BASIC, out.toString().getBytes()); } catch (Exception e) { e.printStackTrace(); } sum += System.currentTimeMillis() - dispatchedTime; if (anomalyCount == 20000) { System.out.println("Average Latency : " + (sum / anomalyCount)); } }
From source file:org.wso2.siddhi.debs2017.output.AlertGenerator.java
License:Open Source License
public void terminate() { Channel channel = rabbitMQPublisher.getChannel(); String TERMINATION_MESSAGE = "~~Termination Message~~"; try {/* www . j a va 2s . c o m*/ channel.basicPublish("", rabbitMQPublisher.getName(), MessageProperties.PERSISTENT_BASIC, TERMINATION_MESSAGE.toString().getBytes()); } catch (Exception e) { e.printStackTrace(); } }