-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-3626: RabbitMQ Stream Support #3895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../src/main/java/org/springframework/integration/amqp/dsl/MessageListenerContainerSpec.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://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.amqp.dsl; | ||
|
||
import org.springframework.amqp.rabbit.listener.MessageListenerContainer; | ||
import org.springframework.integration.dsl.IntegrationComponentSpec; | ||
|
||
/** | ||
* Base class for container specs. | ||
* | ||
* @param <S> the current spec extension type | ||
* @param <C> the listener container type | ||
* | ||
* @author Gary Russell | ||
* | ||
* @since 6.0 | ||
* | ||
*/ | ||
public abstract class MessageListenerContainerSpec<S extends MessageListenerContainerSpec<S, C>, | ||
C extends MessageListenerContainer> | ||
extends IntegrationComponentSpec<S, C> { | ||
|
||
/** | ||
* Set the queue names. | ||
* @param queueNames the queue names. | ||
* @return this spec. | ||
*/ | ||
public S queueName(String... queueNames) { | ||
this.target.setQueueNames(queueNames); | ||
return _this(); | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
...ain/java/org/springframework/integration/amqp/dsl/RabbitInboundChannelAdapterSLCSpec.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2017-2020 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 | ||
* | ||
* https://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.amqp.dsl; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer; | ||
import org.springframework.lang.Nullable; | ||
import org.springframework.rabbit.stream.listener.StreamListenerContainer; | ||
|
||
import com.rabbitmq.stream.Codec; | ||
import com.rabbitmq.stream.Environment; | ||
|
||
/** | ||
* Spec for an inbound channel adapter with a {@link DirectMessageListenerContainer}. | ||
garyrussell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* @author Gary Russell | ||
* @author Artem Bilan | ||
* | ||
* @since 6.0 | ||
* | ||
*/ | ||
public class RabbitInboundChannelAdapterSLCSpec | ||
extends AmqpInboundChannelAdapterSpec<RabbitInboundChannelAdapterSLCSpec, StreamListenerContainer> { | ||
garyrussell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
protected RabbitInboundChannelAdapterSLCSpec(StreamListenerContainer listenerContainer) { | ||
super(new RabbitStreamMessageListenerContainerSpec(listenerContainer)); | ||
} | ||
|
||
protected RabbitInboundChannelAdapterSLCSpec(Environment environment, @Nullable Codec codec) { | ||
super(new RabbitStreamMessageListenerContainerSpec(environment, codec)); | ||
} | ||
|
||
public RabbitInboundChannelAdapterSLCSpec configureContainer( | ||
Consumer<RabbitStreamMessageListenerContainerSpec> configurer) { | ||
|
||
configurer.accept((RabbitStreamMessageListenerContainerSpec) this.listenerContainerSpec); | ||
return this; | ||
} | ||
|
||
} |
114 changes: 114 additions & 0 deletions
114
...rc/main/java/org/springframework/integration/amqp/dsl/RabbitStreamMessageHandlerSpec.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright 2016-2020 the original author or authors. | ||
garyrussell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* 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 | ||
* | ||
* https://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.amqp.dsl; | ||
|
||
import org.springframework.integration.amqp.outbound.AbstractAmqpOutboundEndpoint; | ||
import org.springframework.integration.amqp.outbound.RabbitStreamMessageHandler; | ||
import org.springframework.integration.amqp.support.AmqpHeaderMapper; | ||
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper; | ||
import org.springframework.integration.dsl.MessageHandlerSpec; | ||
import org.springframework.rabbit.stream.producer.RabbitStreamOperations; | ||
|
||
/** | ||
* The base {@link MessageHandlerSpec} for {@link AbstractAmqpOutboundEndpoint}s. | ||
garyrussell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* @author Gary Russell | ||
* | ||
* @since 6.0 | ||
*/ | ||
public class RabbitStreamMessageHandlerSpec | ||
extends MessageHandlerSpec<RabbitStreamMessageHandlerSpec, RabbitStreamMessageHandler> { | ||
|
||
private final DefaultAmqpHeaderMapper headerMapper = DefaultAmqpHeaderMapper.outboundMapper(); | ||
|
||
RabbitStreamMessageHandlerSpec(RabbitStreamOperations operations) { | ||
this.target = new RabbitStreamMessageHandler(operations); | ||
} | ||
|
||
/** | ||
* Set a custom {@link AmqpHeaderMapper} for mapping request and reply headers. | ||
* @param headerMapper the {@link AmqpHeaderMapper} to use. | ||
* @return the spec | ||
*/ | ||
public RabbitStreamMessageHandlerSpec headerMapper(AmqpHeaderMapper headerMapper) { | ||
this.target.setHeaderMapper(headerMapper); | ||
return this; | ||
} | ||
|
||
/** | ||
* Provide the header names that should be mapped from a request to a | ||
* {@link org.springframework.messaging.MessageHeaders}. | ||
* @param headers The request header names. | ||
* @return the spec | ||
*/ | ||
public RabbitStreamMessageHandlerSpec mappedRequestHeaders(String... headers) { | ||
this.headerMapper.setRequestHeaderNames(headers); | ||
return this; | ||
} | ||
|
||
/** | ||
* Determine whether the headers are | ||
* mapped before the message is converted, or afterwards. | ||
* @param headersLast true to map headers last. | ||
* @return the spec. | ||
* @see AbstractAmqpOutboundEndpoint#setHeadersMappedLast(boolean) | ||
*/ | ||
public RabbitStreamMessageHandlerSpec headersMappedLast(boolean headersLast) { | ||
this.target.setHeadersMappedLast(headersLast); | ||
return this; | ||
} | ||
|
||
/** | ||
* Set a callback to be invoked when a send is successful. | ||
* @param callback the callback. | ||
*/ | ||
public RabbitStreamMessageHandlerSpec successCallback(RabbitStreamMessageHandler.SuccessCallback callback) { | ||
this.target.setSuccessCallback(callback); | ||
return this; | ||
} | ||
|
||
/** | ||
* Set a callback to be invoked when a send fails. | ||
* @param callback the callback. | ||
*/ | ||
public RabbitStreamMessageHandlerSpec failureCallback(RabbitStreamMessageHandler.FailureCallback callback) { | ||
this.target.setFailureCallback(callback); | ||
return this; | ||
} | ||
|
||
/** | ||
* Set to true to wait for a confirmation. | ||
* @param sync true to wait. | ||
* @see #setConfirmTimeout(long) | ||
*/ | ||
public RabbitStreamMessageHandlerSpec sync(boolean sync) { | ||
this.target.setSync(sync); | ||
return this; | ||
} | ||
|
||
/** | ||
* Set a timeout for the confirm result. | ||
* @param timeout the approximate timeout. | ||
* @return the spec. | ||
* @see #sync(boolean) | ||
*/ | ||
public RabbitStreamMessageHandlerSpec confirmTimeout(long timeout) { | ||
this.target.setConfirmTimeout(timeout); | ||
return this; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.