Skip to content

Commit

Permalink
Clean up of RMI in the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
artembilan committed Feb 4, 2022
1 parent 05e31b9 commit 09ab0af
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 185 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,8 +18,10 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.awaitility.Awaitility.await;
import static org.mockito.Mockito.mock;

import java.time.Duration;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
Expand Down Expand Up @@ -78,13 +80,13 @@ public class DelayHandlerTests {

private final CountDownLatch latch = new CountDownLatch(1);

private ThreadPoolTaskScheduler taskScheduler;
private final ResultHandler resultHandler = new ResultHandler();

private DelayHandler delayHandler;
private final TestApplicationContext context = TestUtils.createTestApplicationContext();

private final ResultHandler resultHandler = new ResultHandler();
private ThreadPoolTaskScheduler taskScheduler;

private TestApplicationContext context = TestUtils.createTestApplicationContext();
private DelayHandler delayHandler;

@BeforeEach
public void setup() {
Expand Down Expand Up @@ -172,7 +174,7 @@ else if (deliveries == 3) {
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
Thread.sleep(50);
assertThat(count.get()).isEqualTo(4);
assertThat(TestUtils.getPropertyValue(this.delayHandler, "deliveries", Map.class).size()).isEqualTo(0);
assertThat(TestUtils.getPropertyValue(this.delayHandler, "deliveries", Map.class)).hasSize(0);
}

@Test
Expand Down Expand Up @@ -343,10 +345,10 @@ public void errorChannelHeaderAndHandlerThrowsExceptionWithDelay() {
input.send(message);
waitForLatch(10000);
Message<?> errorMessage = resultHandler.lastMessage;
assertThat(errorMessage.getPayload().getClass()).isEqualTo(MessageDeliveryException.class);
assertThat(errorMessage.getPayload()).isInstanceOf(MessageDeliveryException.class);
MessageDeliveryException exceptionPayload = (MessageDeliveryException) errorMessage.getPayload();
assertThat(exceptionPayload.getFailedMessage().getPayload()).isSameAs(message.getPayload());
assertThat(exceptionPayload.getCause().getClass()).isEqualTo(UnsupportedOperationException.class);
assertThat(exceptionPayload.getCause()).isInstanceOf(UnsupportedOperationException.class);
assertThat(resultHandler.lastThread).isNotSameAs(Thread.currentThread());
}

Expand Down Expand Up @@ -375,10 +377,10 @@ public void errorChannelNameHeaderAndHandlerThrowsExceptionWithDelay() {
input.send(message);
waitForLatch(10000);
Message<?> errorMessage = resultHandler.lastMessage;
assertThat(errorMessage.getPayload().getClass()).isEqualTo(MessageDeliveryException.class);
assertThat(errorMessage.getPayload()).isInstanceOf(MessageDeliveryException.class);
MessageDeliveryException exceptionPayload = (MessageDeliveryException) errorMessage.getPayload();
assertThat(exceptionPayload.getFailedMessage().getPayload()).isSameAs(message.getPayload());
assertThat(exceptionPayload.getCause().getClass()).isEqualTo(UnsupportedOperationException.class);
assertThat(exceptionPayload.getCause()).isInstanceOf(UnsupportedOperationException.class);
assertThat(resultHandler.lastThread).isNotSameAs(Thread.currentThread());
}

Expand All @@ -405,10 +407,10 @@ public void defaultErrorChannelAndHandlerThrowsExceptionWithDelay() {
input.send(message);
waitForLatch(10000);
Message<?> errorMessage = resultHandler.lastMessage;
assertThat(errorMessage.getPayload().getClass()).isEqualTo(MessageDeliveryException.class);
assertThat(errorMessage.getPayload()).isInstanceOf(MessageDeliveryException.class);
MessageDeliveryException exceptionPayload = (MessageDeliveryException) errorMessage.getPayload();
assertThat(exceptionPayload.getFailedMessage().getPayload()).isSameAs(message.getPayload());
assertThat(exceptionPayload.getCause().getClass()).isEqualTo(UnsupportedOperationException.class);
assertThat(exceptionPayload.getCause()).isInstanceOf(UnsupportedOperationException.class);
assertThat(resultHandler.lastThread).isNotSameAs(Thread.currentThread());
}

Expand Down Expand Up @@ -497,7 +499,7 @@ public void testRescheduleAndHandleAtTheSameTime() {
}

@Test
public void testRescheduleForTheDateDelay() throws Exception {
public void testRescheduleForTheDateDelay() {
this.delayHandler.setDelayExpression(new SpelExpressionParser().parseExpression("payload"));
this.delayHandler.setOutputChannel(new DirectChannel());
this.delayHandler.setIgnoreExpressionFailures(false);
Expand All @@ -522,11 +524,11 @@ public void testRescheduleForTheDateDelay() throws Exception {
this.taskScheduler.afterPropertiesSet();
this.delayHandler.reschedulePersistedMessages();
Queue<?> works = ((ScheduledThreadPoolExecutor) this.taskScheduler.getScheduledExecutor()).getQueue();
int n = 0;
while (n++ < 2000 && works.size() == 0) {
Thread.sleep(10);
}
assertThat(works.size()).isEqualTo(1);

await()
.atMost(Duration.ofSeconds(20))
.pollDelay(Duration.ofMillis(10))
.until(() -> works.size() == 1);
}


Expand Down
3 changes: 0 additions & 3 deletions src/reference/asciidoc/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ For example, the following root element shows several of these namespace declara
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
xmlns:int-rmi="http://www.springframework.org/schema/integration/rmi"
xmlns:int-ws="http://www.springframework.org/schema/integration/ws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
Expand All @@ -86,8 +85,6 @@ For example, the following root element shows several of these namespace declara
https://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/integration/mail
https://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
http://www.springframework.org/schema/integration/rmi
https://www.springframework.org/schema/integration/rmi/spring-integration-rmi.xsd
http://www.springframework.org/schema/integration/ws
https://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd">
...
Expand Down
1 change: 0 additions & 1 deletion src/reference/asciidoc/gateway.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ It lets you configure an interface as a service, as the following example shows:
====

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.
The general approach is similar to that of Spring Remoting (RMI, HttpInvoker, and so on).
See the <<./samples.adoc#samples,"`Samples`">> Appendix for an example that uses the `gateway` element (in the Cafe demo).

The defaults in the preceding configuration are applied to all methods on the gateway interface.
Expand Down
19 changes: 9 additions & 10 deletions src/reference/asciidoc/handler-advice.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The schema does not allow a `<request-handler-advice-chain>` as a child element
However, a `<request-handler-advice-chain>` can be added to individual reply-producing endpoints within a `<chain>` element.
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.
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).
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).
The adapter can then be advised as usual.
For chains that produce a reply, every child element can be advised.
=====
Expand Down Expand Up @@ -247,7 +247,7 @@ A `<handler-retry-advice>` with no child element uses no back off.
If there is no `recovery-channel`, the exception is thrown when retries are exhausted.
The namespace can only be used with stateless retry.
+
For more complex environments (custom policies etc), use normal `<bean>` definitions.
For more complex environments (custom policies etc.), use normal `<bean>` definitions.

Simple Stateful Retry with Recovery::
To make retry stateful, we need to provide the advice with a `RetryStateGenerator` implementation.
Expand Down Expand Up @@ -324,7 +324,7 @@ The default configuration retries for all exceptions and the exception classifie
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.
+
Since Spring Retry 1.0.3, the `BinaryExceptionClassifier` has a property called `traverseCauses` (the default is `false`).
When `true`, it traverses exception causes until it finds a match or runs out of causes to traverse.
When `true`, it traverses exception causes until it finds a match or runs out of causes traversing.
+
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.
Then you can inject this policy into the `RetryTemplate`.
Expand Down Expand Up @@ -692,17 +692,16 @@ For example, a `RetryOperationsInterceptor` could be applied to the whole sub-fl
==== Transaction Support

Starting with version 5.0, a new `TransactionHandleMessageAdvice` has been introduced to make the whole downstream flow transactional, thanks to the `HandleMessageAdvice` implementation.
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.
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.

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.
The following example shows `<transactional>` in use:

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

[[advice-order]]
==== Ordering Advices within an Advice Chain
==== Ordering Advices within Advice Chain

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

For example, suppose you want to add a retry advice and a transaction advice.
You may want to place the retry advice advice first, followed by the transaction advice.
You may want to place the retry advice first, followed by the transaction advice.
Consequently, each retry is performed in a new transaction.
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.

Expand Down
1 change: 0 additions & 1 deletion src/reference/asciidoc/overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ The affected modules are
* `http`
* `jms`
* `mail`
* `rmi`
* `security`
* `stream`
* `ws`
Expand Down
151 changes: 0 additions & 151 deletions src/reference/asciidoc/rmi.adoc

This file was deleted.

2 changes: 1 addition & 1 deletion src/reference/asciidoc/whats-new.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you are interested in the changes and features that were introduced in earlie

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

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

[[x6.0-new-components]]
=== New Components
Expand Down

0 comments on commit 09ab0af

Please sign in to comment.