Skip to content

Commit

Permalink
Merge pull request #47 from zapek/json-dependency-clarification
Browse files Browse the repository at this point in the history
Clarify the addition of the JSON dependency
  • Loading branch information
Buzzardo authored Jul 23, 2024
2 parents e7d19ac + 8640bfc commit 836a52a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/

For clarity, we have also defined a `myFactory` bean that is referenced in the `JmsListener` annotation of the receiver. Because we use the `DefaultJmsListenerContainerFactoryConfigurer` infrastructure provided by Spring Boot, that `JmsMessageListenerContainer` is identical to the one that Spring Boot creates by default.

The default `MessageConverter` can convert only basic types (such as `String`, `Map`, `Serializable`), and our `Email` is not `Serializable` on purpose. We want to use Jackson and serialize the content to JSON in text format (that is, as a `TextMessage`). Spring Boot detects the presence of a `MessageConverter` and associates it to both the default `JmsTemplate` and any `JmsListenerContainerFactory` created by `DefaultJmsListenerContainerFactoryConfigurer`. Our JSON converter needs the `spring-boot-starter-json` dependency.
The default `MessageConverter` can convert only basic types (such as `String`, `Map`, `Serializable`), and our `Email` is not `Serializable` on purpose. We want to use Jackson and serialize the content to JSON in text format (that is, as a `TextMessage`). Spring Boot detects the presence of a `MessageConverter` and associates it to both the default `JmsTemplate` and any `JmsListenerContainerFactory` created by `DefaultJmsListenerContainerFactoryConfigurer`. Our JSON converter needs the following dependency: `org.springframework.boot:spring-boot-starter-json`.

`JmsTemplate` makes it simple to send messages to a JMS destination. In the `main` runner method, after starting things up, you can use `jmsTemplate` to send an `Email` POJO. Because our custom `MessageConverter` has been automatically associated to it, a JSON document is generated in a `TextMessage` only.

Expand Down

0 comments on commit 836a52a

Please sign in to comment.