4
4
5
5
import java .io .IOException ;
6
6
7
- import java .nio .file .*;
8
-
7
+ import java .nio .charset .StandardCharsets ;
9
8
import java .util .Date ;
10
9
import java .util .HashMap ;
11
10
@@ -65,7 +64,6 @@ public void sendMessage(byte[] msg) throws Exception {
65
64
}
66
65
67
66
public void sendMessageToQueue (String queue , byte [] msg ) throws Exception {
68
- //log(msg);
69
67
_channel .basicPublish ("" , queue , null , msg );
70
68
}
71
69
@@ -89,7 +87,19 @@ public String[] readMessageString() throws Exception {
89
87
if (response == null ) {
90
88
// No message retrieved.
91
89
} else {
92
- result [15 ] = new String (response .getBody ());
90
+ result [15 ] = new String (response .getBody (), StandardCharsets .UTF_8 );
91
+ }
92
+ return result ;
93
+ }
94
+
95
+ public String readMessageBodyString () throws Exception {
96
+ String result ;
97
+ boolean autoAck = true ;
98
+ GetResponse response = _channel .basicGet (_queue , autoAck );
99
+ if (response == null ) {
100
+ result = "" ;
101
+ } else {
102
+ result = new String (response .getBody (), StandardCharsets .UTF_8 );
93
103
}
94
104
return result ;
95
105
}
@@ -120,18 +130,11 @@ private GetResponse readMessage(String[] msg) throws IOException {
120
130
msg [12 ] = props .getDeliveryMode () != null ? Integer .toString (props .getDeliveryMode ()) : null ;
121
131
msg [13 ] = props .getPriority () != null ? Integer .toString (props .getPriority ()) : null ;
122
132
msg [14 ] = props .getTimestamp () != null ? props .getTimestamp ().toString () : null ;
123
-
124
- //log(response.getBody());
125
133
}
126
134
return response ;
127
135
128
136
}
129
137
130
- private void log (byte [] msg ) throws IOException {
131
- Path path = Paths .get ("C:\\ InterSystems\\ java.log" );
132
- Files .write (path , msg );
133
- }
134
-
135
138
public void close ()throws Exception {
136
139
_channel .close ();
137
140
_connection .close ();
0 commit comments