public class PubSubMessageHandler
extends org.springframework.integration.handler.AbstractMessageHandler
It delegates Google Cloud Pub/Sub interaction to PubSubTemplate
.
Modifier and Type | Class and Description |
---|---|
static interface |
PubSubMessageHandler.FailureCallback
Implement this callback to post-process a message that failed to publish to Cloud Pub/Sub.
|
static interface |
PubSubMessageHandler.SuccessCallback
Implement this callback to post-process a successfully published message.
|
EXPRESSION_PARSER, logger
Constructor and Description |
---|
PubSubMessageHandler(PubSubPublisherOperations pubSubPublisherOperations,
String topic)
Instantiates an outbound adapter for publishing messages to a topic.
|
Modifier and Type | Method and Description |
---|---|
protected org.springframework.util.concurrent.ListenableFutureCallback<String> |
getPublishCallback() |
org.springframework.expression.Expression |
getPublishTimeoutExpression() |
org.springframework.expression.Expression |
getTopicExpression() |
protected void |
handleMessageInternal(org.springframework.messaging.Message<?> message) |
boolean |
isSync() |
protected void |
onInit() |
void |
setFailureCallback(PubSubMessageHandler.FailureCallback failureCallback)
Set callback (can be a lambda) for processing the root cause exception and the original
Message in case of failure. |
void |
setHeaderMapper(org.springframework.integration.mapping.HeaderMapper<Map<String,String>> headerMapper)
Set the header mapper to map headers from
Message into outbound PubsubMessage . |
void |
setPublishCallback(org.springframework.util.concurrent.ListenableFutureCallback<String> publishCallback)
|
void |
setPublishTimeout(long timeoutMillis)
Set the timeout in milliseconds for a synchronous publish call to Google Cloud Pub/Sub.
|
void |
setPublishTimeoutExpression(org.springframework.expression.Expression publishTimeoutExpression)
Set the SpEL expression to evaluate a timeout in milliseconds for a synchronous publish call to
Google Cloud Pub/Sub.
|
void |
setPublishTimeoutExpressionString(String publishTimeoutExpression)
Set the SpEL expression to evaluate a timeout in milliseconds for a synchronous publish call to
Google Cloud Pub/Sub from a string.
|
void |
setSuccessCallback(PubSubMessageHandler.SuccessCallback successCallback)
Set callback (can be a lambda) for processing the published message ID and the original
Message after the message was successfully published. |
void |
setSync(boolean sync)
Set publish method to be synchronous or asynchronous.
|
void |
setTopic(String topic)
Set the topic where this adapter sends messages to.
|
void |
setTopicExpression(org.springframework.expression.Expression topicExpression)
Set the SpEL expression for the topic this adapter sends messages to.
|
void |
setTopicExpressionString(String topicExpressionString)
Set the topic expression string that is evaluated into an actual expression.
|
handleMessage, onComplete, onError, onNext, onSubscribe
buildSendTimer, destroy, getComponentType, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public PubSubMessageHandler(PubSubPublisherOperations pubSubPublisherOperations, String topic)
pubSubPublisherOperations
- PubSubPublisherOperations
to usetopic
- short or fully qualified destination topic namepublic boolean isSync()
public void setSync(boolean sync)
Publish is asynchronous be default.
sync
- true for synchronous, false for asynchronouspublic org.springframework.expression.Expression getPublishTimeoutExpression()
public void setPublishTimeoutExpression(org.springframework.expression.Expression publishTimeoutExpression)
publishTimeoutExpression
- the Expression
for the publish timeout in millisecondspublic void setPublishTimeoutExpressionString(String publishTimeoutExpression)
publishTimeoutExpression
- a string with an expression for the publish timeout in
millisecondspublic void setPublishTimeout(long timeoutMillis)
timeoutMillis
- timeout in millisecondsprotected org.springframework.util.concurrent.ListenableFutureCallback<String> getPublishCallback()
@Deprecated public void setPublishCallback(org.springframework.util.concurrent.ListenableFutureCallback<String> publishCallback)
setSuccessCallback(com.google.cloud.spring.pubsub.integration.outbound.PubSubMessageHandler.SuccessCallback)
and setFailureCallback(com.google.cloud.spring.pubsub.integration.outbound.PubSubMessageHandler.FailureCallback)
instead.publishCallback
- callback for the publish futurepublic void setSuccessCallback(PubSubMessageHandler.SuccessCallback successCallback)
Message
after the message was successfully published.successCallback
- callback accepting a String
message ID and the original Message
.public void setFailureCallback(PubSubMessageHandler.FailureCallback failureCallback)
Message
in case of failure.failureCallback
- callback accepting a Throwable
and a Message
.public org.springframework.expression.Expression getTopicExpression()
public void setTopicExpression(org.springframework.expression.Expression topicExpression)
topicExpression
- the SpEL expression representing the topic namepublic void setTopic(String topic)
topic
- topic namepublic void setTopicExpressionString(String topicExpressionString)
topicExpressionString
- topic expression stringpublic void setHeaderMapper(org.springframework.integration.mapping.HeaderMapper<Map<String,String>> headerMapper)
Message
into outbound PubsubMessage
.headerMapper
- the header mapperprotected void handleMessageInternal(org.springframework.messaging.Message<?> message)
handleMessageInternal
in class org.springframework.integration.handler.AbstractMessageHandler
protected void onInit()
onInit
in class org.springframework.integration.context.IntegrationObjectSupport
Copyright © 2024. All rights reserved.