diff --git a/examples/bin/examples/rabbitmq/query.body b/examples/bin/examples/rabbitmq/query.body new file mode 100644 index 00000000000..43623cfa733 --- /dev/null +++ b/examples/bin/examples/rabbitmq/query.body @@ -0,0 +1,12 @@ +{ + "queryType": "groupBy", + "dataSource": "rabbitmqtest", + "granularity": "all", + "dimensions": [], + "aggregations": [ + { "type": "count", "name": "rows" }, + {"type": "longSum", "name": "imps", "fieldName": "impressions"}, + {"type": "doubleSum", "name": "wp", "fieldName": "wp"} + ], + "intervals": ["2010-01-01T00:00/2020-01-01T00:00"] +} diff --git a/examples/bin/examples/rabbitmq/rabbitmq_realtime.spec b/examples/bin/examples/rabbitmq/rabbitmq_realtime.spec new file mode 100644 index 00000000000..fc26f21ee3a --- /dev/null +++ b/examples/bin/examples/rabbitmq/rabbitmq_realtime.spec @@ -0,0 +1,44 @@ +[{ + "schema" : { + "dataSource":"rabbitmqtest", + "aggregators":[ + {"type":"count", "name":"impressions"}, + {"type":"doubleSum","name":"wp","fieldName":"wp"} + ], + "indexGranularity":"minute", + "shardSpec" : { "type": "none" } + }, + "config" : { + "maxRowsInMemory" : 500000, + "intermediatePersistPeriod" : "PT1m" + }, + "firehose" : { + "type" : "rabbitmq", + "connection" : { + "host": "localhost", + "username": "test-dude", + "password": "word-dude", + "virtualHost": "test-vhost" + }, + "config" : { + "exchange": "test-exchange", + "queue" : "druidtest", + "routingKey": "#", + "durable": "true", + "exclusive": "false", + "autoDelete": "false" + }, + "parser" : { + "timestampSpec" : { "column" : "utcdt", "format" : "iso" }, + "data" : { "format" : "json" }, + "dimensionExclusions" : ["wp"] + } + }, + "plumber" : { + "type" : "realtime", + "windowPeriod" : "PT5m", + "segmentGranularity":"hour", + "basePersistDirectory" : "/tmp/realtime/basePersist", + "rejectionPolicy": { "type": "messageTime" } + } +}] diff --git a/examples/src/main/java/druid/examples/rabbitmq/RabbitMQProducerMain.java b/examples/src/main/java/druid/examples/rabbitmq/RabbitMQProducerMain.java new file mode 100644 index 00000000000..a070bfff929 --- /dev/null +++ b/examples/src/main/java/druid/examples/rabbitmq/RabbitMQProducerMain.java @@ -0,0 +1,182 @@ +package druid.examples.rabbitmq; + +import com.rabbitmq.client.Channel; +import com.rabbitmq.client.Connection; +import com.rabbitmq.client.ConnectionFactory; +import org.apache.commons.cli.*; + +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * + */ +public class RabbitMQProducerMain +{ + public static void main(String[] args) + throws Exception + { + // We use a List to keep track of option insertion order. See below. + final List