glassfish
  1. glassfish
  2. GLASSFISH-19492

MDB @MessageDriven listens on Topic for @JMSDestinationDefinition className="javax.jms.Queue"

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 4.0_b68_EE7MS3
    • Fix Version/s: 4.0_b71
    • Component/s: jms
    • Labels:
      None

      Description

      Please see Arun's async receiver sample (which is currently commented as not working in the following blog link) and analysis in MQ-264
      https://blogs.oracle.com/arungupta/entry/simple_jms_2_0_sample

        Issue Links

          Activity

          Hide
          Nigel Deakin added a comment -

          I have tried this in the debugger and agree that this appears to be the problem.

          If you define a MDB which uses mappedName to refer to a queue resource created in the normal way (e.g. using glassfish-resources.xml) then ActivationSpec.setDestinationType() is called with a value of "javax.jms.Queue".

          However if you define a MDB which uses mappedName to refer to a queue resource created using a @JMSDestinationDefinition annotation then ActivationSpec.setDestinationType() is NOT called. As a result the MDB creates a consumer on a topic (but the correct physical name).

          So this seems to be an issue specifically with resources created using a @JMSDestinationDefinition annotation.

          There is a workaround, which is to explicitly specify the destinationType activation property. Note that setting this property should not be necessary.

          @MessageDriven(mappedName = "java:global/jms/myQueue", activationConfig =
           {@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")})
          
          Show
          Nigel Deakin added a comment - I have tried this in the debugger and agree that this appears to be the problem. If you define a MDB which uses mappedName to refer to a queue resource created in the normal way (e.g. using glassfish-resources.xml ) then ActivationSpec.setDestinationType() is called with a value of "javax.jms.Queue" . However if you define a MDB which uses mappedName to refer to a queue resource created using a @JMSDestinationDefinition annotation then ActivationSpec.setDestinationType() is NOT called. As a result the MDB creates a consumer on a topic (but the correct physical name). So this seems to be an issue specifically with resources created using a @JMSDestinationDefinition annotation. There is a workaround, which is to explicitly specify the destinationType activation property. Note that setting this property should not be necessary. @MessageDriven(mappedName = "java:global/jms/myQueue", activationConfig = {@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")})
          Hide
          arungupta added a comment -

          Tried the workaround in my simple sample and it worked.

          Show
          arungupta added a comment - Tried the workaround in my simple sample and it worked.
          Hide
          Simon Meng added a comment -

          Assume we create a jms destination resource via the following command:
          asadmin create-jms-resource --restype javax.jms.Queue --property Name=myQueue jms/myQueue
          The resource should be created successfully. It appears in domain.xml

          In an application (a MDB), it also defines a jms destination by annotation

          @JMSDestinationDefinition(name = "jms/myQueue",
          resourceAdapterName = "jmsra",
          className = "javax.jms.Queue",
          destinationName="myQueue9",
          description="My Queue9")

          @MessageDriven(mappedName = "jms/myQueue")
          public class MessageReceiverAsync implements MessageListener

          { .... }

          When deploy a MDB, we need use the mappedName to find jms destination resource in domain.xml or EJbMessageBeanDescriptor. I need know the clear answer for the following questions:

          1. If the mappedName does not start with "java:" prefix, whether need add "java:comp/env" prefix to match the resources.
          2. If two jms destination resources have the same name (name does not start with "java:" prefix), the two resources are defined in both domain.xml and application, which resource should be used.

          Show
          Simon Meng added a comment - Assume we create a jms destination resource via the following command: asadmin create-jms-resource --restype javax.jms.Queue --property Name=myQueue jms/myQueue The resource should be created successfully. It appears in domain.xml In an application (a MDB), it also defines a jms destination by annotation @JMSDestinationDefinition(name = "jms/myQueue", resourceAdapterName = "jmsra", className = "javax.jms.Queue", destinationName="myQueue9", description="My Queue9") @MessageDriven(mappedName = "jms/myQueue") public class MessageReceiverAsync implements MessageListener { .... } When deploy a MDB, we need use the mappedName to find jms destination resource in domain.xml or EJbMessageBeanDescriptor. I need know the clear answer for the following questions: 1. If the mappedName does not start with "java:" prefix, whether need add "java:comp/env" prefix to match the resources. 2. If two jms destination resources have the same name (name does not start with "java:" prefix), the two resources are defined in both domain.xml and application, which resource should be used.
          Hide
          Simon Meng added a comment -

          Fixed at revision 57990.

          Show
          Simon Meng added a comment - Fixed at revision 57990.

            People

            • Assignee:
              Simon Meng
              Reporter:
              amyk
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: