Skip to content

Instantly share code, notes, and snippets.

@vlytsus
vlytsus / SpringJmsTemplateExample.java
Created February 21, 2020 14:28
Spring JmsTemplate Example
private final JmsTemplate jmsTemplate;
public String sendMessage(String queueName, String payload) {
jmsTemplate.convertAndSend( queueName, payload );
}
@vlytsus
vlytsus / UserService.java
Created February 21, 2020 14:32
Example of @Transactiona method that combines JMS & Database transaction
private final JmsTemplate jmsTemplate;
private final UserRepository userRepository;
...
@Entity
protected class UserEntity {
@Id public UUID userId;
@NotEmpty public String username;
}
...
@Transactional
@vlytsus
vlytsus / gist:a9b87f6a3d7c0e52e5c78bf8a2411d35
Created March 9, 2020 10:24
Spring named beans injection
@Component("email")
public class EmailStrategy implements NotificationStrategy { ... }
...
@Component("sms")
public class SmsStrategy implements NotificationStrategy { ... }
...
@Service
public class NotificationService() {
@Resource(name = "email")
@vlytsus
vlytsus / ApparentWindVector.cs
Last active October 30, 2020 00:52
Apparent Wind Vector
Vector3 calculateApparentWindVector(Vector3 windSpeedVector, Vector3 boatSpeedVector) {
// Since Face wind vector is caused by yacht movement it
// has the yacht velocity magnitude but opposite direction.
// So we will just subtract one vector from another
return windSpeedVector - boatSpeedVector;
}