Since I'm new to MQSeries, I've got some questions.
I'd like to connect two multi-threaded applications on different machines to communictate asyncron via messaging. Threads on the webserver should send requests to a server in the intranet. These requests should be passed to "free" server threads that do some calculations and results should be returned to the corresponding threads on the webserver.
We don't have LDAP or something similar in our office, so I tried to get along without JNDI.
First thing I tried was to run both applications on the same machine. I create two queues (on for request and one for results) The webserver threads put their messages into the request queue and get the corresponding results via a selector and the correlation ID from the results queue.
The intranet threads takes the requeust from the request queue do some calculations and send new messages to the results queue. I created a connectionFactory and connected to the default Connection manager.
This worked as I expected.
Now I try to connect using TCP/IP.
factory = new MQQueueConnectionFactory();
factory.setHostName("w-tobkircher"
factory.setPort(1414);
factory.setQueueManager("QM_w_tobkircher"
factory.setChannel("S_w_tobkircher"
factory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
System.out.println( "Factory retrieved via TCP/IP"
connection = factory.createQueueConnection();
recSession = connection.createQueueSession (false, Session.AUTO_ACKNOWLEDGE);
sendSession = connection.createQueueSession( false,Session.AUTO_ACKNOWLEDGE);
recQueue = recSession.createQueue( "Requests" );
sendQueue = sendSession.createQueue( "RequestResults" );
queueReceiver = recSession.createReceiver(recQueue);
queueSender = sendSession.createSender(sendQueue);
// Set a JMS message listener
queueReceiver.setMessageListener(this);
// Start the JMS connection; allows messages to be delivered
connection.start();
Now I start two webrequest and two intranet requests.
The communication is suddenly syncron!! As long as one intranet thread works the other one is blocked.
Any idea what's going wrong?
I'd like to connect two multi-threaded applications on different machines to communictate asyncron via messaging. Threads on the webserver should send requests to a server in the intranet. These requests should be passed to "free" server threads that do some calculations and results should be returned to the corresponding threads on the webserver.
We don't have LDAP or something similar in our office, so I tried to get along without JNDI.
First thing I tried was to run both applications on the same machine. I create two queues (on for request and one for results) The webserver threads put their messages into the request queue and get the corresponding results via a selector and the correlation ID from the results queue.
The intranet threads takes the requeust from the request queue do some calculations and send new messages to the results queue. I created a connectionFactory and connected to the default Connection manager.
This worked as I expected.
Now I try to connect using TCP/IP.
factory = new MQQueueConnectionFactory();
factory.setHostName("w-tobkircher"
factory.setPort(1414);
factory.setQueueManager("QM_w_tobkircher"
factory.setChannel("S_w_tobkircher"
factory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
System.out.println( "Factory retrieved via TCP/IP"
connection = factory.createQueueConnection();
recSession = connection.createQueueSession (false, Session.AUTO_ACKNOWLEDGE);
sendSession = connection.createQueueSession( false,Session.AUTO_ACKNOWLEDGE);
recQueue = recSession.createQueue( "Requests" );
sendQueue = sendSession.createQueue( "RequestResults" );
queueReceiver = recSession.createReceiver(recQueue);
queueSender = sendSession.createSender(sendQueue);
// Set a JMS message listener
queueReceiver.setMessageListener(this);
// Start the JMS connection; allows messages to be delivered
connection.start();
Now I start two webrequest and two intranet requests.
The communication is suddenly syncron!! As long as one intranet thread works the other one is blocked.
Any idea what's going wrong?