D:\Software\Softwares\MQ7.0.1.5_cdimage_trial\cdimage_trial
- Install
MQSeries using Softwares\MQ7.0.1.3_cdimage_trial\cdimage_trial\Setup.exe.
- Click
WebSphere MQ Installation button. You might receive an
error that WebSphere Eclipse Platform Version 3.0.1 is not installed.
- Click
on the “View Launchpad”. Click the Software Requirements button.
- Expand
WebSphere Eclipse Platform Version 3.0.1 and click on Network PB. Go
to the folder <
Softwares\MQ7.0.1.3_cdimage_trial> \cdimage_trial\Prereqs\IES and
click on setup.exe file will be already entered so click the Open PB.
The installation will begin.
- Click OK PB
for the language. Default is English.
- Click
Next PB on the welcome screen for WebSphere Eclipse Platform.
- Select I
accept the terms in the license agreement RB, click Next PB.
- Click Next PB
for the destination Folder.
- Click
the Install PB to begin the installation of WebSphere
Eclipse platform.
- Click
the Finish PB and now click Refresh button. WebSphere
Eclipse Platform Version 3.0.1 is installed.
- Click
WebSphere MQ Installation button.
- Click Launch
WebSphere MQ Installer button.
- Welcome
window click Next PB.
- Select I
accept the terms in the license agreement RB, click Next PB.
- Select Custom RB
and click Next PB.
- Click Change PB,
enter C:\MQSeries for folder name, click OK PB.
- Click Next PB.
- Click Next PB,
when it indicates data-files folder, leave as C:\MQSeries.
- Click Next PB,
when it indicates log files folder, C:\MQSeries\log.
- Select
all 4 features (Server, Client, Java Messaging, and Development
Toolkit) on Features window.
- Click Next PB.
- Click Install PB.
- Answer
‘Yes’ to license query about purchasing sufficient license units.
- Click
the Finish PB when file copying completes.
- Click Next PB
when Prepare WebSphere MQ Wizard window appears. WebSphere MQ begins
setting itself up. Make sure the NO RB is
selected for the question - Are any of the domain controllers in your
network running Windows 2000 Server and then click NEXT PB.
- Click
the Setup the Default Configuration link to start the Default
Configuration Wizard.
- Click
Next PB.
- Click
Next PB.
- uncheck box Join
the queue manager to the default cluster called, and
click Next PB
- Click Finish PB,
Default configuration begins. Ignore ‘default configuration is partly
complete’ warning message. Click Close PB when
done.
- Click
Next PB in Prepare WebSphere MQ Wizard window.
- When
Wizard is finished, uncheck Launch WebSphere MQ Getting Started
Help and uncheck Launch Notepad to view the release
notes and click Finish PB.
- Some
users may receive the following error: MQSeries is not properly
configured. This error is caused because your NA\Login needs
to be added to the mqm group. If you get this error,
Click Cancel PB and follow steps 20-25.
- Click Start>Settings>Control
Panel>Administrative Tools>Computer Management.
- Expand Local
Users and Groups in left pane. Then Select Groups.
- In
Right Pane, double click on mqm. This opens the properties
window for the mqm group.
- Click Add PB,
select na.uis.kcm.com from Look in: drop down list.
- In
bottom pane enter your NA Domain login and
click Check Names PB. Your name will appear
underlined. Click OK PB. Now your NA Domain login
appears as a user of the mqm group.
- Click Apply PB,
then close out..
- Installation
is complete.
1.1. UnInstalling
WebSphere MQ 7.0.1.7
- Go to
control panel
- Select
programs and features.
- Select
IBM webservice MQ
- Uninstall
- If
need to reboot do it
- Else
if any warning is there just proceeded.
- Thanks
After than add
C:\MQSeries\java\lib and pest all jar file in build path
A system for sending messages to a message queue using IBM
MQ, utilizing multiple threads to handle tasks concurrently. Here’s an overview
of each part of the code:
Step-by-Step Explanation:
Step 1: Main Class (JmsMain)
This is the entry point of the application.
Ø Purpose:
ü
Create an instance of JmsCallMethod.
ü
Measure the execution time of the threadCreation()
method, which is responsible for sending messages concurrently using threads.
java
public class
JmsMain { static JmsCallMethod jmsCall; public static void main(String[] args)
throws InterruptedException, ExecutionException { long startTime =
System.currentTimeMillis(); jmsCall = new JmsCallMethod(); jmsCall.threadCreation(); // Create threads and send messages long endTime =
System.currentTimeMillis(); long totalTime = endTime - startTime; System.out.println("Total execution
time: " + totalTime + " ms"); } } |
Step 2: JmsCallMethod Class
This class is responsible for handling the actual MQ
operations, including sending messages and creating multiple threads for task
execution.
Ø Key
methods:
ü
sendMessage(): Sends a message to a specified
queue using the QueueInterfaceImpl implementation.
ü
threadCreation(): Creates multiple threads using
an ExecutorService to execute MyThread instances (which send messages).
java
public class
JmsCallMethod { QueueInterfaceImpl qmimpl = new
QueueInterfaceImpl(); // Sends a message to the queue void sendMessage() { String qname = "csanfmstatus"; String qManager =
"QM_IN_MANDALKC_1"; final String text = "<Emp
id=\"1\"><name>Kartik</name><age>30</age><role>Developer</role><gen>Male</gen></Emp>"; try { qmimpl.sendMessage(qManager, qname,
text); } catch (JMSException e) { e.printStackTrace(); } } // Creates threads to send messages
concurrently void threadCreation() throws
InterruptedException, ExecutionException { ExecutorService executor =
Executors.newFixedThreadPool(20); for (int i = 0; i < 20; i++) { executor.execute(new
MyThread("TaskTwo" + i, i));
// Create and execute threads } executor.shutdown(); executor.awaitTermination(1,
TimeUnit.SECONDS); System.out.println("All tasks are
finished!"); } } |
Step 3: MyThread Class
This class implements Runnable and is responsible for
sending messages when executed by the threads.
Ø Key
methods:
ü
run(): This is the core method executed by each
thread, where it sends a message to the queue and logs the time taken for
execution.
java
public class
MyThread implements Runnable { JmsCallMethod jmsCall = new
JmsCallMethod(); private String myName; private int count; MyThread(String name, int newcount) { this.myName = name; this.count = newcount; } @Override public void run() { long startTime =
System.currentTimeMillis(); jmsCall.sendMessage(); // Sends message using JmsCallMethod long endTime =
System.currentTimeMillis(); long totalTime = endTime - startTime; System.out.println("Thread name =
" + this.myName + " and execution time is = " + totalTime +
" ms"); } } |
Step 4: QueueInterface Interface
This is an interface that defines the contract for sending
messages.
Ø Key
methods:
ü
sendMessage(): Defines the method signature for
sending a message to the queue.
java
public
interface QueueInterface { void sendMessage(String queueManagerName,
String queueName, String sendTextMessage) throws JMSException; } |
Step 5: QueueInterfaceImpl Class
This is the implementation of the QueueInterface, which uses
IBM MQ to send messages to the queue.
Ø Key
methods:
ü
initialize(): Sets up the connection factory and
prepares the queue manager for message transmission.
ü
sendMessage(): Connects to the queue manager,
creates a session, and sends the message to the specified queue.
java
public class
QueueInterfaceImpl implements QueueInterface { public static MQQueueConnectionFactory
connectionFactory = null; public static MQQueueConnection connection
= null; public static MQQueueSession senderSession
= null; public static MQQueueSender senderQueue =
null; // Initializes the connection to the queue
manager public void initialize(String queueManager)
{ try { connectionFactory = new
MQQueueConnectionFactory();
connectionFactory.setHostName("localhost"); connectionFactory.setPort(1414);
connectionFactory.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE,
WMQConstants.WMQ_CM_BINDINGS);
connectionFactory.setQueueManager(queueManager);
connectionFactory.setChannel("SYSTEM.ADMIN.SVRCONN"); } catch (JMSException e) { e.printStackTrace(); } } @Override public void sendMessage(String
queueManagerName, String queueName, String sendTextMessage) throws
JMSException { initialize(queueManagerName); connection = (MQQueueConnection)
connectionFactory.createQueueConnection(); senderSession = (MQQueueSession)
connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); com.ibm.mq.jms.MQQueue queue =
(com.ibm.mq.jms.MQQueue) senderSession.createQueue(queueName); senderQueue = (MQQueueSender)
senderSession.createSender(queue); long uniqueNumber =
System.currentTimeMillis() % 1000; TextMessage message =
senderSession.createTextMessage(sendTextMessage + uniqueNumber); connection.start(); senderQueue.send(message); System.out.println("Sent message:
" + message.getText()); senderQueue.close(); senderSession.close(); connection.close(); } } |
Summary:
Ø Multithreading:
The JmsCallMethod class creates multiple threads using ExecutorService, and
each thread sends a message to an IBM MQ queue.
Ø Message
Sending: The QueueInterfaceImpl class manages the connection to IBM MQ and
sends the actual message.
Ø Message
Construction: The messages being sent are in XML format, representing an
employee entity.
This architecture can be scaled by adjusting the number of
threads and is suitable for high-throughput messaging systems.
In PTP model |
0 Comments