Skip to content

Commit 56f16a8

Browse files
committed
Add usage examples to JmsClient javadoc
See gh-32501
1 parent 4969f6b commit 56f16a8

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

spring-jms/src/main/java/org/springframework/jms/core/JmsClient.java

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,55 @@
2828

2929
/**
3030
* A fluent {@code JmsClient} with common send and receive operations against a JMS
31-
* destination. This is effectively an alternative to {@link JmsMessagingTemplate},
32-
* also delegating to Spring's {@link JmsTemplate} for performing actual operations.
31+
* destination, dealing with Spring's common {@link Message} or with payload values.
32+
* This is effectively an alternative to {@link JmsMessagingTemplate}, also
33+
* delegating to Spring's {@link JmsTemplate} for performing actual operations.
3334
*
3435
* <p>Note: Operations in this interface throw {@link MessagingException} instead of
3536
* the JMS-specific {@link org.springframework.jms.JmsException}, aligning with the
3637
* {@code spring-messaging} module and its other client operation handles.
38+
* Message conversion is preferably done through the common {@link MessageConverter}
39+
* but can also be customized at the {@link JmsTemplate#setMessageConverter} level.
3740
*
3841
* <p>This client provides reusable operation handles which can be configured with
3942
* custom QoS settings. Note that any use of such explicit settings will override
4043
* administrative provider settings (see {@link JmsTemplate#setExplicitQosEnabled}).
4144
*
45+
* <p>An example for sending a converted payload to a queue:
46+
* <pre class="code">
47+
* client.destination("myQueue")
48+
* .withTimeToLive(1000)
49+
* .send("myPayload"); // optionally with a headers Map next to the payload
50+
* </pre>
51+
*
52+
* <p>An example for receiving a converted payload from a queue:
53+
* <pre class="code">
54+
* Optional&lt;String&gt; payload = client.destination("myQueue")
55+
* .withReceiveTimeout(1000)
56+
* .receive(String.class);
57+
* </pre>
58+
*
59+
* <p>An example for sending a message with a payload to a queue:
60+
* <pre class="code">
61+
* Message&lt;?&gt; message =
62+
* MessageBuilder.withPayload("myPayload").build(); // optionally with headers
63+
* client.destination("myQueue")
64+
* .withTimeToLive(1000)
65+
* .send(message);
66+
* </pre>
67+
*
68+
* <p>An example for receiving a message with a payload from a queue:
69+
* <pre class="code">
70+
* Optional&lt;Message&lt;?&gt;&gt; message = client.destination("myQueue")
71+
* .withReceiveTimeout(1000)
72+
* .receive();
73+
* </pre>
74+
*
4275
* @author Juergen Hoeller
4376
* @since 7.0
4477
* @see JmsTemplate
4578
* @see JmsMessagingTemplate
79+
* @see org.springframework.messaging.support.MessageBuilder
4680
*/
4781
interface JmsClient {
4882

0 commit comments

Comments
 (0)