List of usage examples for com.rabbitmq.client MessageProperties MINIMAL_BASIC
BasicProperties MINIMAL_BASIC
To view the source code for com.rabbitmq.client MessageProperties MINIMAL_BASIC.
Click Source Link
From source file:com.navercorp.pinpoint.plugin.rabbitmq.client.aspect.ChannelAspect.java
License:Apache License
@PointCut public void basicPublish(String exchange, String routingKey, boolean mandatory, boolean immediate, AMQP.BasicProperties props, byte[] body) { AMQP.BasicProperties sourceProps = props; if (sourceProps == null) { sourceProps = MessageProperties.MINIMAL_BASIC; }//from w ww . j a v a2 s . c o m AMQP.BasicProperties useProps = copy(sourceProps); __basicPublish(exchange, routingKey, mandatory, immediate, useProps, body); }
From source file:org.elasticsearch.river.rabbitmq.RabbitMQRiverWithCustomActionsTest.java
License:Apache License
public static void main(String[] args) throws Exception { String rabbitHost = "rabbit-qa1"; Node node = NodeBuilder.nodeBuilder().settings( ImmutableSettings.settingsBuilder().put("gateway.type", "none").put("cluster.name", "es-mqtest")) .node();// w w w . j a va2 s . c o m node.client().prepareIndex("_river", "mqtest1", "_meta") .setSource(jsonBuilder().startObject().field("type", "rabbitmq").startObject("rabbitmq") .field("host", rabbitHost).endObject().startObject("index").field("ordered", "true") .field("warnOnBulkErrors", "false").endObject().endObject()) .execute().actionGet(); ConnectionFactory cfconn = new ConnectionFactory(); cfconn.setHost(rabbitHost); cfconn.setPort(AMQP.PROTOCOL.PORT); Connection conn = cfconn.newConnection(); Channel ch = conn.createChannel(); ch.exchangeDeclare("elasticsearch", "direct", true); ch.queueDeclare("elasticsearch", true, false, false, null); Thread.sleep(5000); String message = "{ \"index\" : { \"_index\" : \"mqtest\", \"_type\" : \"type1\", \"_id\" : \"1\" , \"_version\" : \"2\"} }\n" + "{ \"type1\" : { \"field1\" : \"value1\" } }\n" + "{ \"delete\" : { \"_index\" : \"mqtest\", \"_type\" : \"type1\", \"_id\" : \"2\" } }\n" + "{ \"create\" : { \"_index\" : \"mqtest\", \"_type\" : \"type1\", \"_id\" : \"1\" , \"_version\" : \"2\"} }\n" + "{ \"create\" : { \"_index\" : \"mqtest\", \"_type\" : \"type1\", \"_id\" : \"1\" , \"_version\" : \"1\"} }\n" + "{ \"type1\" : { \"field1\" : \"value1\" } }"; String messageWithWrongIndex = "{ \"index\" : { \"_index\" : \"mqtest\", \"_type\" : \"type1\", \"_id\" : \"1\" , \"_version\" : \"2\"} }\n" + "{ \"type1\" : { \"field1\" : \"value1\" } }\n" + "{ \"delete\" : { \"_index\" : \"This.Is.An.Invalid.Name\", \"_type\" : \"type1\", \"_id\" : \"2\" } }\n" + "{ \"create\" : { \"_index\" : \"mqtest\", \"_type\" : \"type1\", \"_id\" : \"1\" , \"_version\" : \"2\"} }\n" + "{ \"create\" : { \"_index\" : \"mqtest\", \"_type\" : \"type1\", \"_id\" : \"1\" , \"_version\" : \"1\"} }\n" + "{ \"type1\" : { \"field1\" : \"value1\" } }"; String mapping = "{ \"type2\" : { \"properties\" : {\"data\" : {\"dynamic\" : true,\"properties\" : {\"myString\" : {\"type\" : \"string\",\"boost\" : 1.0,\"index\" : \"not_analyzed\",\"store\" : \"no\"},\"myText\" : {\"type\" : \"string\",\"include_in_all\" : true,\"index\" : \"analyzed\",\"store\" : \"no\"}}}}}}"; String mappingMessage = "{ \"_index\" : \"mqtest\", \"_type\" : \"type2\"}\n" + mapping; String partialmappingMessage = "{ \"_index\" : \"mqtest\", \"_type\" : \"type2\"}"; String deleteByQuery = "{ \"_index\" : \"mqtest\", \"_type\" : \"type1\", \"_queryString\" : \"_id:1\"}\n"; ch.basicPublish("elasticsearch", "elasticsearch", null, message.getBytes()); HashMap<String, Object> headers = new HashMap<String, Object>(); headers.put("X-ES-Command", "mapping"); BasicProperties props = MessageProperties.MINIMAL_BASIC; props = props.builder().headers(headers).build(); ch.basicPublish("elasticsearch", "elasticsearch", props, mappingMessage.getBytes()); headers.put("X-ES-Command", "deleteByQuery"); props = props.builder().headers(headers).build(); ch.basicPublish("elasticsearch", "elasticsearch", props, deleteByQuery.getBytes()); Thread.sleep(5000); ch.basicPublish("elasticsearch", "elasticsearch", null, message.getBytes()); ch.basicPublish("elasticsearch", "elasticsearch", null, messageWithWrongIndex.getBytes()); ch.basicPublish("elasticsearch", "elasticsearch", null, message.getBytes()); ch.basicPublish("elasticsearch", "elasticsearch", props, deleteByQuery.getBytes()); Thread.sleep(5000); ch.close(); conn.close(); Thread.sleep(5000); Boolean exists = node.client().get(new GetRequest("mqtest").id("1")).get().isExists(); ClusterState state = node.client().admin().cluster() .state(new ClusterStateRequest().filteredIndices("mqtest")).get().getState(); ImmutableOpenMap<String, MappingMetaData> mappings = state.getMetaData().index("mqtest").mappings(); MappingMetaData typeMap = mappings.get("type2"); if (null != typeMap) { String gotMapping = typeMap.source().toString(); } }
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:/*from w ww . j a v a 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:// w ww . j av a 2 s . co m throw new RuleException("Message Properties: '" + name + "' is undefined!"); } }
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 ww . ja va 2s. c o m persistent ? MessageProperties.MINIMAL_PERSISTENT_BASIC : MessageProperties.MINIMAL_BASIC, msg); }