"Sping Secret" 24, spring Framework for JMS Integration (no environment version, later when learning MQ again) & Task scheduling and thread pool

Source: Internet
Author: User
Tags message queue

I don't know that well, so this needs to be studied.

JMS has 2 types of message domains

Point-to-point mode 1.

2. Publish subscription mode Publish/subscribe pub/sub mode

Traditional JMS API Development

Currently there is no environment, so now write a demo, back to the environment to test a

Package Jms;import Javax.jms.connection;import Javax.jms.connectionfactory;import javax.jms.destination;import Javax.jms.jmsexception;import Javax.jms.messageproducer;import Javax.jms.session;import javax.jms.TextMessage; Import Javax.naming.context;import Javax.naming.initialcontext;import Javax.naming.namingexception;import org.junit.test;/** * Test JMS method * @author xiaof * */public class JmsTest1 {/** * JMS message send */@Testpublic void test1 () {Connecti on con = null; Session session = Null;try {//get jndicontext context = new InitialContext (); ConnectionFactory connectionfactory = (connectionfactory) context.lookup ("Jndi/jms/connectionfactory");D estination Destination = (destination) context.lookup ("jndi/jms/destination"); con = connectionfactory.createconnection ();// Create Connection Session = Con.createsession (false, Session.auto_acknowledge); MessageProducer messageproducer = session.createproducer (destination); Set Object TextMessage message = Session.createtextmessage (); Message.settext ("Hi"); Messageproducer.send (message); Messageproducer.close (); Session.close ();} catch (Namingexception e) {//Todo auto-generated catch Blocke.printstacktrace ();} catch (JMSException e) {//Todo Auto-ge Nerated catch Blocke.printstacktrace ();} Finally {//close resource if (con! = null) {try {con.close ()} catch (JMSException e) {//TODO auto-generated catch Blocke.printstackt Race ();}}}}

  

Spring improved post- JMS

Jmstemplate again, see the template I will not more BB, we know, now understand, template mode is really very powerful

I don't have a lot of BB, everybody go to see the template package, I'm sick of it.

Anyway, this template just encapsulates a bunch of methods to simplify our operation.

Forget it, watch the message queue and then add it.

Task scheduling and thread pooling support in spring

Quartz

Divided:

Job,jobdetail,trigger,scheduler

How does spring fit into the quartz?

The timer in the JDK

"Sping Secret" 24, spring Framework for JMS Integration (no environment version, later when learning MQ again) & Task scheduling and thread pool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.