Author |
Message
|
longhairedhippy |
Posted: Tue Nov 08, 2005 2:03 pm Post subject: Using MQ/MDB in WebSphere driven from a non-java client |
|
|
 Newbie
Joined: 08 Nov 2005 Posts: 7
|
I'm currently working on a project where we plan to integrate multiple Mainframe and distributed systems to drive MDBs in IBM WebSphere using MQ Series. I have come onto the project after the design has been finalized but here's my quandry:
I've gotten my MDB setup in WebSphere and have it hooked into MQ through JMS. I've tried sending simple text messages using the amsqput sample program and the messages are removed from the queue but my MDB is never activated. I'm not using a publisher/subscriber implementation currently, I'm just trying to do a proof of concept. Do I have to use a Java-based client to send the JMS messages or can anything that puts a message on the queue drive the MDB?
My next step is to create java client to send messages, just to prove to myself that the current setup is correct but in production, the plan is to not have java-based clients sending the messages.
I'm brand new to MQ Series/WebSphere/J2EE so bear with me. We're running MQ 5.3.0.11 and WebSphere 6.0.2.3 on AIX 5.3. |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Nov 08, 2005 2:05 pm Post subject: Re: Using MQ/MDB in WebSphere driven from a non-java client |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
longhairedhippy wrote: |
I've tried sending simple text messages using the amsqput sample program and the messages are removed from the queue but my MDB is never activated. |
You should be able to do this. If the messages are removed from the queue, my guess is that whoever is removing them is keeping the MDB from actually getting them. I'd look at the qstatus command to see if you can figure out who has the queue open for input. |
|
Back to top |
|
 |
longhairedhippy |
Posted: Wed Nov 09, 2005 4:36 am Post subject: |
|
|
 Newbie
Joined: 08 Nov 2005 Posts: 7
|
Ok, now we're getting somewhere. It appears that WebSphere AppServer has the queue open twice. Any ideas what would cause this? I'm sure it's some sort of misconfiguration but I kind of at a loss as to where to start. Here's my current configuration:
MQ Connection Factory
--------------------------
Name: AAMQcf
JNDI: jms/AAMQcf
Mapping-configuration alias: DefaultPrincipalMapping
Queue Manager: aa.queue.manager
Port: 0
Transport Type: BINDINGS
Enable message retention: true
XA Enabled: true
Enable return methods: true
Polling interval: 5000
Rescan interval: 5000
Enable MQ connection pooling: true
Broker version: Basic
Publish and subscribe cleanup interval: 3600000
Publish and acknowledgement interval: 25
Publish and subscribe status interval: 60000
Persistent subscriptions store: MIGRATE
Enable multicast transport: DISABLED
Direct broker authorization page: BASIC
MQ queue destinations
--------------------------
Name: AAInputQueue
JNDI: jms/AAInputQueue
Persistence: APPLICATION DEFINED
Priority: APPLICATION DEFINED
Specified priority: 0
Expiry: APPLICATION DEFINED
Specified expiry: 0
Base queue name: INPUT.QUEUE
Integer encoding: Normal
Decimal encoding: Normal
Floating point encoding: Normal
Target client: JMS
Queue manager port: 0
MQ Topic Destinations
-------------------------
Name: AATestTopic
JNDI: jms/AATestTopic
Persistence: APPLICATION DEFINED
Priority: APPLICATION DEFINED
Specified priority: 0
Expiry: APPLICATION DEFINED
Specified expiry: 0
Base topic name: TestTopic
Integer encoding: Normal
Decimal encoding: Normal
Floating point encoding: IEEENormal
Target client: JMS
Enable multicast transport: AS CONNECTION FACTORY
All other settings not listed are either blank or unchecked
Here's the config for my MDB:
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>
AA_InputPlugin</display-name>
<enterprise-beans>
<message-driven id="MQReceiver">
<ejb-name>MQReceiver</ejb-name>
<ejb-class>com.myCompany.AAProject.InputPlugin.MQReceiverBean</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<message-destination-link>AAInputQueue</message-destination-link>
<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>
</message-driven>
</enterprise-beans>
<assembly-descriptor id="AssemblyDescriptor_1131469783308">
<message-destination>
<description>
</description>
<message-destination-name>AAInputQueue</message-destination-name>
</message-destination>
</assembly-descriptor>
<ejb-client-jar>AA_InputPluginClient.jar</ejb-client-jar>
</ejb-jar>
|
Any help would be greatly appreciated! |
|
Back to top |
|
 |
longhairedhippy |
Posted: Wed Nov 09, 2005 4:39 am Post subject: |
|
|
 Newbie
Joined: 08 Nov 2005 Posts: 7
|
Oh yeah, I almost forgot, here's what I've got running MQ wise on the system:
Code: |
mqm 147672 479474 0 Nov 04 - 0:00 amqzllp0 -maa.queue.manager ?
mqm 188546 315556 0 Nov 04 - 0:06 amqfcxba -m aa.queue.manager
mqm 192526 479474 0 Nov 04 - 0:01 /usr/mqm/bin/amqzfuma -m aa.queue.manager
mqm 315556 1 0 Nov 04 - 0:06 amqfcxaa -m aa.queue.manager
mqm 331892 479474 0 Nov 04 - 0:00 /usr/mqm/bin/amqrrmfa -t2332800 -s2592000 -p2592000 -g5184000 -c3600 -m aa.queue.manager
mqm 413912 1 0 07:31:28 - 0:00 /usr/mqm/bin/amqrmppa -m aa.queue.manager
mqm 446492 479474 0 Nov 04 - 0:00 /usr/mqm/bin/runmqchi -m aa.queue.manager
mqm 466988 479474 0 Nov 04 - 0:03 amqzlaa0 -maa.queue.manager -fip0
mqm 475264 479474 0 Nov 04 - 0:03 /usr/mqm/bin/amqzdmaa -m aa.queue.manager
mqm 479474 1 0 Nov 04 - 0:05 amqzxma0 -m aa.queue.manager
mqm 549050 479474 0 Nov 04 - 0:00 amqhasmx aa!queue!manager /var/
|
|
|
Back to top |
|
 |
wschutz |
Posted: Wed Nov 09, 2005 7:36 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Use the "display qstatus" command to see which two processes have the queue open _________________ -wayne |
|
Back to top |
|
 |
longhairedhippy |
Posted: Wed Nov 09, 2005 8:53 am Post subject: |
|
|
 Newbie
Joined: 08 Nov 2005 Posts: 7
|
I did that, qstatus reports both PIDs are the same, its the PID of the WebSphere AppServer process. |
|
Back to top |
|
 |
webspherical |
Posted: Wed Nov 09, 2005 10:58 am Post subject: |
|
|
Acolyte
Joined: 15 Aug 2005 Posts: 50
|
So you have logging in your onMessage() within the MDB that ensures it never gets called? Sounds like the messageListenerPort is working properly, otherwise the message would still be queued up. Are your attributes in the MLP configured with the correct QCF/Qdest? |
|
Back to top |
|
 |
longhairedhippy |
Posted: Wed Nov 09, 2005 11:21 am Post subject: |
|
|
 Newbie
Joined: 08 Nov 2005 Posts: 7
|
Yeah, I have a System.out.println() call in my onMessage(), and I'm not getting anything in the SystemOut.log file. Additionally, I have been playing with the performance monitoring and according to that, my bean is getting called for every message, 10 messages submitted, 10 calls to onMessage().
I was a little confused because WAS had the queue opened twice so I stopped my listener port and now WAS only has it open once and messages are being left in the queue so it appears the listener port is actually taking the messages out. Here's my config for the listener port:
Listener Port
--------------
Name: MQReceiverPort
Initial State: Started
Connection factory JNDI: jms/AAMQcf
Destination JNDI Name: jms/AAInputQueue
Maximum sessions: 1
Maximum retries: 0
Maximum messages: 1
Thanks for all your help! |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Nov 09, 2005 12:29 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
longhairedhippy wrote: |
Yeah, I have a System.out.println() call in my onMessage(), and I'm not getting anything in the SystemOut.log file. Additionally, I have been playing with the performance monitoring and according to that, my bean is getting called for every message, 10 messages submitted, 10 calls to onMessage(). |
So your 'bean' is getting called? Do you mean your MDB? If so, is it possible that the println isn't working? Are you doing container managed or bean managed transactions? Are you doing anything with selectors on the message? |
|
Back to top |
|
 |
longhairedhippy |
Posted: Wed Nov 09, 2005 12:42 pm Post subject: |
|
|
 Newbie
Joined: 08 Nov 2005 Posts: 7
|
Yeah, sorry for the mixup in terminology, by "bean" I meant my MDB (I'm new to J2EE). I went into Tivoli Performance Viewer and monitored my MQReciever module under Performance Modules. The MethodCallCount counter is incrementing each time I send a message to the queue using the amqsput sample program.
I guess it's a possibility the println isn't working by this is what I've got in my onMessage() function:
Code: |
public void onMessage(javax.jms.Message msg) {
System.out.println("MQReceiverBean.onMessage() fired!");
if (msg instanceof javax.jms.TextMessage)
{
javax.jms.TextMessage tm = (javax.jms.TextMessage) msg;
try {
String s = tm.getText();
System.out.println("MQRecieverBean [RECV MSG]: {" + s + "}");
PrintWriter pw = new PrintWriter(new FileWriter("/tmp/messages.txt"));
pw.println("GOT MESSAGE [" + s + "]");
pw.close();
} catch (Exception e)
{
System.out.println("MQReceiverBean Exception occurred retrieving message!");
System.out.println(e.toString());
}
}
else
{
System.out.println("Unknown type of message received: " + msg.toString());
try {
PrintWriter pw = new PrintWriter(new FileWriter("/tmp/messages.txt"));
pw.println("GOT UNKNOWN MSG [" + msg.toString() + "]");
pw.close();
} catch (Exception e)
{
System.out.println("MQReceiverBean exception occurred writing to file");
}
}
}
|
I tried without the code to write to a file but I wasn't getting any println messages so I added the code to write to /tmp/messages.txt to see if maybe the println wasn't working.
I'm using container managed transactions and the only Activation Configuration I have is destinationType == javax.jms.Queue, I'm not doing anything with the messageSelector. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Nov 09, 2005 2:56 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Just as a heads up.
For each queue you have an MDB listening to
You should see at least 1 connection from WAS.
You should see as max # of connections (max instances of MDB +1)
The +1 is the "Browse" process that is just checking if there are any messages in the queue. (Needed by the MDB to know if there is work to do)
Enjoy  |
|
Back to top |
|
 |
longhairedhippy |
Posted: Thu Nov 10, 2005 4:24 am Post subject: |
|
|
 Newbie
Joined: 08 Nov 2005 Posts: 7
|
Ah, that makes a lot of sense as to why WAS had the open twice for input.
On another note, I'm an idiot. Apparently I didn't have the Rational development tool configured correctly and all the changes I've made to my MDB over the last three days were not being deployed to the server. There was a skeleton class already on the server that had no code in the onMessage() and that was the one being called, not the one I have been publish/deploy'ing.
Out of frustration I exported the JAR file from Rational and manually copied it to the server and then restarted WAS and magically it worked! Sorry for the inconvenience and clogging up everyone's time with my bone-headedness. Thanks for all the input and hopefully next time I post it won't be because I'm stupid  |
|
Back to top |
|
 |
webspherical |
Posted: Thu Nov 10, 2005 6:11 pm Post subject: |
|
|
Acolyte
Joined: 15 Aug 2005 Posts: 50
|
fjb_saber, that is good information. appreciate that, Is that in the Using Java Manual? or a IBM WAS redbook? |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Nov 11, 2005 9:59 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Just experience....  |
|
Back to top |
|
 |
|