Java Reference
In-Depth Information
■
Note To start ActiveMQ, you just execute one of the ActiveMQ startup scripts (the script itself is called
activemq.sh
, or
activemq.bat
for Unix-variants and Windows, respectively, and is located in the
bin
directory)
for your operating system.
package com.apress.springenterpriserecipes.post;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class FrontDeskMain {
public static void main(String[] args) {
ApplicationContext context =
new ClassPathXmlApplicationContext("beans-front.xml");
FrontDesk frontDesk = (FrontDesk) context.getBean("frontDesk");
frontDesk.sendMail(new Mail("1234", "US", 1.5));
}
}
package com.apress.springenterpriserecipes.post;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class BackOfficeMain {
public static void main(String[] args) {
ApplicationContext context =
new ClassPathXmlApplicationContext("beans-back.xml");
BackOffice backOffice = (BackOffice) context.getBean("backOffice");
Mail mail = backOffice.receiveMail();
System.out.println("Mail #" + mail.getMailId() + " received");
}
}
■
Note You're encouraged to use your messaging middleware's reporting functionality. In these examples, we're
using ActiveMQ. With the default installation, you can open
http://localhost:8161/admin/queueGraph.jsp
to
see what's happening with
mail.queue
, the queue used in these examples.
Search WWH ::
Custom Search