Vous êtes sur la page 1sur 4

Manual Re-import MQ implementation

1. User will upload the file through UI. 2. Application will receive the uploaded file and a. Insert the file in database b. On successful insertion of the file in DB, the application will post a xml message to the queue configured. 3. Java listener process will receive the xml message. 4. Java process will read the file id from the xml message and process the file from database and update the status.

Database
2 Application Srver 1

Java file processor 3

UI

IBM MQ

Implementation:The implementation proposed for message creation and posting the message is through IBM MQ API. Below are the details.

MQ Messaging
IBM MQ API is used to send & receive MQ messages. Pseudo code for sending MQ message: //Create MQ Connection factory and set host,queue manager & channel details. MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
cf.setHostName(_hostName); cf.setPort(Integer.parseInt(_serverPort)); cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP); cf.setQueueManager(_managerName); cf.setChannel(_channelName);

// Create Queue connection from connection factory with credentials MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection(_userName, _password); // Create Session object MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); // Create Queue Object MQQueue queue = (MQQueue) session.createQueue(_queueName); // create Queue Sender MQQueueSender sender = (MQQueueSender) session.createSender(queue); // start the queue Connection connection.start(); // create JMSMessageText from a string message JMSTextMessage message = (JMSTextMessage) session.createTextMessage(mess); // send message

sender.send(message); // close the connection Connection.close();

Pseudo code for recieving MQ message: //Create MQ Connection factory and set host,queue manager & channel details. MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
cf.setHostName(_hostName); cf.setPort(Integer.parseInt(_serverPort)); cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP); cf.setQueueManager(_managerName); cf.setChannel(_channelName);

// Create Queue connection from connection factory with credentials MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection(_userName, _password); // Create Session object MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); // Create Queue Object MQQueue queue = (MQQueue) session.createQueue(_queueName); // Create Queue Receiver receiver = (MQQueueReceiver) session.createReceiver(queue); // Start the connection connection.start(); // receive the MQ message receiver.receive().toString() // close the connection Connection.close();

Sample XML message (subjected to change based on further design ):


<GMRMRequest> <appCD> GMRM </appCD> <fileID> 1234 </fileID> <action> Clear Exception </action> </GMRMRequest>

Vous aimerez peut-être aussi