0

게시/구독자 샘플을 작성하고 클러스터 환경의 websphere 애플리케이션 서버에 배포합니다. 그러나 메시지를 구독 할 때 MDB는 각 메시지와 단 한 번만 읽습니다. websphere 및 MDB에서 영구 가입을 구성했으며 Share durable subscriptionsalways shared으로 설정하고 Always activate MDBs in all servers을 설정했습니다. 각 메시지는 한 번만 읽었지만 소비하거나 다른 것으로 생각합니다. 을 MDB (http://docs.oracle.com/cd/E18930_01/html/821-2438/gjzpg.html#MQAGgjzpg 기준)로 설정했지만 아무 일도 발생하지 않았습니다. 모든 서버에서 메시지를 구독 할 수 없습니다. 또한 웹 스피어 버스에서 messaging engine policyHigh availability으로 설정합니다. Default messaging provider이 사용됩니다.websphere 클러스터에서 jms 게시/구독

어디에 문제가 있습니까 ??

여기 내 발행인

@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

I은 ​​WebSphere 버스에 messaging engine policy을 사용하지 않도록 설정하여 문제를 해결합니다. 이제는 잘 작동합니다.