0

Я пишу образец публикации/подписчика и разворачиваю его на сервере приложений websphere в среде кластера. , но когда я подписываюсь на сообщение, каждое сообщение и только одно время было прочитано MDB. Я настроил прочную подписку в websphere и MDB, также установил Share durable subscriptions на always shared и установил Always activate MDBs in all servers. каждое сообщение было прочитано только один раз, я думаю, что он потребляет или что-то еще. Я установил @ActivationConfigProperty(propertyName = "useSharedSubscriptionInClusteredContainer",propertyValue = "false") в MDB (на основе http://docs.oracle.com/cd/E18930_01/html/821-2438/gjzpg.html#MQAGgjzpg), но ничего не произошло. Я не могу подписывать сообщения на всех серверах. Также я установил messaging engine policy в High availability в шину websphere. Default messaging provider используется.jms publish/subscribe в кластере 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(); 
     } 

    } 
} 

и мой абонент

@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(); 
     } 
    } 

} 

ответ

0

Я решил проблему, отключив messaging engine policy в WEBSPHERE автобусе. Теперь он работает хорошо.

Смежные вопросы