Skip to content

Commit aa1328c

Browse files
authored
update readme and changelog (Azure#19535)
* update readme and changelog
1 parent 12b90f1 commit aa1328c

File tree

4 files changed

+83
-3
lines changed

4 files changed

+83
-3
lines changed

sdk/spring/azure-spring-boot-starter-servicebus-jms/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Release History
22

33
## 3.2.0-beta.1 (Unreleased)
4+
### Breaking Changes
5+
- Require new property of `spring.jms.servicebus.pricing-tier` to set pricing tier of Azure Service Bus. Supported values are `premium`, `standard` and `basic`.
6+
47
### New Features
58
- Enable MessageConverter bean customization.
69
- Update the underpinning JMS library for the Premium pricing tier of Service Bus to JMS 2.0.

sdk/spring/azure-spring-boot-starter-servicebus-jms/README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ public class User implements Serializable {
8787
}
8888
```
8989

90-
`Serializable` is implemented to use the `send` method in `JmsTemplate` in the Spring framework. Otherwise, a customized `MessageConverter` bean should be defined to serialize the content to json in text format. For more information about `MessageConverter`, see the official [Spring JMS starter project](https://spring.io/guides/gs/messaging-jms/).
91-
9290
#### Create a new class for the message send controller
9391

9492
1. Create a Java file named *SendController.java* in the package directory of your app. Add the following code to the new file:
@@ -182,7 +180,39 @@ public class User implements Serializable {
182180
}
183181
}
184182
```
183+
### Optional Service Bus functionality
184+
A customized `MessageConverter` bean can be used to convert between Java objects and JMS messages.
185+
186+
#### Set [content-type][servicebus-message-payloads] of messages
187+
188+
Below code snippet sets content-type of `BytesMessage` as `application/json`.
189+
190+
<!-- embedme ../azure-spring-boot/src/samples/java/com/azure/spring/jms/CustomizedMessageConverter.java#L25-L45 -->
191+
```java
192+
@Component
193+
public class CustomMessageConverter extends MappingJackson2MessageConverter {
194+
195+
private static final String TYPE_ID_PROPERTY = "_type";
196+
private static final Symbol CONTENT_TYPE = Symbol.valueOf("application/json");
197+
198+
public CustomMessageConverter() {
199+
this.setTargetType(MessageType.BYTES);
200+
this.setTypeIdPropertyName(TYPE_ID_PROPERTY);
201+
}
202+
203+
@Override
204+
protected BytesMessage mapToBytesMessage(Object object, Session session, ObjectWriter objectWriter)
205+
throws JMSException, IOException {
206+
final BytesMessage bytesMessage = super.mapToBytesMessage(object, session, objectWriter);
207+
JmsBytesMessage jmsBytesMessage = (JmsBytesMessage) bytesMessage;
208+
AmqpJmsMessageFacade facade = (AmqpJmsMessageFacade) jmsBytesMessage.getFacade();
209+
facade.setContentType(CONTENT_TYPE);
210+
return jmsBytesMessage;
211+
}
212+
}
213+
```
185214

215+
For more information about `MessageConverter`, see the official [Spring JMS guide][spring_jms_guide].
186216
## Troubleshooting
187217
If the JDK version you use is greater than 1.8, You may meet this problem:
188218
```
@@ -234,3 +264,5 @@ Please follow [instructions here](https://github.com/Azure/azure-sdk-for-java/bl
234264
[logging]: https://github.com/Azure/azure-sdk-for-java/wiki/Logging-with-Azure-SDK#use-logback-logging-framework-in-a-spring-boot-application
235265
[azure_subscription]: https://azure.microsoft.com/free
236266
[jdk_link]: https://docs.microsoft.com/java/azure/jdk/?view=azure-java-stable
267+
[servicebus-message-payloads]: https://docs.microsoft.com/azure/service-bus-messaging/service-bus-messages-payloads
268+
[spring_jms_guide]: https://spring.io/guides/gs/messaging-jms/

sdk/spring/azure-spring-boot/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
user-flows:
1414
${your-user-flow-key}: ${your-user-flow-name-defined-on-azure-portal}
1515
```
16-
16+
- Require new property of `spring.jms.servicebus.pricing-tier` to set pricing tier of Azure Service Bus. Supported values are `premium`, `standard` and `basic`.
1717
### New Features
1818
- Enable MessageConverter bean customization.
1919
- Update the underpinning JMS library for the Premium pricing tier of Service Bus to JMS 2.0.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.spring.jms;
5+
/**
6+
* WARNING: MODIFYING THIS FILE WILL REQUIRE CORRESPONDING UPDATES TO README.md FILE. LINE NUMBERS
7+
* ARE USED TO EXTRACT APPROPRIATE CODE SEGMENTS FROM THIS FILE. ADD NEW CODE AT THE BOTTOM TO AVOID CHANGING
8+
* LINE NUMBERS OF EXISTING CODE SAMPLES.
9+
* <p>
10+
* Code samples for the Key Vault in README.md
11+
*/
12+
import com.fasterxml.jackson.databind.ObjectWriter;
13+
import org.apache.qpid.jms.message.JmsBytesMessage;
14+
import org.apache.qpid.jms.provider.amqp.message.AmqpJmsMessageFacade;
15+
import org.apache.qpid.proton.amqp.Symbol;
16+
import org.springframework.jms.support.converter.MappingJackson2MessageConverter;
17+
import org.springframework.jms.support.converter.MessageType;
18+
import org.springframework.stereotype.Component;
19+
20+
import javax.jms.BytesMessage;
21+
import javax.jms.JMSException;
22+
import javax.jms.Session;
23+
import java.io.IOException;
24+
25+
@Component
26+
public class CustomMessageConverter extends MappingJackson2MessageConverter {
27+
28+
private static final String TYPE_ID_PROPERTY = "_type";
29+
private static final Symbol CONTENT_TYPE = Symbol.valueOf("application/json");
30+
31+
public CustomMessageConverter() {
32+
this.setTargetType(MessageType.BYTES);
33+
this.setTypeIdPropertyName(TYPE_ID_PROPERTY);
34+
}
35+
36+
@Override
37+
protected BytesMessage mapToBytesMessage(Object object, Session session, ObjectWriter objectWriter)
38+
throws JMSException, IOException {
39+
final BytesMessage bytesMessage = super.mapToBytesMessage(object, session, objectWriter);
40+
JmsBytesMessage jmsBytesMessage = (JmsBytesMessage) bytesMessage;
41+
AmqpJmsMessageFacade facade = (AmqpJmsMessageFacade) jmsBytesMessage.getFacade();
42+
facade.setContentType(CONTENT_TYPE);
43+
return jmsBytesMessage;
44+
}
45+
}

0 commit comments

Comments
 (0)