-
-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable SqsMessagingMessageConverter to handle JSON Strings with JSON …
…Mime Type (#1195) * Enable SqsMessagingMessageConverter to handle JSON strings configured with the Application_JSON header * Polishing Closes #1144 --------- Co-authored-by: daniel kim <daniel.d.kim@polarissharetech.com>
- Loading branch information
1 parent
8581ffa
commit 57e94c2
Showing
6 changed files
with
111 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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
35 changes: 35 additions & 0 deletions
35
...ain/java/io/awspring/cloud/sqs/support/converter/SimpleClassMatchingMessageConverter.java
This file contains 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,35 @@ | ||
package io.awspring.cloud.sqs.support.converter; | ||
|
||
import org.springframework.lang.Nullable; | ||
import org.springframework.messaging.Message; | ||
import org.springframework.messaging.MessageHeaders; | ||
import org.springframework.messaging.converter.AbstractMessageConverter; | ||
import org.springframework.messaging.converter.SmartMessageConverter; | ||
|
||
/** | ||
* {@link SmartMessageConverter} implementation that returns the payload unchanged if the target class | ||
* for Serialization / Deserialization matches the payload class. | ||
* | ||
* @author Tomaz Fernandes | ||
* @since 3.3 | ||
*/ | ||
public class SimpleClassMatchingMessageConverter extends AbstractMessageConverter { | ||
|
||
@Override | ||
protected boolean supports(Class<?> clazz) { | ||
return true; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
protected Object convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) { | ||
Object payload = message.getPayload(); | ||
return payload.getClass().isAssignableFrom(targetClass) ? payload : null; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { | ||
return payload.getClass().isAssignableFrom(getSerializedPayloadClass()) ? payload : null; | ||
} | ||
} |
This file contains 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 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 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