org.quartz.jobs.ee.jms
public class: SendDesitnationMessageJob [javadoc |
source]
java.lang.Object
org.quartz.jobs.ee.jms.SendDesitnationMessageJob
All Implemented Interfaces:
Job
A Job that sends a javax.jms.Message to a
javax.jms.Destination. Note, this class can only be used in a JMS 1.1
compliant environment.
The following properties are expected to be provided in the JobDataMap:
JMS_CONNECTION_FACTORY_JNDI - The JNDI name of the JMS Connection Factory.
JMS_DESTINATION_JNDI - The JNDI name of the JMS destination.
JMS_USE_TXN - Whether or not to use a transacted javax.jms.Session.
JMS_ACK_MODE - The acknowledgement mode for the javax.jms.Session.
JMS_MSG_FACTORY_CLASS_NAME - The implementation class name for the JmsMessageFactory.
The following properties are optional
JMS_USER - The JMS user for secure destinations.
JMS_PASSWORD - The JMS password for secure destinations.
The following properties can be used for JNDI support:
INITIAL_CONTEXT_FACTORY - The java.naming.factory.initial setting for JNDI.
PROVIDER_URL - The java.naming.provider.url for JNDI.
| Method from org.quartz.jobs.ee.jms.SendDesitnationMessageJob Summary: |
|---|
|
execute |
| Method from org.quartz.jobs.ee.jms.SendDesitnationMessageJob Detail: |
public void execute(JobExecutionContext context) throws JobExecutionException {
ConnectionFactory factory = null;
Connection connection = null;
Session session = null;
MessageProducer producer = null;
Destination destination = null;
InitialContext initCtx = null;
JobDetail detail = context.getJobDetail();
JobDataMap jobDataMap = detail.getJobDataMap();
try {
initCtx = org.quartz.jobs.ee.jms.JmsHelper.getInitialContext(jobDataMap);
factory = (ConnectionFactory) initCtx.lookup(org.quartz.jobs.ee.jms.JmsHelper.JMS_CONNECTION_FACTORY_JNDI);
if(org.quartz.jobs.ee.jms.JmsHelper.isDestinationSecure(jobDataMap))
{
String user = jobDataMap.getString(org.quartz.jobs.ee.jms.JmsHelper.JMS_USER);
String pw = jobDataMap.getString(org.quartz.jobs.ee.jms.JmsHelper.JMS_PASSWORD);
connection = factory.createConnection(user, pw);
} else {
connection = factory.createConnection();
}
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = (Destination) initCtx.lookup(org.quartz.jobs.ee.jms.JmsHelper.JMS_DESTINATION_JNDI);
producer = session.createProducer(destination);
String factoryClass = jobDataMap.getString(org.quartz.jobs.ee.jms.JmsHelper.JMS_MSG_FACTORY_CLASS_NAME);
org.quartz.jobs.ee.jms.JmsMessageFactory messageFactory = org.quartz.jobs.ee.jms.JmsHelper.getMessageFactory(factoryClass);
Message m = messageFactory.createMessage(jobDataMap, session);
producer.send(m);
} catch (NamingException e) {
throw new JobExecutionException(e);
} catch (JMSException e) {
throw new JobExecutionException(e);
} catch (JmsJobException e) {
throw new JobExecutionException(e);
}finally{
JmsHelper.closeResource(producer);
JmsHelper.closeResource(session);
JmsHelper.closeResource(connection);
}
}
|