Тёмный

Java program for posting messages to Weblogic JMS (Java Messaging Service) Queue 

Ghoshal Academy
Подписаться 730
Просмотров 18 тыс.
50% 1

Java program for posting messages to Weblogic JMS (Java Messaging Service) Queue

Опубликовано:

 

15 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 19   
@chalapathirao3517
@chalapathirao3517 6 лет назад
Thanks Ghoshal. one query, How to integrate with spring boot?
@mahrshi
@mahrshi 5 лет назад
Its really very good
@rahulpoman
@rahulpoman 2 года назад
Hi Ghoshal, Do you know weblogic jms message is sent but not received at receiver side, how to verify this type of issue.
@loicroubaud1857
@loicroubaud1857 7 лет назад
Thanks a lot
@ghoshalacademy4367
@ghoshalacademy4367 8 лет назад
package com.ghoshalacademy.weblogic; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Hashtable; import javax.jms.JMSException; import javax.jms.Queue; import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory; import javax.jms.QueueSender; import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class QueuePoster { public final static String SERVER="t3://localhost:7001"; public final static String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory"; public final static String JMS_FACTORY="com.ghoshal.weblogic.base.cf"; public final static String QUEUE="com.ghoshal.weblogic.base.dq"; private QueueConnectionFactory queueConnectionFactory; private QueueConnection queueConnection; private QueueSession queueSession; private QueueSender queueSender; private Queue queue; private TextMessage message; public void init(Context context, String queueName) throws NamingException, JMSException { queueConnectionFactory = (QueueConnectionFactory) context.lookup(JMS_FACTORY); queueConnection = queueConnectionFactory.createQueueConnection(); queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queue = (Queue) context.lookup(queueName); queueSender = queueSession.createSender(queue); message = queueSession.createTextMessage(); queueConnection.start(); } public void post(String msg) throws JMSException { message.setText(msg); queueSender.send(message); } public void close() throws JMSException { queueSender.close(); queueSession.close(); queueConnection.close(); } private static void sendToServer(QueuePoster queuePoster) throws IOException, JMSException { BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in)); boolean readFlag=true; System.out.println("Enter messages to send to weblogic server (Enter quit to end):n"); while(readFlag) { System.out.print("Enter Message:"); String msg=bufferedReader.readLine(); if(msg.equals("quit")) { queuePoster.post(msg); System.exit(0); } queuePoster.post(msg); System.out.println(); } bufferedReader.close(); } private static InitialContext getInitialContext() throws NamingException { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY); env.put(Context.PROVIDER_URL, SERVER); return new InitialContext(env); } public static void main(String[] args) throws Exception { InitialContext initialContext = getInitialContext(); QueuePoster queuePoster = new QueuePoster(); queuePoster.init(initialContext, QUEUE); sendToServer(queuePoster); queuePoster.close(); } }
@pallavipurple
@pallavipurple 5 лет назад
Hello Ghosal Sir... In the previous video, where jms is configured in weblogic. There was a filesystem configured in jms server. Wanted to know what is tge significance of the filesystem or database when we are posting or reading the data..? Can we view the content og filesystem or database. Thanks. Pallavi
@NitishKumar-kl7vm
@NitishKumar-kl7vm 5 лет назад
Do you have file of JMS Programing? Can you give me download location?
@pundalikgawandi4570
@pundalikgawandi4570 2 года назад
Can I get source code for this program?
@Bat0u89
@Bat0u89 8 лет назад
you should provide the source code in the description :)
@ghoshalacademy4367
@ghoshalacademy4367 8 лет назад
Posted
@niteshkumar-ez8ci
@niteshkumar-ez8ci 8 лет назад
its not in the description
@rameshm1395
@rameshm1395 3 года назад
Full videos in weblogic admin plz
@ghoshalacademy4367
@ghoshalacademy4367 8 лет назад
package com.ghoshalacademy.weblogic; import java.util.Hashtable; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.Queue; import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory; import javax.jms.QueueReceiver; import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class QueueReader implements MessageListener{ public final static String SERVER="t3://localhost:7001"; public final static String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory"; public final static String JMS_FACTORY="com.ghoshal.weblogic.base.cf"; public final static String QUEUE="com.ghoshal.weblogic.base.dq"; private QueueConnectionFactory queueConnectionFactory; private QueueConnection queueConnection; private QueueSession queueSession; private QueueReceiver queueReceiver; private Queue queue; private Boolean quit=false; public void init(Context context, String queueName) throws NamingException, JMSException { queueConnectionFactory = (QueueConnectionFactory) context.lookup(JMS_FACTORY); queueConnection = queueConnectionFactory.createQueueConnection(); queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queue = (Queue) context.lookup(queueName); queueReceiver = queueSession.createReceiver(queue); queueReceiver.setMessageListener(this); queueConnection.start(); } public void close() throws JMSException { queueReceiver.close(); queueSession.close(); queueConnection.close(); } private static InitialContext getInitialContext() throws NamingException { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY); env.put(Context.PROVIDER_URL, SERVER); return new InitialContext(env); } public static void main(String[] args) throws Exception { InitialContext initialContext = getInitialContext(); QueueReader queueReader = new QueueReader(); queueReader.init(initialContext, QUEUE); System.out.println("Waiting to receive messages"); synchronized(queueReader){ while(!queueReader.quit) { try { queueReader.wait(); }catch(InterruptedException ie){} } queueReader.close(); } } @Override public void onMessage(Message msg) { try { String msgText; if (msg instanceof TextMessage) { msgText = ((TextMessage)msg).getText(); } else { msgText = msg.toString(); } System.out.println("Message Received: "+ msgText ); if (msgText.equalsIgnoreCase("quit")) { synchronized(this) { quit = true; this.notifyAll(); // Notify main thread to quit } } } catch (JMSException jmsException) { System.err.println("Exception: "+jmsException.getMessage()); } } }
Далее
ЗАБЛУДИЛИСЬ В ТРАВЕ #shorts
00:25
Просмотров 370 тыс.
Куда пропали ЗДРАЙВЕРЫ?
11:38
Просмотров 599 тыс.
Oracle Weblogic 12c Thread Monitoring
20:33
Просмотров 56 тыс.
Weblogic JMS Configuration
13:31
Просмотров 38 тыс.
Overview of WebLogic Distributed JMS
14:53
Просмотров 33 тыс.
How to Do 90% of What Plugins Do (With Just Vim)
1:14:03
Просмотров 894 тыс.