Skip to content

Commit

Permalink
New optional exchange parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
eduard93 committed Mar 15, 2018
1 parent 97bb62e commit 5932249
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/isc/rabbitmq/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ public class API {

private final String _queue;

private final String _exchange;

private final Connection _connection;

public API(String host, int port, String user, String pass, String virtualHost, String queue, int durable) throws Exception {
this(host, port, user, pass, virtualHost, queue, durable, "");
}

public API(String host, int port, String user, String pass, String virtualHost, String queue, int durable, String exchange) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost(host);
factory.setPort(port);
Expand Down Expand Up @@ -53,6 +59,7 @@ public API(String host, int port, String user, String pass, String virtualHost,
}

_queue = queue;
_exchange = exchange;
}

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

public void sendMessageToQueue(String queue, byte[] msg) throws Exception {
_channel.basicPublish("", queue, null, msg);
_channel.basicPublish(_exchange, queue, null, msg);
}

public void sendMessageToQueue(String queue, byte[] msg, String correlationId, String messageId) throws Exception {
AMQP.BasicProperties props = createProperties(correlationId, messageId);
_channel.basicPublish("", queue, props, msg);
_channel.basicPublish(_exchange, queue, props, msg);
}

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

0 comments on commit 5932249

Please sign in to comment.