Skip to content

Commit 09ab0af

Browse files
committed
Clean up of RMI in the docs
1 parent 05e31b9 commit 09ab0af

File tree

7 files changed

+30
-185
lines changed

7 files changed

+30
-185
lines changed

spring-integration-core/src/test/java/org/springframework/integration/handler/DelayHandlerTests.java

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,8 +18,10 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
21+
import static org.awaitility.Awaitility.await;
2122
import static org.mockito.Mockito.mock;
2223

24+
import java.time.Duration;
2325
import java.util.Calendar;
2426
import java.util.Date;
2527
import java.util.Map;
@@ -78,13 +80,13 @@ public class DelayHandlerTests {
7880

7981
private final CountDownLatch latch = new CountDownLatch(1);
8082

81-
private ThreadPoolTaskScheduler taskScheduler;
83+
private final ResultHandler resultHandler = new ResultHandler();
8284

83-
private DelayHandler delayHandler;
85+
private final TestApplicationContext context = TestUtils.createTestApplicationContext();
8486

85-
private final ResultHandler resultHandler = new ResultHandler();
87+
private ThreadPoolTaskScheduler taskScheduler;
8688

87-
private TestApplicationContext context = TestUtils.createTestApplicationContext();
89+
private DelayHandler delayHandler;
8890

8991
@BeforeEach
9092
public void setup() {
@@ -172,7 +174,7 @@ else if (deliveries == 3) {
172174
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
173175
Thread.sleep(50);
174176
assertThat(count.get()).isEqualTo(4);
175-
assertThat(TestUtils.getPropertyValue(this.delayHandler, "deliveries", Map.class).size()).isEqualTo(0);
177+
assertThat(TestUtils.getPropertyValue(this.delayHandler, "deliveries", Map.class)).hasSize(0);
176178
}
177179

178180
@Test
@@ -343,10 +345,10 @@ public void errorChannelHeaderAndHandlerThrowsExceptionWithDelay() {
343345
input.send(message);
344346
waitForLatch(10000);
345347
Message<?> errorMessage = resultHandler.lastMessage;
346-
assertThat(errorMessage.getPayload().getClass()).isEqualTo(MessageDeliveryException.class);
348+
assertThat(errorMessage.getPayload()).isInstanceOf(MessageDeliveryException.class);
347349
MessageDeliveryException exceptionPayload = (MessageDeliveryException) errorMessage.getPayload();
348350
assertThat(exceptionPayload.getFailedMessage().getPayload()).isSameAs(message.getPayload());
349-
assertThat(exceptionPayload.getCause().getClass()).isEqualTo(UnsupportedOperationException.class);
351+
assertThat(exceptionPayload.getCause()).isInstanceOf(UnsupportedOperationException.class);
350352
assertThat(resultHandler.lastThread).isNotSameAs(Thread.currentThread());
351353
}
352354

@@ -375,10 +377,10 @@ public void errorChannelNameHeaderAndHandlerThrowsExceptionWithDelay() {
375377
input.send(message);
376378
waitForLatch(10000);
377379
Message<?> errorMessage = resultHandler.lastMessage;
378-
assertThat(errorMessage.getPayload().getClass()).isEqualTo(MessageDeliveryException.class);
380+
assertThat(errorMessage.getPayload()).isInstanceOf(MessageDeliveryException.class);
379381
MessageDeliveryException exceptionPayload = (MessageDeliveryException) errorMessage.getPayload();
380382
assertThat(exceptionPayload.getFailedMessage().getPayload()).isSameAs(message.getPayload());
381-
assertThat(exceptionPayload.getCause().getClass()).isEqualTo(UnsupportedOperationException.class);
383+
assertThat(exceptionPayload.getCause()).isInstanceOf(UnsupportedOperationException.class);
382384
assertThat(resultHandler.lastThread).isNotSameAs(Thread.currentThread());
383385
}
384386

@@ -405,10 +407,10 @@ public void defaultErrorChannelAndHandlerThrowsExceptionWithDelay() {
405407
input.send(message);
406408
waitForLatch(10000);
407409
Message<?> errorMessage = resultHandler.lastMessage;
408-
assertThat(errorMessage.getPayload().getClass()).isEqualTo(MessageDeliveryException.class);
410+
assertThat(errorMessage.getPayload()).isInstanceOf(MessageDeliveryException.class);
409411
MessageDeliveryException exceptionPayload = (MessageDeliveryException) errorMessage.getPayload();
410412
assertThat(exceptionPayload.getFailedMessage().getPayload()).isSameAs(message.getPayload());
411-
assertThat(exceptionPayload.getCause().getClass()).isEqualTo(UnsupportedOperationException.class);
413+
assertThat(exceptionPayload.getCause()).isInstanceOf(UnsupportedOperationException.class);
412414
assertThat(resultHandler.lastThread).isNotSameAs(Thread.currentThread());
413415
}
414416

@@ -497,7 +499,7 @@ public void testRescheduleAndHandleAtTheSameTime() {
497499
}
498500

499501
@Test
500-
public void testRescheduleForTheDateDelay() throws Exception {
502+
public void testRescheduleForTheDateDelay() {
501503
this.delayHandler.setDelayExpression(new SpelExpressionParser().parseExpression("payload"));
502504
this.delayHandler.setOutputChannel(new DirectChannel());
503505
this.delayHandler.setIgnoreExpressionFailures(false);
@@ -522,11 +524,11 @@ public void testRescheduleForTheDateDelay() throws Exception {
522524
this.taskScheduler.afterPropertiesSet();
523525
this.delayHandler.reschedulePersistedMessages();
524526
Queue<?> works = ((ScheduledThreadPoolExecutor) this.taskScheduler.getScheduledExecutor()).getQueue();
525-
int n = 0;
526-
while (n++ < 2000 && works.size() == 0) {
527-
Thread.sleep(10);
528-
}
529-
assertThat(works.size()).isEqualTo(1);
527+
528+
await()
529+
.atMost(Duration.ofSeconds(20))
530+
.pollDelay(Duration.ofMillis(10))
531+
.until(() -> works.size() == 1);
530532
}
531533

532534

src/reference/asciidoc/configuration.adoc

-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ For example, the following root element shows several of these namespace declara
7474
xmlns:int-file="http://www.springframework.org/schema/integration/file"
7575
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
7676
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
77-
xmlns:int-rmi="http://www.springframework.org/schema/integration/rmi"
7877
xmlns:int-ws="http://www.springframework.org/schema/integration/ws"
7978
xsi:schemaLocation="http://www.springframework.org/schema/beans
8079
https://www.springframework.org/schema/beans/spring-beans.xsd
@@ -86,8 +85,6 @@ For example, the following root element shows several of these namespace declara
8685
https://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
8786
http://www.springframework.org/schema/integration/mail
8887
https://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
89-
http://www.springframework.org/schema/integration/rmi
90-
https://www.springframework.org/schema/integration/rmi/spring-integration-rmi.xsd
9188
http://www.springframework.org/schema/integration/ws
9289
https://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd">
9390
...

src/reference/asciidoc/gateway.adoc

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ It lets you configure an interface as a service, as the following example shows:
4545
====
4646

4747
With this configuration defined, the `cafeService` can now be injected into other beans, and the code that invokes the methods on that proxied instance of the `Cafe` interface has no awareness of the Spring Integration API.
48-
The general approach is similar to that of Spring Remoting (RMI, HttpInvoker, and so on).
4948
See the <<./samples.adoc#samples,"`Samples`">> Appendix for an example that uses the `gateway` element (in the Cafe demo).
5049

5150
The defaults in the preceding configuration are applied to all methods on the gateway interface.

src/reference/asciidoc/handler-advice.adoc

+9-10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The schema does not allow a `<request-handler-advice-chain>` as a child element
4141
4242
However, a `<request-handler-advice-chain>` can be added to individual reply-producing endpoints within a `<chain>` element.
4343
An exception is that, in a chain that produces no reply, because the last element in the chain is an `outbound-channel-adapter`, that last element cannot be advised.
44-
If you need to advise such an element, it must be moved outside of the chain (with the `output-channel` of the chain being the `input-channel` of the adapter).
44+
If you need to advise such an element, it must be moved outside the chain (with the `output-channel` of the chain being the `input-channel` of the adapter).
4545
The adapter can then be advised as usual.
4646
For chains that produce a reply, every child element can be advised.
4747
=====
@@ -247,7 +247,7 @@ A `<handler-retry-advice>` with no child element uses no back off.
247247
If there is no `recovery-channel`, the exception is thrown when retries are exhausted.
248248
The namespace can only be used with stateless retry.
249249
+
250-
For more complex environments (custom policies etc), use normal `<bean>` definitions.
250+
For more complex environments (custom policies etc.), use normal `<bean>` definitions.
251251

252252
Simple Stateful Retry with Recovery::
253253
To make retry stateful, we need to provide the advice with a `RetryStateGenerator` implementation.
@@ -324,7 +324,7 @@ The default configuration retries for all exceptions and the exception classifie
324324
If you configure it to, say, retry only on `MyException` and your application throws a `SomeOtherException` where the cause is a `MyException`, retry does not occur.
325325
+
326326
Since Spring Retry 1.0.3, the `BinaryExceptionClassifier` has a property called `traverseCauses` (the default is `false`).
327-
When `true`, it traverses exception causes until it finds a match or runs out of causes to traverse.
327+
When `true`, it traverses exception causes until it finds a match or runs out of causes traversing.
328328
+
329329
To use this classifier for retry, use a `SimpleRetryPolicy` created with the constructor that takes the max attempts, the `Map` of `Exception` objects, and the `traverseCauses` boolean.
330330
Then you can inject this policy into the `RetryTemplate`.
@@ -692,17 +692,16 @@ For example, a `RetryOperationsInterceptor` could be applied to the whole sub-fl
692692
==== Transaction Support
693693

694694
Starting with version 5.0, a new `TransactionHandleMessageAdvice` has been introduced to make the whole downstream flow transactional, thanks to the `HandleMessageAdvice` implementation.
695-
When a regular `TransactionInterceptor` is used in the `<request-handler-advice-chain>` element (for example, through configuring `<tx:advice>`), a started transaction is only applied only for an internal `AbstractReplyProducingMessageHandler.handleRequestMessage()` and is not propagated to the downstream flow.
695+
When a regular `TransactionInterceptor` is used in the `<request-handler-advice-chain>` element (for example, through configuring `<tx:advice>`), a started transaction is applied only for an internal `AbstractReplyProducingMessageHandler.handleRequestMessage()` and is not propagated to the downstream flow.
696696

697697
To simplify XML configuration, along with the `<request-handler-advice-chain>`, a `<transactional>` element has been added to all `<outbound-gateway>` and `<service-activator>` and related components.
698698
The following example shows `<transactional>` in use:
699699

700700
[source,xml]
701701
----
702-
<int-rmi:outbound-gateway remote-channel="foo" host="localhost"
703-
request-channel="good" reply-channel="reply" port="#{@port}">
704-
<int-rmi:transactional/>
705-
</int-rmi:outbound-gateway>
702+
<int-jdbc:outbound-gateway query="select * from things where id=:headers[id]">
703+
<int-jdbc:transactional/>
704+
</int-jdbc:outbound-gateway>
706705
707706
<bean id="transactionManager" class="org.mockito.Mockito" factory-method="mock">
708707
<constructor-arg value="org.springframework.transaction.TransactionManager"/>
@@ -798,14 +797,14 @@ public class MyAdvisedFilter {
798797
----
799798

800799
[[advice-order]]
801-
==== Ordering Advices within an Advice Chain
800+
==== Ordering Advices within Advice Chain
802801

803802
Advice classes are "`around`" advices and are applied in a nested fashion.
804803
The first advice is the outermost, while the last advice is the innermost (that is, closest to the handler being advised).
805804
It is important to put the advice classes in the correct order to achieve the functionality you desire.
806805

807806
For example, suppose you want to add a retry advice and a transaction advice.
808-
You may want to place the retry advice advice first, followed by the transaction advice.
807+
You may want to place the retry advice first, followed by the transaction advice.
809808
Consequently, each retry is performed in a new transaction.
810809
On the other hand, if you want all the attempts and any recovery operations (in the retry `RecoveryCallback`) to be scoped within the transaction, you could put the transaction advice first.
811810

src/reference/asciidoc/overview.adoc

-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ The affected modules are
569569
* `http`
570570
* `jms`
571571
* `mail`
572-
* `rmi`
573572
* `security`
574573
* `stream`
575574
* `ws`

src/reference/asciidoc/rmi.adoc

-151
This file was deleted.

src/reference/asciidoc/whats-new.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you are interested in the changes and features that were introduced in earlie
1212

1313
If you are interested in more details, see the Issue Tracker tickets that were resolved as part of the 6.0 development process.
1414

15-
In general the project has been moved to Java 17 base line and migrated from Java EE to Jakarta EE.
15+
In general the project has been moved to Java 17 baseline and migrated from Java EE to Jakarta EE.
1616

1717
[[x6.0-new-components]]
1818
=== New Components

0 commit comments

Comments
 (0)