# Download RPM and Install wget http://www.rabbitmq.com/releases/rabbitmq-server/v2.4.1/rabbitmq-server-2.4.1-1.noarch.rpm rpm -Uvh rabbitmq-server-2.4.1-1.noarch.rpm # Two ways to Start RabbitMQ Server service rabbitmq-server start /usr/sbin/rabbitmq-server start -detached # Make RabbitMQ to Run as a Service chkconfig rabbitmq-server onReference: RabbitMQ
2011年6月8日 星期三
在CentOS上安裝RabbitMQ
標籤:
centos,
installation,
JMS,
rabbitmq
2011年6月6日 星期一
JMS: Resource Injection
Within the Java EE environment, objects bound within the Java EE context can use the @Resource annotation to inject the JMS resources into the code rather than performing a JNDI lookup using the InitialContext.
若使用Java EE所提供的Annotation,注入JMS Resource,則不需要在程式中使用InitialContext作JNDI的lookup。
Reference: Java Message Service
From Java Message Service
public class Lender {
TopicConnection conn = null;
TopicSession session = null;
Topic ratesTopic = null;
TopicPublisher publisher = null;
public Lender() {
try {
Context ctx = new InitialContext();
TopicConnectionFactory factory =
(TopicConnectionFactory)ctx.lookup("TopicCF");
conn = factory.createTopicConnection();
conn.start();
session =
conn.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
ratesTopic = (Topic)ctx.lookup("jms/Rates");
publisher = session.createPublisher(ratesTopic);
...
} catch (JMSException jmse) {
jmse.printStackTrace();
} catch (NamingException jne) {
jne.printStackTrace();
}
}
...
}
若使用Java EE所提供的Annotation,注入JMS Resource,則不需要在程式中使用InitialContext作JNDI的lookup。
@Stateless
@Remote(Lender.class)
public class LenderBean implements Lender {
@Resource(name="TopicCF") TopicConnectionFactory factory;
@Resource(name="jms/Rates") Topic ratesTopic;
TopicConnection conn = null;
TopicSession session = null;
TopicPublisher publisher = null;
@PostContruct
public void init() {
try {
conn = factory.createTopicConnection();
conn.start();
session =
conn.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
publisher = session.createPublisher(ratesTopic);
...
} catch (JMSException jmse) {
jmse.printStackTrace();
}
}
...
}
Reference: Java Message Service
標籤:
Java EE,
JMS,
JNDI,
Resource Injection
訂閱:
文章 (Atom)