Topic
3 replies Latest Post - ‏2013-08-28T08:25:16Z by MarkN
nicolex
nicolex
1 Post
ACCEPTED ANSWER

Pinned topic JMS asynchronous messaging for EBAs on liberty?

‏2013-08-05T14:13:07Z |

Hello,

I'm trying to configure asynchronous message handling between EBAs on liberty server.

From researching online, it seems like there are only 2 ways to do asynch JMS messaging, thru Message Listener or Message driven bean.  Message Listener appears to be not supported and throws a "javax.jms.IllegalStateException: Method setMessageListener not permitted".  MDB is ejb driven which we don't plan to use. 

I'm wondering is there any other workarounds to do message handling asynchronously?

 

Regards

Nicole.

  • MarkN
    MarkN
    10 Posts
    ACCEPTED ANSWER

    Re: JMS asynchronous messaging for EBAs on liberty?

    ‏2013-08-07T11:04:22Z  in response to nicolex

    Hi Nicole, 

    The Java EE 6 spec (section EE.6.7) restricts the setMessageListener() methods to the application client container. In effect, this prevents you from calling setMessageListener within both Java EE and OSGi Applications on both Full and Liberty WAS profiles. 

    There are still ways of getting JMS messages into OSGi Applications. On Full Profile you can include MDBs in the OSGi Application, or use SCA. (See my second reply in this thread for some more pointers.)

    We have to be a bit more creative on Liberty since we don't support EJBs in OSGi Applications on that profile. The two main options are (a) to use the JMS client API without message listeners, and (b) to use an MDB in a Java EE application, and route the messages on to the OSGi application. 

    Option (a) requires your OSGi application to poll for messages. You'd typically have some extra thread management code to write around that. Option (b) means that you have to get a JMS message from a Java EE to an OSGi Application. This can be done by HTTP; typically Servlet or JAX-RS, but it's not very efficient. Another approach would be to write a custom feature to handle passing the message between the Java EE and OSGi applications. This should be more efficient, and doesn't require a great deal of code. 

    Regards, 

    Mark

     

    • IT_Girdhar
      IT_Girdhar
      2 Posts
      ACCEPTED ANSWER

      Re: JMS asynchronous messaging for EBAs on liberty?

      ‏2013-08-28T06:24:53Z  in response to MarkN

      Hi Mark,

      Could you please give code snippet for  a custom feature to handle passing the message between the Java EE and OSGi applications ? .

       

      • MarkN
        MarkN
        10 Posts
        ACCEPTED ANSWER

        Re: JMS asynchronous messaging for EBAs on liberty?

        ‏2013-08-28T08:25:16Z  in response to IT_Girdhar

        Hello, 

        One set of code fragments can be found in the Infocenter topic, "Locating OSGi Applications". Another can be found in my sample.osgi.htttpservice GitHub project, which is described in more detail in this wasdev article. The Infocenter and GitHub articles each illustrate a different way of finding an OSGi Application from a custom feature. Calling a custom feature from a Java EE application is straightforward. For some method, org.sample.Forwarder.forward(String message, String targetApp) in the custom feature, you would need a header, IBM-API-Package: org.sample in the custom feature manifest. That would allow you to call the forward() method directly from the Java EE side. 

        Regards, 

        Mark