INT-4157: Migrate JMS DSL

JIRA: https://jira.spring.io/browse/INT-4157

- Refactor the core message-driven endpoint to be `MessageProducerSupport`, eliminating the DSL wrapper
- Retain and refactor the DSL gateway wrapper - still required because it needs to be a MGS
- Port the (core) `Channels` factory

Fix Javadoc

Remove Deprecated setter

Move JmsInboundGateway to the jms Package

* Some polishing for `@Copyright`s
* Remove `@Deprecated` methods in the `Jms`
* Reinstate `IntegrationFlows.from(Function<Channels, MessageChannelSpec<?, ?>>)`
* Typos fixes in the `JmsTests`
This commit is contained in:
Gary Russell
2016-11-02 18:17:20 -04:00
committed by Artem Bilan
parent e0b0c29ce1
commit cfceca8518
21 changed files with 3184 additions and 4 deletions

View File

@@ -0,0 +1,136 @@
/*
* Copyright 2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.dsl;
import java.util.Queue;
import java.util.concurrent.Executor;
import org.springframework.integration.dsl.channel.DirectChannelSpec;
import org.springframework.integration.dsl.channel.ExecutorChannelSpec;
import org.springframework.integration.dsl.channel.MessageChannels;
import org.springframework.integration.dsl.channel.PriorityChannelSpec;
import org.springframework.integration.dsl.channel.PublishSubscribeChannelSpec;
import org.springframework.integration.dsl.channel.QueueChannelSpec;
import org.springframework.integration.dsl.channel.RendezvousChannelSpec;
import org.springframework.integration.store.ChannelMessageStore;
import org.springframework.integration.store.PriorityCapableChannelMessageStore;
import org.springframework.messaging.Message;
/**
* @author Artem Bilan
* @author Gary Russell
*
* @since 5.0
*/
public class Channels {
public DirectChannelSpec direct() {
return MessageChannels.direct();
}
public DirectChannelSpec direct(String id) {
return MessageChannels.direct(id);
}
public QueueChannelSpec queue() {
return MessageChannels.queue();
}
public QueueChannelSpec queue(String id) {
return MessageChannels.queue(id);
}
public QueueChannelSpec queue(Integer capacity) {
return MessageChannels.queue(capacity);
}
public QueueChannelSpec queue(String id, Integer capacity) {
return MessageChannels.queue(id, capacity);
}
public QueueChannelSpec queue(Queue<Message<?>> queue) {
return MessageChannels.queue(queue);
}
public QueueChannelSpec queue(String id, Queue<Message<?>> queue) {
return MessageChannels.queue(id, queue);
}
public QueueChannelSpec.MessageStoreSpec queue(ChannelMessageStore messageGroupStore, Object groupId) {
return MessageChannels.queue(messageGroupStore, groupId);
}
public QueueChannelSpec.MessageStoreSpec queue(String id, ChannelMessageStore messageGroupStore, Object groupId) {
return MessageChannels.queue(id, messageGroupStore, groupId);
}
public PriorityChannelSpec priority() {
return MessageChannels.priority();
}
public PriorityChannelSpec priority(String id) {
return MessageChannels.priority(id);
}
public QueueChannelSpec.MessageStoreSpec priority(String id, PriorityCapableChannelMessageStore messageGroupStore,
Object groupId) {
return MessageChannels.priority(id, messageGroupStore, groupId);
}
public QueueChannelSpec.MessageStoreSpec priority(PriorityCapableChannelMessageStore messageGroupStore,
Object groupId) {
return MessageChannels.priority(messageGroupStore, groupId);
}
public RendezvousChannelSpec rendezvous() {
return MessageChannels.rendezvous();
}
public RendezvousChannelSpec rendezvous(String id) {
return MessageChannels.rendezvous(id);
}
public PublishSubscribeChannelSpec<? extends PublishSubscribeChannelSpec<?>> publishSubscribe() {
return MessageChannels.publishSubscribe();
}
public PublishSubscribeChannelSpec<? extends PublishSubscribeChannelSpec<?>> publishSubscribe(Executor executor) {
return MessageChannels.publishSubscribe(executor);
}
public PublishSubscribeChannelSpec<? extends PublishSubscribeChannelSpec<?>> publishSubscribe(String id,
Executor executor) {
return MessageChannels.publishSubscribe(id, executor);
}
public PublishSubscribeChannelSpec<? extends PublishSubscribeChannelSpec<?>> publishSubscribe(String id) {
return MessageChannels.publishSubscribe(id);
}
public ExecutorChannelSpec executor(Executor executor) {
return MessageChannels.executor(executor);
}
public ExecutorChannelSpec executor(String id, Executor executor) {
return MessageChannels.executor(id, executor);
}
Channels() {
super();
}
}

View File

@@ -212,6 +212,18 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
return registerOutputChannelIfCan(this.currentMessageChannel);
}
/**
* Populate a {@link MessageChannel} instance
* at the current {@link IntegrationFlow} chain position using the {@link Channels}
* factory fluent API.
* @param channels the {@link Function} to use.
* @return the current {@link IntegrationFlowDefinition}.
*/
public B channel(Function<Channels, MessageChannelSpec<?, ?>> channels) {
Assert.notNull(channels);
return channel(channels.apply(new Channels()));
}
/**
* The {@link org.springframework.integration.channel.PublishSubscribeChannel} {@link #channel}
* method specific implementation to allow the use of the 'subflow' subscriber capability.

View File

@@ -17,6 +17,7 @@
package org.springframework.integration.dsl;
import java.util.function.Consumer;
import java.util.function.Function;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.MessageSource;
@@ -74,6 +75,20 @@ public final class IntegrationFlows {
: from(messageChannelName);
}
/**
* Populate the {@link MessageChannel} object to the
* {@link IntegrationFlowBuilder} chain using the fluent API from {@link Channels} factory.
* The {@link org.springframework.integration.dsl.IntegrationFlow} {@code inputChannel}.
* @param channels the {@link Function} to use method chain to configure.
* {@link MessageChannel} via {@link Channels} factory.
* @return new {@link IntegrationFlowBuilder}.
* @see Channels
*/
public static IntegrationFlowBuilder from(Function<Channels, MessageChannelSpec<?, ?>> channels) {
Assert.notNull(channels);
return from(channels.apply(new Channels()));
}
/**
* Populate the {@link MessageChannel} object to the
* {@link IntegrationFlowBuilder} chain using the fluent API from {@link MessageChannelSpec}.

View File

@@ -242,7 +242,7 @@ public class CorrelationHandlerTests {
@Bean
@DependsOn("barrierFlow")
public IntegrationFlow releaseBarrierFlow(MessageTriggerAction barrierTriggerAction) {
return IntegrationFlows.from(MessageChannels.queue("releaseChannel"))
return IntegrationFlows.from(c -> c.queue("releaseChannel"))
.trigger(barrierTriggerAction,
e -> e.poller(p -> p.fixedDelay(100)))
.get();