File tree Expand file tree Collapse file tree 4 files changed +24
-6
lines changed
main/java/org/apache/beam/sdk/io/solace/broker
test/java/org/apache/beam/sdk/io/solace Expand file tree Collapse file tree 4 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ public class BasicAuthJcsmpSessionService extends SessionService {
46
46
private final String password ;
47
47
private final String vpnName ;
48
48
@ Nullable private JCSMPSession jcsmpSession ;
49
+ @ Nullable private MessageReceiver messageReceiver ;
49
50
private final RetryCallableManager retryCallableManager = RetryCallableManager .create ();
50
51
51
52
/**
@@ -73,21 +74,25 @@ public void connect() {
73
74
74
75
@ Override
75
76
public void close () {
76
- if (isClosed ()) {
77
- return ;
78
- }
79
77
retryCallableManager .retryCallable (
80
78
() -> {
81
- checkStateNotNull (jcsmpSession ).closeSession ();
79
+ if (messageReceiver != null ) {
80
+ messageReceiver .close ();
81
+ }
82
+ if (!isClosed ()) {
83
+ checkStateNotNull (jcsmpSession ).closeSession ();
84
+ }
82
85
return 0 ;
83
86
},
84
87
ImmutableSet .of (IOException .class ));
85
88
}
86
89
87
90
@ Override
88
91
public MessageReceiver createReceiver () {
89
- return retryCallableManager .retryCallable (
90
- this ::createFlowReceiver , ImmutableSet .of (JCSMPException .class ));
92
+ this .messageReceiver =
93
+ retryCallableManager .retryCallable (
94
+ this ::createFlowReceiver , ImmutableSet .of (JCSMPException .class ));
95
+ return this .messageReceiver ;
91
96
}
92
97
93
98
@ Override
Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ public interface MessageReceiver {
49
49
*/
50
50
BytesXMLMessage receive () throws IOException ;
51
51
52
+ /** Closes the message receiver. */
53
+ void close ();
54
+
52
55
/**
53
56
* Test clients may return {@literal true} to signal that all expected messages have been pulled
54
57
* and the test may complete. Real clients should always return {@literal false}.
Original file line number Diff line number Diff line change @@ -69,4 +69,11 @@ public BytesXMLMessage receive() throws IOException {
69
69
throw new IOException (e );
70
70
}
71
71
}
72
+
73
+ @ Override
74
+ public void close () {
75
+ if (!isClosed ()) {
76
+ this .flowReceiver .close ();
77
+ }
78
+ }
72
79
}
Original file line number Diff line number Diff line change @@ -92,6 +92,9 @@ public BytesXMLMessage receive() throws IOException {
92
92
return getRecordFn .apply (counter .getAndIncrement ());
93
93
}
94
94
95
+ @ Override
96
+ public void close () {}
97
+
95
98
@ Override
96
99
public boolean isEOF () {
97
100
return counter .get () >= minMessagesReceived ;
You can’t perform that action at this time.
0 commit comments