IBM MQ Message property is null in MDB

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

IBM MQ Message property is null in MDB

gnanapandithan
This post was updated on .
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 = "topic")
    private Topic topic;
    Connection connection = connectionFactory.createConnection();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageProducer producer = session.createProducer(queue);
    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.
   

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IBM MQ Message property is null in MDB

jgallimore
Hi

Thanks for your email!

I'll debug my WMQ setup this evening for you and see if I can see anything
on the TomEE side that might be preventing this from working as you'd
expect.

Jon

On Wed, Jul 26, 2017 at 2:52 AM, gnanapandithan <[hidden email]>
wrote:

> 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 = "queue")
>     private Queue queue;
>     Connection connection = connectionFactory.createConnection();
>     Session session = connection.createSession(false,
> QueueSession.AUTO_ACKNOWLEDGE);
>     MessageProducer producer = session.createProducer(queue);
>     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();
>
> Guide me why message property is null in MDB consumer.
>
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/IBM-MQ-Message-property-is-null-in-MDB-tp4682317.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IBM MQ Message property is null in MDB

gnanapandithan
Hi jgallimore,

Thanks for your reply. I suspect this issue due to Java EE connector api and resource adapter concept.

IBM implement this by below class.

com.ibm.mq.connector.ResourceAdapterImpl

com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl

I am using IBM JAR version : 8.0.0.5

 Normal Java JMS api works fine. able to get Message property. Please try with  Java EE connector api and resource adapter concept and let me know if it is working for you.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IBM MQ Message property is null in MDB

jgallimore
Hi

This does work for me in WMQ 7.5, using the latest code in the TomEE 1.7.x
branch. Will give it a go with TomEE 7 and WMQ 8. If that works, I'll
provide my test app and config as a reference.

Regards

Jon

On Wed, Jul 26, 2017 at 2:47 PM, gnanapandithan <[hidden email]>
wrote:

> Hi jgallimore,
>
> Thanks for your reply. I suspect this issue due to Java EE connector api
> and
> resource adapter concept.
>
> IBM implement this by below class.
>
> com.ibm.mq.connector.ResourceAdapterImpl
>
> com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl
>
> I am using IBM JAR version : 8.0.0.5
>
>  Normal Java JMS api works fine. able to get Message property. Please try
> with  Java EE connector api and resource adapter concept and let me know if
> it is working for you.
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/IBM-MQ-Message-property-is-null-in-MDB-
> tp4682317p4682325.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IBM MQ Message property is null in MDB

gnanapandithan
Please try with Tomee-plus 7.0.2 with IBM MQ 8. if works please share your POC with me. thanks in advance
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IBM MQ Message property is null in MDB

jgallimore
In reply to this post by jgallimore
I'm afraid this did also work for me in WMQ 8 and TomEE 7.0.2, using the
8.0.0.7 rar jars. I've included my test app and config here:
https://github.com/jgallimore/jms-test. Happy to tweak the config if it
isn't representative of your setup and try again.

I hope my test app and config is at least some help.

Jon

On Thu, Jul 27, 2017 at 5:00 PM, Jonathan Gallimore <
[hidden email]> wrote:

> Hi
>
> This does work for me in WMQ 7.5, using the latest code in the TomEE 1.7.x
> branch. Will give it a go with TomEE 7 and WMQ 8. If that works, I'll
> provide my test app and config as a reference.
>
> Regards
>
> Jon
>
> On Wed, Jul 26, 2017 at 2:47 PM, gnanapandithan <
> [hidden email]> wrote:
>
>> Hi jgallimore,
>>
>> Thanks for your reply. I suspect this issue due to Java EE connector api
>> and
>> resource adapter concept.
>>
>> IBM implement this by below class.
>>
>> com.ibm.mq.connector.ResourceAdapterImpl
>>
>> com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl
>>
>> I am using IBM JAR version : 8.0.0.5
>>
>>  Normal Java JMS api works fine. able to get Message property. Please try
>> with  Java EE connector api and resource adapter concept and let me know
>> if
>> it is working for you.
>>
>>
>>
>> --
>> View this message in context: http://tomee-openejb.979440.n4
>> .nabble.com/IBM-MQ-Message-property-is-null-in-MDB-tp4682317p4682325.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.
>>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IBM MQ Message property is null in MDB

jgallimore
In reply to this post by gnanapandithan
That code was tested with TomEE 7.0.2 with WMQ 8. With the exception of the
WMQ jars which I can't distribute, you should have all of my code and
config.

My config (note tomee.xml and system.properties) is in the
src/main/tomee/conf directory. I just copy those into TomEE's conf
directory, and add the jars from the WMQ rar in the lib directory.

Jon


On 28 Jul 2017 5:56 pm, "gnanapandithan" <[hidden email]> wrote:

Please try with Tomee-plus 7.0.2 with IBM MQ 8. if works please share your
POC with me. thanks in advance



--
View this message in context: http://tomee-openejb.979440.
n4.nabble.com/IBM-MQ-Message-property-is-null-in-MDB-tp4682317p4682336.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IBM MQ Message property is null in MDB

gnanapandithan
This post has NOT been accepted by the mailing list yet.
Thanks for sharing your poc with me. I could see few difference.

1. You are not using com.ibm.mq.connector.outbound.MQTopicProxy
   
     am using connector API.

Please check http://tomee.apache.org/tomee-and-webspheremq.html this and update me. thank in advance.

I used resource.xml instead of tomee.xml, since i need this application level not server level.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IBM MQ Message property is null in MDB

gnanapandithan
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 configuring JMS. I am able to get message and property.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IBM MQ Message property is null in MDB

jgallimore
Oh wonderful, thank you for following up with that information. Apologies
for not knowing that, I'm very new to WMQ myself.

Jon

On Mon, Jul 31, 2017 at 5:44 AM, gnanapandithan <[hidden email]>
wrote:

> 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 configuring JMS. I am able to get message and property.
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/IBM-MQ-Message-property-is-null-in-MDB-
> tp4682317p4682342.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>
Loading...