Skip to content

Commit

Permalink
Use the BuiltinExchangeType instead of string literals in Java examples
Browse files Browse the repository at this point in the history
  • Loading branch information
christophetd committed Mar 21, 2017
1 parent 7d09e3b commit 34619a5
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion java/EmitLog.java
@@ -1,3 +1,4 @@
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
Expand All @@ -12,7 +13,7 @@ public static void main(String[] argv) throws Exception {
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.FANOUT);

String message = getMessage(argv);

Expand Down
3 changes: 2 additions & 1 deletion java/EmitLogDirect.java
@@ -1,3 +1,4 @@
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
Expand All @@ -13,7 +14,7 @@ public static void main(String[] argv) throws Exception {
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

channel.exchangeDeclare(EXCHANGE_NAME, "direct");
channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.DIRECT);

String severity = getSeverity(argv);
String message = getMessage(argv);
Expand Down
2 changes: 1 addition & 1 deletion java/EmitLogHeader.java
Expand Up @@ -38,7 +38,7 @@ public static void main(String[] argv) throws Exception {
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

channel.exchangeDeclare(EXCHANGE_NAME, "headers");
channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.HEADERS);

AMQP.BasicProperties.Builder builder = new AMQP.BasicProperties.Builder();

Expand Down
3 changes: 2 additions & 1 deletion java/EmitLogTopic.java
@@ -1,3 +1,4 @@
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
Expand All @@ -16,7 +17,7 @@ public static void main(String[] argv) {
connection = factory.newConnection();
channel = connection.createChannel();

channel.exchangeDeclare(EXCHANGE_NAME, "topic");
channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.TOPIC);

String routingKey = getRouting(argv);
String message = getMessage(argv);
Expand Down
2 changes: 1 addition & 1 deletion java/ReceiveLogHeader.java
Expand Up @@ -18,7 +18,7 @@ public static void main(String[] argv) throws Exception {
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

channel.exchangeDeclare(EXCHANGE_NAME, "headers");
channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.HEADERS);

// The API requires a routing key, but in fact if you are using a header exchange the
// value of the routing key is not used in the routing. You can receive information
Expand Down
2 changes: 1 addition & 1 deletion java/ReceiveLogs.java
Expand Up @@ -11,7 +11,7 @@ public static void main(String[] argv) throws Exception {
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.FANOUT);
String queueName = channel.queueDeclare().getQueue();
channel.queueBind(queueName, EXCHANGE_NAME, "");

Expand Down
2 changes: 1 addition & 1 deletion java/ReceiveLogsDirect.java
Expand Up @@ -12,7 +12,7 @@ public static void main(String[] argv) throws Exception {
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

channel.exchangeDeclare(EXCHANGE_NAME, "direct");
channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.DIRECT);
String queueName = channel.queueDeclare().getQueue();

if (argv.length < 1){
Expand Down
2 changes: 1 addition & 1 deletion java/ReceiveLogsTopic.java
Expand Up @@ -12,7 +12,7 @@ public static void main(String[] argv) throws Exception {
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();

channel.exchangeDeclare(EXCHANGE_NAME, "topic");
channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.TOPIC);
String queueName = channel.queueDeclare().getQueue();

if (argv.length < 1) {
Expand Down

0 comments on commit 34619a5

Please sign in to comment.