Skip to content

Commit 5932249

Browse files
committed
New optional exchange parameter
1 parent 97bb62e commit 5932249

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: src/isc/rabbitmq/API.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ public class API {
1616

1717
private final String _queue;
1818

19+
private final String _exchange;
20+
1921
private final Connection _connection;
2022

2123
public API(String host, int port, String user, String pass, String virtualHost, String queue, int durable) throws Exception {
24+
this(host, port, user, pass, virtualHost, queue, durable, "");
25+
}
26+
27+
public API(String host, int port, String user, String pass, String virtualHost, String queue, int durable, String exchange) throws Exception {
2228
ConnectionFactory factory = new ConnectionFactory();
2329
factory.setHost(host);
2430
factory.setPort(port);
@@ -53,6 +59,7 @@ public API(String host, int port, String user, String pass, String virtualHost,
5359
}
5460

5561
_queue = queue;
62+
_exchange = exchange;
5663
}
5764

5865
public void sendMessage(byte[] msg, String correlationId, String messageId) throws Exception {
@@ -64,12 +71,12 @@ public void sendMessage(byte[] msg) throws Exception {
6471
}
6572

6673
public void sendMessageToQueue(String queue, byte[] msg) throws Exception {
67-
_channel.basicPublish("", queue, null, msg);
74+
_channel.basicPublish(_exchange, queue, null, msg);
6875
}
6976

7077
public void sendMessageToQueue(String queue, byte[] msg, String correlationId, String messageId) throws Exception {
7178
AMQP.BasicProperties props = createProperties(correlationId, messageId);
72-
_channel.basicPublish("", queue, props, msg);
79+
_channel.basicPublish(_exchange, queue, props, msg);
7380
}
7481

7582
public byte[] readMessageStream(String[] result) throws Exception {

0 commit comments

Comments
 (0)