Skip to content

Commit 258f8b1

Browse files
committed
fix timing issue with stomp client and tx publishing
1 parent e440b2d commit 258f8b1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/main/java/io/mapsmessaging/network/protocol/impl/stomp/listener/SendListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ protected void processEvent(SessionState engine, Event event, Message message) t
4040
throw new RuntimeException(e);
4141
}
4242
return destination;
43-
});
43+
}).join();
4444
}
4545
}

src/test/java/io/mapsmessaging/network/protocol/impl/stomp/StompPublishEventTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ void testTransactionalPublishContentLength() throws Exception {
117117
start = stompSubscriber.counter.get();
118118
}
119119
}
120+
Assertions.assertEquals(10, stompSubscriber.counter.get());
120121

121122
stompConnection.begin("tx2");
122123
for (int x = 0; x < 100; x++) {
@@ -160,7 +161,7 @@ public StompSubscriber(String topicName, String hostname, int port, String usern
160161
stompConnection.open(hostname, port );
161162
stompConnection.connect(username, getPassword(username), "client-subscribe");
162163
headers = new HashMap<>();
163-
headers.put("id", "client-subscribe/"+topicName);
164+
headers.put("id", topicName);
164165
stompConnection.subscribe(topicName, "client-individual", headers);
165166
Thread t = new Thread(this);
166167
t.start();
@@ -180,12 +181,13 @@ public void run() {
180181
while (!end.get()) {
181182
try {
182183
try {
183-
StompFrame stompFrame = stompConnection.receive(100);
184+
StompFrame stompFrame = stompConnection.receive(1000);
184185
if (stompFrame.isMessage()) {
185186
stompConnection.ack(stompFrame);
186187
}
187188
counter.incrementAndGet();
188189
} catch (SocketTimeoutException e) {
190+
System.err.println("SocketTimeoutException");
189191
// ignore
190192
}
191193
} catch (Exception e) {

0 commit comments

Comments
 (0)