Class FromCloudEventTransformer
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.transformer.AbstractTransformer
org.springframework.integration.cloudevents.transformer.FromCloudEventTransformer
- All Implemented Interfaces:
Aware,BeanFactoryAware,BeanNameAware,InitializingBean,ApplicationContextAware,ComponentSourceAware,ExpressionCapable,GenericTransformer<Message<?>, Message<?>>,NamedComponent,Transformer
Transform
CloudEvent format messages to Spring Integration messages.
This transformer supports two payload types:
CloudEventObject Type: When the message payload is aCloudEventinstance, the transformer extracts theCloudEventdata from the message payload and mapsCloudEventattributes to message headers usingCloudEventHeadersconstants.CloudEventextensions are also mapped to message headers with the "ce-" prefix.- Serialized
CloudEventType: When the message payload is abyte[]containing a serializedCloudEvent(e.g., JSON, XML), the transformer uses theMessageHeaders.CONTENT_TYPEheader to resolve anEventFormatviaEventFormatProvider. If theEventFormatis not found from theMessageHeaders.CONTENT_TYPEor if the message does not containMessageHeaders.CONTENT_TYPEthen it will fall back to thesetEventFormat(EventFormat). TheCloudEventis then deserialized, and the data is extracted from theCloudEventwith its attributes mapped to headers.
- Since:
- 7.1
- Author:
- Glenn Renfro, Artem Bilan
- See Also:
-
Field Summary
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectdoTransform(Message<?> message) Subclasses must implement this method to provide the transformation logic.voidsetEventFormat(io.cloudevents.core.format.EventFormat eventFormat) Establish theEventFormatthat will be used if theEventFormatProvidercan not identify theEventFormatfor theMessageHeaders.CONTENT_TYPEor the message does not contain aMessageHeaders.CONTENT_TYPE.Methods inherited from class org.springframework.integration.transformer.AbstractTransformer
transformMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, onInit, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
-
Constructor Details
-
FromCloudEventTransformer
public FromCloudEventTransformer()
-
-
Method Details
-
setEventFormat
public void setEventFormat(io.cloudevents.core.format.EventFormat eventFormat) Establish theEventFormatthat will be used if theEventFormatProvidercan not identify theEventFormatfor theMessageHeaders.CONTENT_TYPEor the message does not contain aMessageHeaders.CONTENT_TYPE.- Parameters:
eventFormat- The fallbackEventFormatto use ifEventFormatProvidercan not identify theEventFormatfor the payload.
-
getComponentType
-
doTransform
Description copied from class:AbstractTransformerSubclasses must implement this method to provide the transformation logic. If the return value is itself a Message, it will be used as the result. Otherwise, any non-null return value will be used as the payload of the result Message.- Specified by:
doTransformin classAbstractTransformer- Parameters:
message- The message.- Returns:
- The result of the transformation.
-