-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #516 from dbmdz/channel_exception
Automatically recover from channel-level exception
- Loading branch information
Showing
31 changed files
with
360 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
framework/src/main/java/com/github/dbmdz/flusswerk/framework/rabbitmq/ChannelCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.github.dbmdz.flusswerk.framework.rabbitmq; | ||
|
||
import java.io.IOException; | ||
|
||
public interface ChannelCommand<T> { | ||
T execute() throws IOException; | ||
} |
81 changes: 81 additions & 0 deletions
81
framework/src/main/java/com/github/dbmdz/flusswerk/framework/rabbitmq/ChannelCommands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.github.dbmdz.flusswerk.framework.rabbitmq; | ||
|
||
import com.rabbitmq.client.*; | ||
import java.util.Map; | ||
|
||
public class ChannelCommands { | ||
|
||
private final Channel channel; | ||
|
||
public ChannelCommands(Channel channel) { | ||
this.channel = channel; | ||
} | ||
|
||
public ChannelCommand<Void> basicPublish( | ||
String exchange, String routingKey, AMQP.BasicProperties properties, byte[] data) { | ||
return () -> { | ||
channel.basicPublish(exchange, routingKey, properties, data); | ||
return null; | ||
}; | ||
} | ||
|
||
public ChannelCommand<Void> basicAck(long deliveryTag, boolean multiple) { | ||
return () -> { | ||
channel.basicAck(deliveryTag, multiple); | ||
return null; | ||
}; | ||
} | ||
|
||
public ChannelCommand<Void> basicReject(long deliveryTag, boolean requeue) { | ||
return () -> { | ||
channel.basicReject(deliveryTag, requeue); | ||
return null; | ||
}; | ||
} | ||
|
||
public ChannelCommand<GetResponse> basicGet(String queue, boolean autoAck) { | ||
return () -> channel.basicGet(queue, autoAck); | ||
} | ||
|
||
public ChannelCommand<Void> basicConsume(String queue, boolean autoAck, Consumer consumer) { | ||
return () -> { | ||
channel.basicConsume(queue, autoAck, consumer); | ||
return null; | ||
}; | ||
} | ||
|
||
public ChannelCommand<Void> exchangeDeclare( | ||
String exchange, BuiltinExchangeType type, boolean durable) { | ||
return () -> { | ||
channel.exchangeDeclare(exchange, type, durable); | ||
return null; | ||
}; | ||
} | ||
|
||
public ChannelCommand<Void> queueDeclare( | ||
String name, | ||
boolean durable, | ||
boolean exclusive, | ||
boolean autoDelete, | ||
Map<String, Object> args) { | ||
return () -> { | ||
channel.queueDeclare(name, durable, exclusive, autoDelete, args); | ||
return null; | ||
}; | ||
} | ||
|
||
public ChannelCommand<Void> queueBind(String name, String exchange, String routingKey) { | ||
return () -> { | ||
channel.queueBind(name, exchange, routingKey); | ||
return null; | ||
}; | ||
} | ||
|
||
public ChannelCommand<Long> messageCount(String queue) { | ||
return () -> channel.messageCount(queue); | ||
} | ||
|
||
public ChannelCommand<AMQP.Queue.PurgeOk> queuePurge(String queue) { | ||
return () -> channel.queuePurge(queue); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
framework/src/main/java/com/github/dbmdz/flusswerk/framework/rabbitmq/ChannelListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.github.dbmdz.flusswerk.framework.rabbitmq; | ||
|
||
/** A ChannelListener receives notifications about channel recovery. */ | ||
public interface ChannelListener { | ||
void handleReset(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.