websphere集群中的jms发布/订阅
我编写了一个发布/订户示例,并将其部署在集群环境中的WebSphereApplicationServer上。 但是当我订阅消息时,MDB只读取了每条消息,并且只读取了一次。 我在websphere和MDB中配置了持久订阅,还将websphere集群中的jms发布/订阅,jms,websphere,java-ee-6,publish-subscribe,message-driven-bean,Jms,Websphere,Java Ee 6,Publish Subscribe,Message Driven Bean,我编写了一个发布/订户示例,并将其部署在集群环境中的WebSphereApplicationServer上。 但是当我订阅消息时,MDB只读取了每条消息,并且只读取了一次。 我在websphere和MDB中配置了持久订阅,还将共享持久订阅设置为始终共享,并将始终激活所有服务器中的MDB设置为。 每封邮件只读了一次,我想它会消耗你的精力或者其他什么。 我在MDB中设置了@ActivationConfigProperty(propertyName=“UseSharedSubscriptionClus
共享持久订阅设置为始终共享,并将始终激活所有服务器中的MDB设置为。
每封邮件只读了一次,我想它会消耗你的精力或者其他什么。
我在MDB中设置了@ActivationConfigProperty(propertyName=“UseSharedSubscriptionClusteredContainer”,propertyValue=“false”)
(基于),但什么也没发生。
我无法在所有服务器上订阅邮件。
我还在websphere总线中将消息传递引擎策略设置为高可用性。
使用默认消息传递提供程序
问题出在哪里
这是我的出版商
@WebServlet("/publishServlet")
public class Testpublish extends HttpServlet {
@Resource(mappedName = "jms/ConnFact")
private static TopicConnectionFactory topicConnectionFactory;
@Resource(mappedName = "jms/topicJ")
private static Topic topic;
TopicConnection connection = null;
TopicSession session = null;
TopicPublisher publisher = null;
TextMessage message = null;
final int NUM_MSGS = 5;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/plain");
ServletOutputStream out = response.getOutputStream();
out.println("Start Testing");
System.out.println("Start Testing");
try {
connection = topicConnectionFactory.createTopicConnection();
session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
publisher = session.createPublisher(topic);
message = session.createTextMessage();
for (int i = 0; i < NUM_MSGS; i++) {
message.setText("This is testMessage " + (i + 1));
System.out.println("Sending testMessage: " + message.getText());
out.println("Sending testMessage: " + message.getText());
publisher.publish(message);
}
connection.close();
out.println("Finish Testing");
System.out.println("Finish Testing");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
我通过在websphere总线中禁用消息传递引擎策略
解决了这个问题。现在它工作得很好
@MessageDriven(mappedName = "jms/topicJ", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "subscriptionDurability",propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "clientId",propertyValue = "MyID"),
@ActivationConfigProperty(propertyName = "subscriptionName",propertyValue = "MySub")
})
public class testsubscribe implements MessageListener {
@Override
public void onMessage(Message message) {
TextMessage txtMessage = (TextMessage) message;
try {
System.out.println("---------MESSAGE RECIEVED------------" + txtMessage.getText()
+ " ..............");
} catch (JMSException e) {
e.printStackTrace();
}
}
}