In recent times, we faced a lingering issue in production while posting messages to a remote queue (MQV5.3) using MQ import binding (connections management via server settings) where the connections from client are remained alive/active despite connections are broken from remote side. We applied several settings suggested in Technote but it didn't help. We also checked firewall and TCP settings but no luck.
PMR suggested that its due to older version of MQ which is no longer supported by IBM and we were advised to upgrade. Since MQ is remote and we have no control on it we end up making/managing connections using Java code, which is performing really well as of this writing. Here is the code snippet:
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Date;
import java.util.Properties;
import javax.jms.JMSException;
import com.ibm.jms.JMSTextMessage;
import com.ibm.mq.jms.MQQueue;
import com.ibm.mq.jms.MQQueueConnection;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import com.ibm.mq.jms.MQQueueSender;
import com.ibm.mq.jms.MQQueueSession;
public static void postMessage(String msg) {
Properties p = new Properties(System.getProperties());
//Setting below properties based on Link1 and Link2
p.put("com.ibm.mq.cfg.TCP.Connect_Timeout", "30");
p.put("com.ibm.mq.cfg.MQRCVBLKTO", "30");
System.setProperties(p);
MQQueueSession session = null;
MQQueueSender sender = null;
MQQueueConnection connection = null;
try {
FileReader fr = new FileReader(
"C:\\Harish\\Msg.txt");
BufferedReader br = new BufferedReader(fr);
String s;
StringBuffer str = new StringBuffer();
while ((s = br.readLine()) != null)
str.append(s);
fr.close();
msg = str.toString();
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
cf.setHostName(HOST);
cf.setPort(PORT);
cf.setTransportType(1);
cf.setQueueManager(QM);
cf.setChannel(CHANNEL);
connection = (MQQueueConnection) cf.createQueueConnection();
session = (MQQueueSession) connection.createQueueSession(false, 1);
MQQueue queue = (MQQueue) session
.createQueue("queue:///QUEUE");
sender = (MQQueueSender) session.createSender(queue);
JMSTextMessage message = (JMSTextMessage) session
.createTextMessage(msg);
connection.start();
sender.send(message);
System.out.println("Sent message");
} catch (JMSException jme) {
System.out.println("JMSException occurred");
jme.printStackTrace();
} catch (Exception e) {
System.out.println("Exception occurred");
e.printStackTrace();
}
finally {
try {
sender.close();
System.out.println("sender closed");
} catch (Exception ex) {
System.err.println("sender() : " + ex.getLocalizedMessage());
}
try {
session.close();
System.out.println("session closed");
} catch (Exception ex) {
System.err.println("session.close() : "
+ ex.getLocalizedMessage());
}
try {
connection.close();
System.out.println("connection closed");
} catch (Exception ex) {
System.err.println("connection.close() : "
+ ex.getLocalizedMessage());
}
}
}
PMR suggested that its due to older version of MQ which is no longer supported by IBM and we were advised to upgrade. Since MQ is remote and we have no control on it we end up making/managing connections using Java code, which is performing really well as of this writing. Here is the code snippet:
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Date;
import java.util.Properties;
import javax.jms.JMSException;
import com.ibm.jms.JMSTextMessage;
import com.ibm.mq.jms.MQQueue;
import com.ibm.mq.jms.MQQueueConnection;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import com.ibm.mq.jms.MQQueueSender;
import com.ibm.mq.jms.MQQueueSession;
public static void postMessage(String msg) {
Properties p = new Properties(System.getProperties());
//Setting below properties based on Link1 and Link2
p.put("com.ibm.mq.cfg.TCP.Connect_Timeout", "30");
p.put("com.ibm.mq.cfg.MQRCVBLKTO", "30");
System.setProperties(p);
MQQueueSession session = null;
MQQueueSender sender = null;
MQQueueConnection connection = null;
try {
FileReader fr = new FileReader(
"C:\\Harish\\Msg.txt");
BufferedReader br = new BufferedReader(fr);
String s;
StringBuffer str = new StringBuffer();
while ((s = br.readLine()) != null)
str.append(s);
fr.close();
msg = str.toString();
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
cf.setHostName(HOST);
cf.setPort(PORT);
cf.setTransportType(1);
cf.setQueueManager(QM);
cf.setChannel(CHANNEL);
connection = (MQQueueConnection) cf.createQueueConnection();
session = (MQQueueSession) connection.createQueueSession(false, 1);
MQQueue queue = (MQQueue) session
.createQueue("queue:///QUEUE");
sender = (MQQueueSender) session.createSender(queue);
JMSTextMessage message = (JMSTextMessage) session
.createTextMessage(msg);
connection.start();
sender.send(message);
System.out.println("Sent message");
} catch (JMSException jme) {
System.out.println("JMSException occurred");
jme.printStackTrace();
} catch (Exception e) {
System.out.println("Exception occurred");
e.printStackTrace();
}
finally {
try {
sender.close();
System.out.println("sender closed");
} catch (Exception ex) {
System.err.println("sender() : " + ex.getLocalizedMessage());
}
try {
session.close();
System.out.println("session closed");
} catch (Exception ex) {
System.err.println("session.close() : "
+ ex.getLocalizedMessage());
}
try {
connection.close();
System.out.println("connection closed");
} catch (Exception ex) {
System.err.println("connection.close() : "
+ ex.getLocalizedMessage());
}
}
}
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteangularjs Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
angularjs-Training in sholinganallur
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletepython interview questions and answers | python tutorials
Really great post, Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!
ReplyDeleteJava training in Chennai | Java training in Bangalore
Java interview questions and answers | Core Java interview questions and answers
A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.
ReplyDeleteData Science Training in Chennai | Data Science course in anna nagar
Data Science course in chennai | Data science course in Bangalore
Data Science course in marathahalli | Data Science course in btm layout
Excellent blog!!! I got to know the more useful information by reading your blog. Thanks for posting this blog.
ReplyDeleteTOEFL Coaching Centres in Ambattur Chennai
TOEFL Classes in Ambattur OT
TOEFL Course in Redhills
TOEFL Training near me
Best TOEFL Coaching Institute in velachery
TOEFL Coaching Classes in Tharamani
TOEFL Coaching Centres in Madipakkam
I am really enjoying reading your well written articles.
ReplyDeleteIt looks like you spend a lot of effort and time on your blog.
I have bookmarked it and I am looking forward to reading new articles. Keep up the good work..
Hadoop Training in Chennai
Big Data Training in Chennai
Big Data Course in Chennai
big data courses in bangalore
hadoop training institutes in bangalore
We are urgently in need of Organs Donors, Kidney donors,Female Eggs,Kidney donors Amount: $500.000.00 Dollars
ReplyDeleteFemale Eggs Amount: $500,000.00 Dollars
WHATSAP: +91 91082 56518
Email: : customercareunitplc@gmail.com
Please share this post.
Thanks for sharing information awesome blog-post. Online Education Quiz website For Exam Follow this website Gk in Hindi
ReplyDeleteAre you having problem in learning new skills or confused to choose between right Passion . So don't worry we are here because our institution is offering CS executive classes and a free of cost CSEET classes. So what are you waiting for contact us or visit our website at https://uniqueacademyforcommerce.com/
ReplyDeleteAutomated Forex Trading : exness login Is An Automated Forex Investing Software. It Is An Algorithmic Trading Software That Provides Automated Forex Trading Signals.
ReplyDeleteXM REVIEW If You Are A Beginner, Check Out Our Guide On How To Open An Account With XM. They Offer Copy Trading Where You Can Copy The Trades Of Successful Traders.
ReplyDeleteAre You Thinking About Joining AVATRADE REVIEW ? If You Are Then Read The Review On AVATRADE Fx In This Article. We, Will, Tell You About The Company, The Brokers, The Platform, And All The Information You Need To Know. Read More Here.
ReplyDeleteBest Digital Marketing courses | Web development training institute in Chennai,chennai - Learnfella
ReplyDeleteLearnfella Offers Digital Marketing, Web and mobile app development, Machine learning,
Video editing and animation course Training in Shenoynagar, Anna nagar, Padi, Ambattur,
Kilpauk, Arumbakam, Chennai with Learnfella. Get the best training with live interactive classes, real-world case studies, and expert trainers.
Digital Marketing Course in chennai,
Coworking Office Space in Anna nagar, Korattur, Padi, Ambattur, Kilpauk, Arumbakam, Shenoynagar, Chennai - Cowrkz
ReplyDeleteFind the best coworking space in Chennai. Book a Coworking space at Anna Nagar,
Korattur, Padi, Ambattur, Kilpauk, Arumbakam, Shenoynagar. Office Space for rent with all amenities at an affordable price in Anna Nagar.
Coworking Office Space in Shenoynagar,
Incredible points. Sound arguments. Keep up the great work. Read about dot net consultant chennai from Maria Academy.
ReplyDeleteExcellent blog!!!
ReplyDeletejewellery erp software
Jewellery erp software
great post, keep posting
ReplyDeletediyarbakır
ReplyDeletedüzce
edirne
elazığ
erzincan
RZ06A
ReplyDeleteشركة مكافحة حشرات بجدة
شركة مكافحة حشرات
The article provides a step-by-step guide on how to create a Walmart account using a Brazil virtual phone number via PVApins. It highlights Walmart's benefits as a digital marketplace, including advanced search features, order tracking, and a premium subscription that offers free delivery and savings. Emphasizing the importance of privacy, it suggests using virtual numbers to safeguard personal information during registration. Overall, it serves as a practical resource for users looking for a secure and efficient way to set up their Walmart accounts.
ReplyDeleteVisit us:- https://pvapins.com/?/EN
Many potential users want to know how to register for WeChat from outside China. However, they may encounter two main issues: the app might freeze during verification, and they may need another user to scan a QR code for account activation. This user must have been registered for at least a month. These challenges often arise from location (IP address), local mobile operators, and email services. A VPN can help address location issues, but obtaining a mobile number from a foreign operator can be tricky. Visit us:- https://pvapins.com/?/EN
ReplyDeleteThis article offers a great glimpse into the diversity of Canadian names, blending both English and French influences. It's interesting to see how names like Liam, Noah, and Emma have become so popular, while also showcasing the rich multiculturalism of Canada through surnames like Tremblay and Dupuis. It’s a reminder of how names can reflect not only personal identity but also a country's unique cultural and linguistic landscape.
ReplyDeleteVisit us:- https://pvapins.com/?/EN