<dependency>
<groupId>de.adorsys.jmspojo</groupId>
<artifactId>jmspojo</artifactId>
<version>0.1</version>
</dependency>
public interface JMSSampleService {
public void fireAndForget(PingMessage message);
public JMSFuture<Void> fireAndWait(PingMessage message);
public void fireAndForget(PingMessage message, Destination destination);
public JMSFuture<PingMessage> ping(@JMSMessageHeaders Map<String, Object> messageHeaders, PingMessage message);
public JMSFuture<PingMessage> ping(PingMessage message);
public JMSFuture<PingMessage> ping(PingMessage message, Destination destination);
}
JMSServiceAdapterFactory jmsServiceStubFactory = new JMSServiceAdapterFactory(OBJECT_MAPPER, cf, defaultQueue, JMS_TIMEOUT);
JMSSampleService service = jmsServiceStubFactory.generateJMSServiceProxy(JMSSampleService.class);
service.fireAndForget(message);
try (JMSFuture<PingMessage> future = service.ping(message)) {
PingMessage sampleMessage = future.get(100, TimeUnit.MILLISECONDS);
}
try (JMSFuture<PingMessage> future = service.ping(message, dedicatedQueue)) {
PingMessage sampleMessage = future.get();
}
HashMap<String, Object> headers = new HashMap<>();
headers.put("timeout", true);
try (JMSFuture<PingMessage> future = service.ping(headers, message)) {
future.get(100, TimeUnit.MILLISECONDS);
}
try (JMSFuture<PingMessage> future1 = service.ping(message, dedicatedQueue);
JMSFuture<PingMessage> future2 = service.ping(message, dedicatedQueue)) {
JMSFuture.waitForAll(2000l, future1, future2);
PingMessage sampleMessage = future1.get();
PingMessage sampleMessage = future2.get();
}
public static class SampleMessageServiceWithReply {
@JMSMessageReceiver
public PingMessage ping(PingMessage message) {
return message;
}
}
@MessageDriven(activationConfig= {
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="sampleQ")
})
public class SampleMDB
extends JMSAbstractMessageListener<SampleMessageServiceWithReply> {
@Inject
SampleMessageServiceWithReply service;
@Resource(lookup="java:/JmsXA")
ConnectionFactory cf;
@Override
protected SampleMessageServiceWithReply getService() {
return service;
}
@Override
protected ConnectionFactory getConnectionFactory() {
return cf;
}
}
SampleMessageServiceWithReply service = new SampleMessageServiceWithReply();
JMSMessageListenerServiceAdapter<SampleMessageServiceWithReply> adapter =
JMSMessageListenerServiceAdapter.createAdapter(service, cf, OBJECT_MAPPER);
new MessageListener() {
@Override
public void onMessage(Message message) {
adapter.onMessage(textMessage);
}
}