forked from 888xin/activeMQ
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xin
committed
Feb 8, 2015
0 parents
commit 6223c25
Showing
244 changed files
with
2,592 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="FacetManager"> | ||
<facet type="web" name="Web"> | ||
<configuration> | ||
<descriptors> | ||
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" /> | ||
</descriptors> | ||
<webroots> | ||
<root url="file://$MODULE_DIR$/web" relative="/" /> | ||
</webroots> | ||
</configuration> | ||
</facet> | ||
</component> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="activemq1" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Tomcat8" level="application_server_libraries" /> | ||
</component> | ||
</module> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" | ||
xsi:schemaLocation="http://www.springframework.org/schema/context | ||
http://www.springframework.org/schema/context/spring-context-2.5.xsd | ||
http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" | ||
default-lazy-init="true"> | ||
|
||
<bean id="listenerContainer" | ||
class="org.springframework.jms.listener.DefaultMessageListenerContainer"> | ||
<property name="connectionFactory" ref="connectionFactory"></property> | ||
<property name="destination" ref="messageQueue"></property> | ||
<property name="messageListener" ref="receiveMessageListener"></property> | ||
</bean> | ||
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> | ||
<property name="jndiName" value="java:comp/env/myJMS/ConnectionFactory"></property> | ||
</bean> | ||
<bean id="messageQueue" class="org.springframework.jndi.JndiObjectFactoryBean"> | ||
<property name="jndiName" value="java:comp/env/myJMS/MessageQueue"></property> | ||
</bean> | ||
<bean id="receiveMessageListener" | ||
class="org.shirdrn.spring.jms.integration.ReceiveMessageListener"></bean> | ||
|
||
<bean id="messageSender" class="org.shirdrn.spring.jms.integration.MessageSender"> | ||
<property name="jmsTemplate" ref="jmsTemplate"></property> | ||
</bean> | ||
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> | ||
<property name="connectionFactory" ref="connectionFactory"></property> | ||
<property name="defaultDestination" ref="messageQueue"></property> | ||
</bean> | ||
|
||
<bean id="sendMessageController" | ||
class="org.shirdrn.spring.jms.integration.SendMessageController"> | ||
<property name="messageSender" ref="messageSender" /> | ||
<property name="successView" value="/success" /> | ||
</bean> | ||
<bean id="urlMapping" | ||
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> | ||
<property name="mappings"> | ||
<props> | ||
<prop key="/sendMessage.do">sendMessageController</prop> | ||
</props> | ||
</property> | ||
</bean> | ||
<bean id="viewResolver" | ||
class="org.springframework.web.servlet.view.InternalResourceViewResolver"> | ||
<property name="requestContextAttribute" value="rc" /> | ||
<property name="viewClass" | ||
value="org.springframework.web.servlet.view.JstlView" /> | ||
<property name="prefix" value="/" /> | ||
<property name="suffix" value=".jsp" /> | ||
</bean> | ||
|
||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# This is the configuring for logging displayed in the Application Server | ||
log4j.rootCategory=DEBUG, stdout | ||
|
||
# Replace the line above if you want to put a log file into the directory | ||
# you start Tomcat from | ||
# log4j.rootCategory=INFO, stdout, R | ||
|
||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
|
||
# Pattern to output the caller's file name and line number. | ||
log4j.appender.stdout.layout.ConversionPattern=%t %d{dd/MM HH:mm:ss,SSS} %p [%20.30c{2}]-%L %m%n | ||
|
||
log4j.appender.R=org.apache.log4j.RollingFileAppender | ||
|
||
# You can change this to be an absolute path or even an environment variable | ||
# If you're using an environment variable, you will have to set JAVA_OPTS | ||
# to contain this variables - for example in the catalina.sh or catalina.bat | ||
# file | ||
|
||
log4j.appender.R.File=${catalina.home}/logs/euctia.log | ||
|
||
log4j.appender.R.MaxFileSize=1000KB | ||
|
||
# Don't keep a backup file | ||
log4j.appender.R.MaxBackupIndex=10 | ||
|
||
log4j.appender.R.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.R.layout.ConversionPattern=%t %d{dd/MM HH:mm:ss,SSS} %p [%20.30c{2}]-%L %m%n | ||
|
||
log4j.logger.com.eucita=DEBUG | ||
log4j.logger.com.eucita.component.acegi=WARN | ||
log4j.logger.com.eucita.utils.GenericsUtils=ERROR | ||
|
||
# If programmed properly the most messages would be at DEBUG | ||
# and the least at FATAL. | ||
|
||
# Control logging for other open source packages | ||
#log4j.logger.org.apache.commons=ERROR | ||
log4j.logger.org.springframework=DEBUG | ||
log4j.logger.org.acegisecurity=WARN | ||
log4j.logger.org.springframework.transaction=WARN | ||
log4j.logger.com.ibatis=DEBUG | ||
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG | ||
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG | ||
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG | ||
log4j.logger.java.sql.Connection=DEBUG | ||
log4j.logger.java.sql.Statement=DEBUG | ||
log4j.logger.java.sql.PreparedStatement=WARN | ||
log4j.logger.java.sql.ResultSet=WARN | ||
log4j.logger.com.atomikos=WARN | ||
#log4j.logger.org.apache.activemq.command.ActiveMQObjectMessage=DEBUG | ||
#log4j.logger.org.springframework.jms.support.converter.MessageConverter=DEBUG | ||
log4j.logger.org.springframework.aop.framework.Cglib2AopProxy=ERROR | ||
|
||
|
||
|
||
|
33 changes: 33 additions & 0 deletions
33
springMQ1/src/org/shirdrn/spring/jms/integration/MessageSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.shirdrn.spring.jms.integration; | ||
|
||
import javax.jms.JMSException; | ||
import javax.jms.Message; | ||
import javax.jms.Session; | ||
import javax.jms.TextMessage; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.springframework.jms.core.JmsTemplate; | ||
import org.springframework.jms.core.MessageCreator; | ||
|
||
public class MessageSender { | ||
|
||
private static final Logger LOG = Logger.getLogger(MessageSender.class); | ||
private JmsTemplate jmsTemplate; | ||
|
||
public void setJmsTemplate(JmsTemplate jmsTemplate) { | ||
this.jmsTemplate = jmsTemplate; | ||
} | ||
|
||
public void sendMessage(final String message) { | ||
LOG.info("Send message: " + message); | ||
jmsTemplate.send(new MessageCreator() { | ||
|
||
public Message createMessage(Session session) throws JMSException { | ||
TextMessage textMessage = session.createTextMessage(message); | ||
return textMessage; | ||
} | ||
|
||
}); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
springMQ1/src/org/shirdrn/spring/jms/integration/ReceiveMessageListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.shirdrn.spring.jms.integration; | ||
|
||
import javax.jms.JMSException; | ||
import javax.jms.Message; | ||
import javax.jms.MessageListener; | ||
import javax.jms.TextMessage; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
public class ReceiveMessageListener implements MessageListener { | ||
|
||
private static final Logger LOG = Logger.getLogger(ReceiveMessageListener.class); | ||
|
||
public void onMessage(Message message) { | ||
if (message instanceof TextMessage) { | ||
TextMessage text = (TextMessage) message; | ||
try { | ||
LOG.info("Received message:" + text.getText()); | ||
} catch (JMSException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
springMQ1/src/org/shirdrn/spring/jms/integration/SendMessageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.shirdrn.spring.jms.integration; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.springframework.web.servlet.ModelAndView; | ||
import org.springframework.web.servlet.mvc.multiaction.MultiActionController; | ||
|
||
public class SendMessageController extends MultiActionController { | ||
|
||
private String successView; | ||
private MessageSender messageSender; | ||
|
||
public ModelAndView sendMessage(HttpServletRequest request, | ||
HttpServletResponse response) throws Exception { | ||
|
||
Map<String, Object> retMap = new HashMap<String, Object>(); | ||
String message = request.getParameter("message"); | ||
messageSender.sendMessage(message); | ||
|
||
return new ModelAndView(successView, retMap); | ||
} | ||
|
||
public String getSuccessView() { | ||
return successView; | ||
} | ||
|
||
public void setSuccessView(String successView) { | ||
this.successView = successView; | ||
} | ||
|
||
public MessageSender getMessageSender() { | ||
return messageSender; | ||
} | ||
|
||
public void setMessageSender(MessageSender messageSender) { | ||
this.messageSender = messageSender; | ||
} | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | ||
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> | ||
|
||
<context-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value> | ||
classpath:activemq.xml | ||
</param-value> | ||
</context-param> | ||
<listener> | ||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | ||
</listener> | ||
|
||
<servlet> | ||
<servlet-name>controller</servlet-name> | ||
<servlet-class> | ||
org.springframework.web.servlet.DispatcherServlet | ||
</servlet-class> | ||
<init-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value> | ||
classpath:activemq.xml | ||
</param-value> | ||
</init-param> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>controller</servlet-name> | ||
<url-pattern>*.do</url-pattern> | ||
</servlet-mapping> | ||
|
||
|
||
<welcome-file-list> | ||
<welcome-file>index.jsp</welcome-file> | ||
</welcome-file-list> | ||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> | ||
<% | ||
String path = request.getContextPath(); | ||
String basePath = request.getScheme() + "://" | ||
+ request.getServerName() + ":" + request.getServerPort() | ||
+ path + "/"; | ||
%> | ||
|
||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html> | ||
<head> | ||
<base href="<%=basePath%>"> | ||
|
||
<title>My JSP 'index.jsp' starting page</title> | ||
<meta http-equiv="pragma" content="no-cache"> | ||
<meta http-equiv="cache-control" content="no-cache"> | ||
<meta http-equiv="expires" content="0"> | ||
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> | ||
<meta http-equiv="description" content="This is my page"> | ||
<!-- | ||
<link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css"> | ||
--> | ||
</head> | ||
|
||
<body> | ||
<div align="center" style="width: 500px; height: 300px; border:2px; borderColor:black"> | ||
<form action="sendMessage.do" method="post"> | ||
<table align="center"> | ||
<tr> | ||
<th colspan="2"> | ||
消息发送控制台 | ||
</th> | ||
</tr> | ||
<tr> | ||
<td> | ||
消息内容: | ||
</td> | ||
<td> | ||
<input type="text" name="message"> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td align="center" colspan="2"> | ||
<input type="reset" value="清除"> | ||
| ||
<input type="submit" value="发送"> | ||
</td> | ||
</tr> | ||
</table> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> | ||
<% | ||
String path = request.getContextPath(); | ||
String basePath = request.getScheme() + "://" | ||
+ request.getServerName() + ":" + request.getServerPort() | ||
+ path + "/"; | ||
%> | ||
|
||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html> | ||
<head> | ||
<base href="<%=basePath%>"> | ||
|
||
<title>My JSP 'index.jsp' starting page</title> | ||
<meta http-equiv="pragma" content="no-cache"> | ||
<meta http-equiv="cache-control" content="no-cache"> | ||
<meta http-equiv="expires" content="0"> | ||
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> | ||
<meta http-equiv="description" content="This is my page"> | ||
<!-- | ||
<link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css"> | ||
--> | ||
</head> | ||
|
||
<body> | ||
<div align="center" style="width: 500px; height: 300px; border:2px; borderColor:black"> | ||
<form action="sendMessage.do" method="post"> | ||
<table align="center"> | ||
<tr> | ||
<th colspan="2"> | ||
消息发送报告 | ||
</th> | ||
</tr> | ||
<tr> | ||
<td colspan="2"> | ||
状态:发送成功 | ||
</td> | ||
</tr> | ||
<tr> | ||
<td align="center" colspan="2"> | ||
<a href="index.jsp" mce_href="index.jsp">返回</a> | ||
</td> | ||
</tr> | ||
</table> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.