You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2020/03/31 21:03:22 UTC

[tomee] branch master updated: Slight refactor of this example - not sure it makes any real difference at this point.

This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/master by this push:
     new 16e59f7  Slight refactor of this example - not sure it makes any real difference at this point.
16e59f7 is described below

commit 16e59f739966fc3a2eb968c2171ccf0d45f136a9
Author: Jonathan Gallimore <jo...@jrg.me.uk>
AuthorDate: Tue Mar 31 22:02:37 2020 +0100

    Slight refactor of this example - not sure it makes any real difference at this point.
---
 .../src/main/java/org/superbiz/jms/CustomJmsService.java     | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/examples/simple-jms-context/src/main/java/org/superbiz/jms/CustomJmsService.java b/examples/simple-jms-context/src/main/java/org/superbiz/jms/CustomJmsService.java
index 4c4b088..f14fc18 100644
--- a/examples/simple-jms-context/src/main/java/org/superbiz/jms/CustomJmsService.java
+++ b/examples/simple-jms-context/src/main/java/org/superbiz/jms/CustomJmsService.java
@@ -19,10 +19,7 @@ package org.superbiz.jms;
 import javax.annotation.Resource;
 import javax.ejb.Stateless;
 import javax.inject.Inject;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSContext;
-import javax.jms.JMSException;
-import javax.jms.Queue;
+import javax.jms.*;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
@@ -47,7 +44,12 @@ public class CustomJmsService {
 
     @GET
     public String receiveMessage() throws JMSException {
-        return jmsContext.createConsumer(messageQueue).receiveBody(String.class, 1000);
+        final Message message = jmsContext.createConsumer(messageQueue).receive(1000);
+        if (! (message instanceof TextMessage)) {
+            return null;
+        }
+
+        return ((TextMessage) message).getText();
     }
 
     private void sendMessage(final Queue queue, final String message) {