嗨我是Spring JMS和websphere MQ的新手。可以任何人给我一步一步的过程或例如如何接收来自websphere MQ的消息,并能够在控制台中打印该消息 非常感谢您的帮助Spring JMS和Websphere MQ
回答
下面是使用Spring的MDP /激活规范为WebSphere MQ
MDP-listener.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<bean id="messageListener" class="com.rohid.samples.SpringMdp" />
<bean class="org.springframework.jms.listener.endpoint.JmsMessageEndpointManager">
<property name="activationSpec">
<bean class="com.ibm.mq.connector.inbound.ActivationSpecImpl">
<property name="destinationType" value="javax.jms.Queue"/>
<property name="destination" value="QUEUE1"/>
<property name="hostName" value="A.B.C"/>
<property name="queueManager" value="QM_"/>
<property name="port" value="1414"/>
<property name="channel" value="SYSTEM.ADMIN.SVNNN"/>
<property name="transportType" value="CLIENT"/>
<property name="userName" value="abc"/>
<property name="password" value="jabc"/>
</bean>
</property>
<property name="messageListener" ref="messageListener"/>
<property name="resourceAdapter" ref="myResourceAdapterBean"/>
</bean>
<bean id="myResourceAdapterBean" class ="org.springframework.jca.support.ResourceAdapterFactoryBean">
<property name="resourceAdapter">
<bean class="com.ibm.mq.connector.ResourceAdapterImpl">
<property name="maxConnections" value="50"/>
</bean>
</property>
<property name="workManager">
<bean class="org.springframework.jca.work.SimpleTaskWorkManager"/>
</property>
</bean>
</beans>
的web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context/mdp-listener.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
SpringMdp
package com.rohid.samples;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
public class SpringMdp implements MessageListener {
public void onMessage(Message message) {
try {
if(message instanceof TextMessage) {
System.out.println(this + " : " + ((TextMessage) message).getText());
}
} catch (JMSException ex){
throw new RuntimeException(ex);
}
}
}
工作示例
'
这些是为WMQ V5.3编写的,但大多仍然应用。 WMQ管理员所做的更改与连接和配置有关。
developerWorks: The Spring Series
请务必包括WMQ服务器和客户端对未来岗位的版本,因为在Java/JMS配置的细节上有所不同。另外,请务必使用与您正在使用的WMQ客户端或服务器版本相匹配的文档版本。
您可能还想考虑在JMS之上使用Spring集成;这里有一个示例使用ActiveMQ https://github.com/SpringSource/spring-integration-samples/tree/master/basic/jms - 您只需要将JMS配置更改为使用MQ。
样品读取来自控制台发送通过JMS消息,由消息驱动适配器读取,并且写入到控制台。
感谢您的答复和链接pshere MQ例子。当我downlad它给了我像20个不同的项目,我的cdnt找到需要的例子或既不运行它。我只是想简单的例子能够运行 – nepJava
?困惑?链接指向GitHub上关于如何运行它的自述文件的示例。简单地克隆Github示例回购并按照说明操作。 –
我刚刚经历过这个自己。先从Spring Boot JMS Starter
添加一个bean提供MQQueueConnectionFactory
@Configuration
@EnableJms
public class MQConfiguration {
@Bean
public MQQueueConnectionFactory mqFactory()
{
MQQueueConnectionFactory factory = null;
try {
factory = new MQQueueConnectionFactory();
factory.setHostName("localhost");
factory.setPort(1414);
factory.setQueueManager("QM.LOCAL");
factory.setChannel("SYSTEM.DEF.SVRCONN");
factory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
}
catch (JMSException e) {
System.out.println(e);
}
return factory;
}
}
卸下org.apache.activemq/ActiveMQ的经纪人的依赖,以确保ActiveMQ的不潜行它到底。
添加依赖于com.ibm.mqjms.jar,com.bim.mq.jmqi.jar,dhbcore.jar
运行
- 1. Spring-JMS(Websphere MQ)
- 2. Spring,Websphere,JMS和Eclipselink问题
- 3. IBM WebSphere MQ JMS Jar文件
- 4. WebSphere中的JMS,MQ异常
- 5. 使用JMS的WebSphere MQ
- 6. Websphere MQ JMS - 配置选项
- 7. JMS的WebSphere MQ BytesMessge和TextMessage的
- 8. 的WebSphere MQ 7with春JMS - 无限交付
- 9. ClassNotFoundException:com.ibm.mq.jms.MQConnectionFactory(Websphere MQ 7.5 + spring jms + maven tomcat 7插件)
- 10. 从WebSphere MQ队列消费期间Spring JMS超时到期
- 11. IBM MQ vs JMS - Spring实现
- 12. JMS与Spring和Webspehre集成的JNDI MQ
- 13. wso2 ESB - websphere MQ JMS丢失连接
- 14. JMS无法连接到WebSphere MQ
- 15. 春JMS到WebSphere MQ连接错误
- 16. Spring JmsTemplate&WebSphere MQ - 忽略RECEIVE_TIMEOUT_NO_WAIT
- 17. Websphere MQ使用JMS,闭合连接停留在MQ
- 18. WebSphere MQ是WebSphere AS 8/8.5中的默认JMS提供者吗?
- 19. 配置WebMethods客户端以连接到WebSphere JMS(非WebSphere MQ)
- 20. IBM Websphere MQ Monitoring
- 21. Spring MQ JMS重新连接配置
- 22. Websphere JMS部署错误
- 23. Websphere + Spring DMLC + MQ -J2CA0045E:为资源JMS调用方法createOrWaitForConnection时连接不可用
- 24. JMS,MQ-Series,MQ-Queue,MDB
- 25. Websphere MQ和高可用性
- 26. Websphere MQ和版本控制
- 27. Websphere MQ主题和SSL
- 28. WebSphere Camel JMS,spring,taskExecutor,haninging线程
- 29. Mdb Glasswish Websphere MQ
- 30. MQ WebSphere MessageID Woes
我发布了春季MDP /激活规范/网络在 http://stackoverflow.com/questions/7390286/whats-the-difference-between-activationspec-and-connectionfactory – user3344338