Refresh Your Java - Before Java Interview
We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....
WebSphere MQ is one of the very popular MOM server
which has been used by enormous number of
Organizations
as their message based integrator .
The following
code snippets and images illustrates how could the Web Sphere app
server be integrated with
WebSphere MQ.
Step 1:
Create a Queue Connection Factory:
Queue manager : The Queue manager name
(MQ Queue manager )
Hostname : The host name where you installed MQ
Server connection channel : SYSTEM.ADMIN.SVRCONN (this is generic Remote Queue Channel name in MQ)
Step 2:
Websphere queue :
Queue name : Queue of the MQ
queue
Queue manager or
Queue sharing group name : MQ Queue Manager
Name
Code :
Please note you are submitting your message to WebSphere , that
would in-turn submit the data
to WebSphere-MQ
, you are not directly submitting data to
WebSphere-MQ.
public static void
sendMessage(String inputXML)
{
try
{
String URL =
"iiop://w108v-wp2-015:2809";
String connectionfactoryjndi = "test/JMSCF";
String sendQueueName = "test/gcJMSQ";
Properties
props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.ibm.websphere.naming.WsnInitialContextFactory");
props.setProperty("java.naming.provider.url", URL);
Context
jndiContext = new InitialContext();
jndiContext =
new InitialContext(props);
QueueConnectionFactory cf =
(QueueConnectionFactory)jndiContext.lookup(connectionfactoryjndi);
System.out.println("Looked up : QueueConnectionFactory
" + connectionfactoryjndi);
System.out.println("Transport CCC Queue [" +
sendQueueName + "]");
QueueConnection
connection = cf.createQueueConnection();
QueueSession
session = connection.createQueueSession(false, 2);
Queue queue =
(Queue)jndiContext.lookup(sendQueueName);
QueueSender
sender = session.createSender(queue);
long
uniqueNumber = System.currentTimeMillis() % 1000L;
TextMessage
message = session.createTextMessage(inputXML);
connection.start();
sender.send(message);
sender.close();
session.close();
connection.close();
System.out.println("\\nSUCCESS\\n");
}
catch (JMSException jmsex) {
System.out.println(jmsex);
System.out.println("\\nFAILURE\\n");
}
catch (Exception ex) {
System.out.println(ex);
System.out.println("\\nFAILURE\\n");
}
}
This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,
This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.