2 Replies Latest reply on Jan 10, 2014 11:31 AM by jrantav

    How to send JMS messages to other servers from MDB?

    jrantav Novice

      I have this kind of configuration for my MDB, which works  fine for listening:

       

      @MessageDriven(name = "MQListenerBean", activationConfig = {

              @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true"),

              @ActivationConfigProperty(propertyName = "destination", propertyValue = "targetQueueJNDIName"),

              @ActivationConfigProperty(propertyName = "hostName", propertyValue = "target.server.com"),

              @ActivationConfigProperty(propertyName = "port", propertyValue = "3100"),

              @ActivationConfigProperty(propertyName = "queueManager", propertyValue = "QM"),

              @ActivationConfigProperty(propertyName = "channel", propertyValue = "CHANNEL_NAME"),

              @ActivationConfigProperty(propertyName = "username", propertyValue = "USER"),

              @ActivationConfigProperty(propertyName = "password", propertyValue = "PASS"), })

      @ResourceAdapter(value = "wmq.jmsra.rar")

      @TransactionAttribute(TransactionAttributeType.REQUIRED)

      public class MQListenerBean implements MessageListener {

       

      However, if I try to look up a JMS queue in the same MDB, same target server for sending, using

       

      @Resource(mappedName = "TARGETQCF")

      private XAQueueConnectionFactory xaConnectionFactory;

      or

       

      @Resource(lookup = "TARGETQCF")

      private XAQueueConnectionFactory xaConnectionFactory;

       

      the lookup fails. Apparently ActivationConfig no longer applies. So, how can I do a lookup from some other server? Why is ActivationConfig not respected by Resource annotation?

        • 1. Re: How to send JMS messages to other servers from MDB?
          Justin Bertram Master

          I think you're confused about what the activation configuration properties are doing in relation to the resource you're injecting.  The bottom line is that they don't have anything to do with each other.  The activation configuration properties are strictly for inbound communication for the MDB.  The XAQueueConnectionFactory is completely independent of this.  If you want to lookup a JMS connection factory pointing to a remote server then you'll need to configure the appropriately in the <resource-adapters> section of standalone*.xml or domain.xml.  See this bit of documentation for more information.

          1 of 1 people found this helpful
          • 2. Re: How to send JMS messages to other servers from MDB?
            jrantav Novice

            Ok, thank you for the reply. And yes, I suspected they are independent. I was hoping there would be a way to configure a remote server for sending JMS. standalone*.xml configuration is server wide, so it is not applicable for all situations.

             

            So - should I read this as so there is no way to do similar stuff that MDB can do with ActivationConfiguration for sending JMS and using a resource adapter? By similar I mean something that is contained in the application.