5
5
import java .io .IOException ;
6
6
7
7
import java .nio .file .*;
8
+
9
+ import java .util .Date ;
10
+ import java .util .HashMap ;
11
+
8
12
/**
9
13
* Created by eduard on 06.10.2017.
10
14
*/
@@ -30,6 +34,10 @@ public API(String host, int port, String user, String pass, String virtualHost,
30
34
_queue = queue ;
31
35
}
32
36
37
+ public void sendMessage (byte [] msg , String correlationId , String messageId ) throws Exception {
38
+ sendMessageToQueue (_queue , msg , correlationId , messageId );
39
+ }
40
+
33
41
public void sendMessage (byte [] msg ) throws Exception {
34
42
sendMessageToQueue (_queue , msg );
35
43
}
@@ -39,6 +47,11 @@ public void sendMessageToQueue(String queue, byte[] msg) throws Exception {
39
47
_channel .basicPublish ("" , queue , null , msg );
40
48
}
41
49
50
+ public void sendMessageToQueue (String queue , byte [] msg , String correlationId , String messageId ) throws Exception {
51
+ AMQP .BasicProperties props = createProperties (correlationId , messageId );
52
+ _channel .basicPublish ("" , queue , props , msg );
53
+ }
54
+
42
55
public byte [] readMessageStream (String [] result ) throws Exception {
43
56
GetResponse response = readMessage (result );
44
57
if (response == null ) {
@@ -102,4 +115,24 @@ public void close()throws Exception {
102
115
_connection .close ();
103
116
}
104
117
118
+ private AMQP .BasicProperties createProperties (String correlationId , String messageId ) throws Exception
119
+ {
120
+ String contentType = null ;
121
+ String contentEncoding = null ;
122
+ HashMap <String , Object > headers = null ;
123
+ Integer deliveryMode = null ;
124
+ Integer priority = null ;
125
+ //String correlationId= null;
126
+ String replyTo = null ;
127
+ String expiration = null ;
128
+ //String messageId= null;
129
+ Date timestamp = null ;
130
+ String type = null ;
131
+ String userId = null ;
132
+ String appId = null ;
133
+ String clusterId = null ;
134
+ AMQP .BasicProperties props = new AMQP .BasicProperties (contentType , contentEncoding , headers , deliveryMode , priority , correlationId , replyTo , expiration , messageId , timestamp , type , userId , appId , clusterId );
135
+ return props ;
136
+ }
137
+
105
138
}
0 commit comments