-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
servicebus jms queue sample update #158
servicebus jms queue sample update #158
Conversation
@yiliuTo please help review this PR. |
@JmsListener(destination = QUEUE_NAME, containerFactory = "jmsListenerContainerFactory") | ||
/** | ||
* Message consumer | ||
* @param user user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should give more detailed explanation for what the parameter of User
is used as.
import org.springframework.jms.core.JmsTemplate; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* Message Producer Mannually. | ||
*/ | ||
@RestController | ||
public class QueueSendController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's unify the class naming and remove Controller
suffix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Controller can be remained I think, it has a post request.
@Autowired | ||
private JmsTemplate jmsTemplate; | ||
|
||
/** | ||
* @param message username |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add the introduction of the method, also we could give full explanation of what the paremeter of message
is used as
import javax.jms.Session; | ||
|
||
/** | ||
* For reqeust-response pattern of Jms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo here
private JmsTemplate jmsTemplate; | ||
|
||
@Autowired | ||
private JmsMessagingTemplate jmsMessagingTemplate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this used for?
* Premium Tier Only | ||
*/ | ||
@Component | ||
@Profile("sync") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we call this profile as sync
? Given the description of class javadoc, this profile of sample is trying to introduce the use case of "send and receive" of JmsMessagingTemplate
, but do we have special support of it in our library?
*/ | ||
@RestController | ||
@Profile("sync") | ||
public class SyncQueueSendController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
.createSession(false, Session.AUTO_ACKNOWLEDGE); | ||
ObjectMessage objectMessage = session.createObjectMessage(new User(message)); | ||
objectMessage.setJMSCorrelationID(UUID.randomUUID().toString()); | ||
objectMessage.setJMSReplyTo(connectionFactory.createContext().createTemporaryQueue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the temporary queue here mean? will it create a queue in Service Bus? And we can comment here to introduce the meaning of message properties we configured.
objectMessage.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); | ||
|
||
return jmsMessagingTemplate.convertSendAndReceive(new JmsQueue(queueName), | ||
objectMessage, User.class); //this operation seems to be blocking + sync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't have "seems to be" here
pricing-tier: ${PRICING_TIER} | ||
pool: | ||
enabled: true # To be true to enable the JmsPoolConnectionFactory bean. Default false. | ||
queuename: que001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's follow unified property naming schema and use kebab here
We can update this sample and introduce the usage of caching and pooled connection factory, and update the sample of topic as well |
In your terminal, run `mvn clean spring-boot:run`. | ||
|
||
|
||
Navigate to the project root directory, then run the maven command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can update the template and then update all the descriptions here.
issue link
please revert it here.
```shell | ||
mvn clean spring-boot:run | ||
``` | ||
|
||
## Verify This Sample | ||
|
||
1. Verify in your app's logs that a similar message was posted: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar messages were posted
``` | ||
curl -d "" http://localhost:8080/queue?message=hello | ||
``` | ||
|
||
2. Verify in your app's logs that a similar message was posted: | ||
3. [Optional] Verify in your app's logs that a similar message was posted: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
I should propose different pr for different issues. So this closed for now. |
Purpose
*Update the ServiceBus Jms Queue sample
Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?
How to Test
What to Check
Verify that the following are valid
Other Information