1

I am publishing JMS text message to topic and consumer is able to consumer ( MDB ) the text message. But not able to get Message Object and String property. it is null in MDB consumer side. I have defined MDB in ejb-jar.xml under META-INF folder. I am using

TomEE plus 7.0.2 JMS 2.0 IBM MQ 8 JDK 1.8 Topic

I refereed below mentioned Tomee official example. In example they used tomee.xml instead i used resource.xml and don't use web.xml

Consumer is MessageDrivenBean

Consumer is able to get Text or Object Message. But Message property is null.

http://tomee.apache.org/tomee-and-webspheremq.html

@Resource(name = "qcf") 
    private ConnectionFactory connectionFactory; 
    @Resource(name = "wmq-javax.jms.Topic") 
    private Topic topic; 
    Connection connection = connectionFactory.createConnection(); 
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); 
    MessageProducer producer = session.createProducer(topic); 
    TextMessage message = session.createTextMessage(); 
    message.setText("Test Message"); 
    message.setObjectProperty("a","b"); 
    message.setStringProperty("c","D"); 
    connection.start(); 
    producer.send(message); 
    session.close(); 
    connection.close(); 

Consumer

<ejb-jar id="ejb-jar_ID" version="3.1"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                          http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">

  <display-name>SampleTransactionMDB</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>SampleTransactionMDB</display-name>
      <ejb-name>SampleTransactionMDB</ejb-name>
      <ejb-class>com.example.SampleTransactionMDB</ejb-class>
      <transaction-type>Container</transaction-type>
      <activation-config>
        <activation-config-property>
          <activation-config-property-name>destinationType</activation-config-property-name>
          <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>destination</activation-config-property-name>
          <activation-config-property-value>openejb:Resource/projectname/topicname</activation-config-property-value>
        </activation-config-property> 
      </activation-config>

        <activation-config-property>
          <activation-config-property-name>useJNDI</activation-config-property-name>
          <activation-config-property-value>true</activation-config-property-value>
        </activation-config-property>

        <activation-config-property>
          <activation-config-property-name>HostName</activation-config-property-name>
          <activation-config-property-value>x.x.x.x</activation-config-property-value>
        </activation-config-property>

        <activation-config-property>
          <activation-config-property-name>Port</activation-config-property-name>
          <activation-config-property-value>123</activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>QueueManager</activation-config-property-name>
          <activation-config-property-value>xxxxx</activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>Channel</activation-config-property-name>
          <activation-config-property-value>xxxx</activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>TransportType</activation-config-property-name>
          <activation-config-property-value>CLIENT</activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>subscriptionName</activation-config-property-name>
          <activation-config-property-value>xxxxxx</activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          <activation-config-property-name>sharedSubscription</activation-config-property-name>
          <activation-config-property-value>true</activation-config-property-value>
        </activation-config-property>


    </message-driven>  
  </enterprise-beans>
  <assembly-descriptor>
  </assembly-descriptor>
</ejb-jar>

Guide me why message property is null in MDB consumer.

2 Answers 2

1

I found the root cause of the problem. it is my mistake. TopicProxy's targetClient should be JMS. I wrongly configured as MQ. so I was able to get message but not property.

After changing targetClient value to JMS. I am able to get message and property

http://tomee.apache.org/tomee-and-webspheremq.html

Sign up to request clarification or add additional context in comments.

Comments

0

MessageProducer producer = session.createProducer(queue);

If you are publishing a message to topic then why are you using a variable named 'queue'? A topic string generally looks like 'test/ABC/one' (no quotes).

Secondly, why didn't you post the code for the consumer? Update your original posting to include the consumer code.

2 Comments

please refer tomee.apache.org/tomee-and-webspheremq.html for resource.xml where I am configuring Topic and connection. I used as resource.xml not as tomee.xml
I tried both ( Topic and Queue ). Message property is null

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.