Hi All,
I’m looking for pointers to drop/publish a message to a Queue using JMS from AEM 6.5.
I referred an old post, but that doesn’t help- https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/jms-client-in-aem-using-we...
Can anyone provide me input here?
Thanks,
Raju.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Can you elaborate on what you are trying to accomplish? I am under the impression that you could use alternatives such as Sling Jobs https://techrevel.blog/2023/11/06/enhancing-efficiency-and-reliability-by-sling-jobs/
Check these for now:
Hi,
Can you elaborate on what you are trying to accomplish? I am under the impression that you could use alternatives such as Sling Jobs https://techrevel.blog/2023/11/06/enhancing-efficiency-and-reliability-by-sling-jobs/
Check these for now:
@Rajumuddana Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Hi all,
I did figure out the way to integrate JMS with AEM as a Client application.
The first challenge was finding the right dependencies, after a struggle I managed to get the required jar files and created OSGI bundles out of those with few Import/Export packages changes.
Below is the dependent jars
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId>
<version>9.4.1.0</version>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
</dependency>
Sample code to make a connection and post a message from our application.
The MQ Queue related details used in below code are from different team (they work on MQ Queue server side).
public class JmsMwssage {
// Create variables for the connection to MQ
//private static final String HOST = "_YOUR_HOSTNAME_"; // Host name or IP address
private static String HOST = ""; // Host name or IP address
private static int PORT = 0; // Listener port for your queue manager
private static String CHANNEL = ""; // Channel name
private static String QMGR = ""; // Queue manager name
private static String APP_USER = ""; // User name that application uses to connect to MQ
private static String APP_PASSWORD = ""; // Password that the application uses to connect to MQ
private static String QUEUE_NAME = ""; // Queue that the application uses to put and get messages to and from
//public static void main(String[] args) {
public static void sendMessage() {
//Values from OSGI config
HOST = “”;//Fetch your values from Config.
PORT=“”;//Fetch your values from Config.
CHANNEL=“”;//Fetch your values from Config
QMGR=“”;//Fetch your values from Config
// Variables
JMSContext context = null;
Destination destination = null;
JMSProducer producer = null;
try {
// Create a connection factory
JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQ_PROVIDER);
JmsConnectionFactory cf = ff.createConnectionFactory();
// Set the properties
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, HOST);
cf.setIntProperty(WMQConstants.WMQ_PORT, PORT);
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, CHANNEL);
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, QMGR);
cf.setStringProperty(WMQConstants.WMQ_APPLICATIONNAME, "JmsPutGet (JMS)");
cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
cf.setStringProperty(WMQConstants.USERID, APP_USER);
cf.setStringProperty(WMQConstants.PASSWORD, APP_PASSWORD);
// Create JMS objects
context = cf.createContext();
destination = context.createQueue("queue:///" + QUEUE_NAME);
producer = context.createProducer();
producer.send(destination, message);
System.out.println("Sent message:\n" + message);
context.close();
} catch (JMSException jmsex) {
//Log your Exception here
}
}
}
Thanks,
Raju.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Like
Replies