https://ngeblognow.blogspot.com//search?q=how-to-setup-set-jms-factory-and-queue
https://ngeblognow.blogspot.com//search?q=how-to-setup-set-jms-factory-and-queue
Also, yous mightiness desire to depository fiscal establishment represent the synchronous manner of receiving jms message:
https://ngeblognow.blogspot.com//search?q=how-to-setup-set-jms-factory-and-queue
In asynchronous way, nosotros require to define a degree that extends javax.jms.MessageListener. This degree is saltation to a JMS Queue (via mappedName property), where it volition nous for message. On message have it volition telephone weep upwards the onMessage() have method. Refer to the degree below for example:
package com.ipiel.service.message; import javax.ejb.ActivationConfigProperty; import javax.ejb.MessageDriven; import javax.inject.Inject; import javax.inject.Named; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.ObjectMessage; import javax.ws.rs.core.UriBuilder; import org.slf4j.Logger; import com.ipiel.commons.dto.MessageDTO; import com.ipiel.commons.dto.util.MessageDTOHelper; @MessageDriven(mappedName = "jms/ipielQueue", activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") }) @Named("ipielGatewayMDB") world degree IpielGatewayMDB implements MessageListener { @Inject soul Logger log; world void onMessage(Message msg) { log.debug("[ipiel-pg] onMessage: afterBegin. msg=" + msg); endeavour { MessageDTO messageDTO = MessageDTOHelper .deserialize((ObjectMessage) msg); processAction(messageDTO); } grab (Exception e) { log.error("[ipiel-pg] onMessage: {}. msg was : {}", e.getMessage(), msg); } } soul void processAction(MessageDTO msg) throws Exception { log.debug("[ipiel-pg] processAction: afterDeserialize. messageDTO={}", msg); } }
0 komentar:
Please comment if there are any that need to be asked.