-
Notifications
You must be signed in to change notification settings - Fork 88
guide jms
devonfw-core edited this page Nov 21, 2022
·
8 revisions
Table of Contents
Warning
|
Hey there! Seems like you are still using the documentation of our legacy Java repository. Since it won’t be maintained anymore, we recommend you to checkout the new Java page here. |
Messaging in Java is done using the JMS standard from JEE.
Warning
|
Hey there! Seems like you are still using the documentation of our legacy Java repository. Since it won’t be maintained anymore, we recommend you to checkout the new Java page here. For messaging you need to choose a JMS provider such as: |
-
Oracle Advanced Queuing (esp. if you already use Oracle RDBMS)
Warning
|
Hey there! Seems like you are still using the documentation of our legacy Java repository. Since it won’t be maintained anymore, we recommend you to checkout the new Java page here. As a receiver of messages is receiving data from other systems it is located in the service-layer. |
Warning
|
Hey there! Seems like you are still using the documentation of our legacy Java repository. Since it won’t be maintained anymore, we recommend you to checkout the new Java page here.
A JmsListener is a class listening and consuming JMS messages. It should carry the suffix JmsListener and implement the MessageListener interface or have its listener method annotated with @JmsListener . This is illustrated by the following example:
|
@Named
@Transactional
public class BookingJmsListener /* implements MessageListener */ {
@Inject
private Bookingmanagement bookingmanagement;
@Inject
private MessageConverter messageConverter;
@JmsListener(destination = "BOOKING_QUEUE", containerFactory = "jmsListenerContainerFactory")
public void onMessage(Message message) {
try {
BookingTo bookingTo = (BookingTo) this.messageConverter.fromMessage(message);
this.bookingmanagement.importBooking(bookingTo);
} catch (MessageConversionException | JMSException e) {
throw new InvalidMessageException(message);
}
}
}
Warning
|
Hey there! Seems like you are still using the documentation of our legacy Java repository. Since it won’t be maintained anymore, we recommend you to checkout the new Java page here. |
The sending of JMS messages is considered as any other sending of data like kafka messages or RPC calls via REST using service-client, gRPC, etc. This will typically happen directly from a use-case in the logic-layer. However, the technical complexity of the communication and protocols itself shall be hidden from the use-case and not be part of the logic layer. With spring we can simply use JmsTemplate to do that.
This documentation is licensed under the Creative Commons License (Attribution-NoDerivatives 4.0 International).