@@ -16,9 +16,15 @@ public class API {
16
16
17
17
private final String _queue ;
18
18
19
+ private final String _exchange ;
20
+
19
21
private final Connection _connection ;
20
22
21
23
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 {
22
28
ConnectionFactory factory = new ConnectionFactory ();
23
29
factory .setHost (host );
24
30
factory .setPort (port );
@@ -53,6 +59,7 @@ public API(String host, int port, String user, String pass, String virtualHost,
53
59
}
54
60
55
61
_queue = queue ;
62
+ _exchange = exchange ;
56
63
}
57
64
58
65
public void sendMessage (byte [] msg , String correlationId , String messageId ) throws Exception {
@@ -64,12 +71,12 @@ public void sendMessage(byte[] msg) throws Exception {
64
71
}
65
72
66
73
public void sendMessageToQueue (String queue , byte [] msg ) throws Exception {
67
- _channel .basicPublish ("" , queue , null , msg );
74
+ _channel .basicPublish (_exchange , queue , null , msg );
68
75
}
69
76
70
77
public void sendMessageToQueue (String queue , byte [] msg , String correlationId , String messageId ) throws Exception {
71
78
AMQP .BasicProperties props = createProperties (correlationId , messageId );
72
- _channel .basicPublish ("" , queue , props , msg );
79
+ _channel .basicPublish (_exchange , queue , props , msg );
73
80
}
74
81
75
82
public byte [] readMessageStream (String [] result ) throws Exception {
0 commit comments