活动MQ tcp连接失败

活动MQ tcp连接失败,tcp,jms,activemq,wso2esb,wso2carbon,Tcp,Jms,Activemq,Wso2esb,Wso2carbon,我使用的是活动MQ 5.10版本,我已将其配置为wso2esb以进行消息处理 大约7-10天后,活动MQ将抛出tcp连接失败异常,因为ESB未接收到成功的tcp连接,所以无法在队列中提交消息 在这种情况下,我重新启动服务器,它将再次运行7-10天,同样的事情会重复 我的问题是 活动MQ停止提供成功tcp连接的确切原因可能是什么 为什么重新启动服务器后会恢复正常状态 有没有解决这个问题的最好办法 activemq.xml文件中的内存配置 <systemUsage> <sys

我使用的是活动MQ 5.10版本,我已将其配置为wso2esb以进行消息处理

大约7-10天后,活动MQ将抛出tcp连接失败异常,因为ESB未接收到成功的tcp连接,所以无法在队列中提交消息

在这种情况下,我重新启动服务器,它将再次运行7-10天,同样的事情会重复

我的问题是

活动MQ停止提供成功tcp连接的确切原因可能是什么

为什么重新启动服务器后会恢复正常状态

有没有解决这个问题的最好办法

activemq.xml文件中的内存配置

<systemUsage>
   <systemUsage sendFailIfNoSpace="true">
         <memoryUsage>
                <memoryUsage limit="1430 mb"/>
          </memoryUsage>
          <storeUsage>
                <storeUsage limit="300 gb"/>
          </storeUsage>
          <tempUsage>
                <tempUsage limit="100 gb"/>
          </tempUsage>
    </systemUsage>
 </systemUsage>
ManagedLifecycle{

Connection connection;

public boolean mediate(MessageContext msgCtx) { 


     try {
         boolean topic=false;
        String jmsuri=""+msgCtx.getProperty("jmsuri");
        String t=""+msgCtx.getProperty("topic");

        if(t.isEmpty()){

            topic=false;
        }
        else {

            topic=Boolean.valueOf(t);
        }

        ConnectionFactory factory= new ActiveMQConnectionFactory(jmsuri);
        connection = factory.createConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination=null;
        if(!topic)destination= session.createQueue(""+msgCtx.getProperty("jmsqueue"));
        else destination= session.createTopic(""+msgCtx.getProperty("jmsqueue"));
        MessageProducer producer = session.createProducer(destination);
        producer.setDeliveryMode(DeliveryMode.PERSISTENT);

        String xml = ""+msgCtx.getEnvelope().getBody().toStringWithConsume();

        if(topic){

            JSONObject obj=XML.toJSONObject(xml);
            JSONObject ar=obj.getJSONObject("soapenv:Body");
            ar.remove("xmlns:soapenv");
            xml=ar.toString();
        }
        TextMessage message = session.createTextMessage(xml);
        producer.send(message);

    } catch (Exception e) {

        log.info("LogLocation = "+getClass().getName()+",Error in storing message in JMS stacktrace is :"+e.toString());
        ((Axis2MessageContext) msgCtx).setProperty(NhttpConstants.HTTP_SC, 500);
        handleException("Error while storing in the message store", msgCtx);

    }
    finally {
        try {
            connection.close();

        } catch (JMSException e) {
            log.info("LogLocation = "+getClass().getName()+",Error in closing JMS connection stacktrace is :"+e.toString());
        }
    }
        log.info("LogLocation = "+getClass().getName()+",ProxyName = "+msgCtx.getProperty("proxy.name")+
            ",Usercode = "+msgCtx.getProperty("usercode")+",Clientid = "+msgCtx.getProperty("clientid")+
            ",requestMsgId = "+msgCtx.getProperty("requestMsgId")+",Position = END"); 

    return true;
}

您应该共享proxys配置,但始终可以验证:

  • 您已设置cachelevel以避免每次扫描时出现新连接:
    消费者
  • 您已要求每次扫描时使用所有消息:
    -1

ActiveMQ中的消息数量是否与日俱增?您如何将AMQ与JMS代理服务、MessageStore结合使用?您好@Jean Michel谢谢您的回复,我使用ESB代理服务将消息放入队列,其他JMS代理服务将侦听此队列并对其进行处理。消息经常会到达queu在Active MQ成功提供到ESB的tcp连接之前,我会发布第一个答案,但告诉我当if开始失败时,ActiveMQ中的消息数量是否在增加(队列中等待数千条消息)发生此问题时,队列中没有等待的消息。收到所有消息后,将立即处理这些消息。
<sequence xmlns="http://ws.apache.org/ns/synapse"
          name="JmsStore_Seq"
          trace="disable">
   <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
   <property xmlns:ns="http://org.apache.synapse/xsd"
             name="Authentication"
             expression="//Authentication/text()"/>
   <property xmlns:ns="http://org.apache.synapse/xsd"
             name="UserId"
             expression="//UserId/text()"
             scope="default"
             type="STRING"/>
   <property xmlns:ns="http://org.apache.synapse/xsd"
             name="WorkOUid"
             expression="//WorkOUid/text()"/>
   <property xmlns:ns="http://org.apache.synapse/xsd"
             name="WorkPartyBranchId"
             expression="//WorkPartyBranchId/text()"/>

   <filter xmlns:ns="http://org.apache.synapse/xsd"
           xpath="get-property('Authentication')=''">
      <then>
         <payloadFactory media-type="xml">
            <format>
               <ResponseJSON xmlns="">
                  <Exception>Service trying to connect inactive service</Exception>
                  <Status>101503</Status>
               </ResponseJSON>
            </format>
            <args/>
         </payloadFactory>
         <property name="messageType" value="application/json" scope="axis2"/>
         <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
         <property name="RESPONSE" value="true" scope="default" type="STRING"/>
         <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
         <send/>
      </then>
      <else>
         <filter xpath="get-property('Authentication')='false'">
            <then>
               <payloadFactory media-type="xml">
                  <format>
                     <ResponseJSON xmlns="">
                        <Exception>Authentication Failed</Exception>
                        <Status>401</Status>
                     </ResponseJSON>
                  </format>
                  <args/>
               </payloadFactory>
               <property name="messageType" value="application/json" scope="axis2"/>
               <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
               <property name="RESPONSE" value="true" scope="default" type="STRING"/>
               <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
               <send/>
            </then>
            <else>
               <property name="jmspayload"
                         expression="get-property('readingspayload')"
                         type="OM"/>
               <property name="ResponseJSON" expression="$body/ResponseJSON" type="OM"/>
               <property name="jmsuri" expression="get-property('jmsuri')"/>
               <property name="jmsqueue" expression="get-property('jmsqueue')"/>
               <payloadFactory media-type="xml">
                  <format>
                     <PLData>
                        <JMpayload>$1</JMpayload>
                        <AuthData>$2</AuthData>
                        <LogData>
                           <usercode>$3</usercode>
                           <clientid>$4</clientid>
                           <requestMsgId>$5</requestMsgId>
                        </LogData>
                     </PLData>
                  </format>
                  <args>
                     <arg evaluator="xml" expression="get-property('jmspayload')"/>
                     <arg evaluator="xml" expression="get-property('ResponseJSON')"/>
                     <arg evaluator="xml" expression="get-property('usercode')"/>
                     <arg evaluator="xml" expression="get-property('clientid')"/>
                     <arg evaluator="xml" expression="get-property('requestMsgId')"/>
                  </args>
               </payloadFactory>
               <class name="in.youtility.esb.custommediators.JMSStoreMediator"/>
               <payloadFactory media-type="xml">
                  <format>
                     <ResponseJSON xmlns="">
                        <Body>
                           <Datalist>
                              <Data>Successfully stored</Data>
                           </Datalist>
                        </Body>
                        <Status>200</Status>
                     </ResponseJSON>
                  </format>
                  <args/>
               </payloadFactory>
               <property name="messageType" value="application/json" scope="axis2"/>
               <header name="To" action="remove"/>
               <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
               <property name="RESPONSE" value="true"/>
               <send/>
            </else>
         </filter>
      </else>
   </filter>
   <description/>
</sequence>
public class JMSStoreMediator extends AbstractMediator implements
Connection connection;

public boolean mediate(MessageContext msgCtx) { 


     try {
         boolean topic=false;
        String jmsuri=""+msgCtx.getProperty("jmsuri");
        String t=""+msgCtx.getProperty("topic");

        if(t.isEmpty()){

            topic=false;
        }
        else {

            topic=Boolean.valueOf(t);
        }

        ConnectionFactory factory= new ActiveMQConnectionFactory(jmsuri);
        connection = factory.createConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination=null;
        if(!topic)destination= session.createQueue(""+msgCtx.getProperty("jmsqueue"));
        else destination= session.createTopic(""+msgCtx.getProperty("jmsqueue"));
        MessageProducer producer = session.createProducer(destination);
        producer.setDeliveryMode(DeliveryMode.PERSISTENT);

        String xml = ""+msgCtx.getEnvelope().getBody().toStringWithConsume();

        if(topic){

            JSONObject obj=XML.toJSONObject(xml);
            JSONObject ar=obj.getJSONObject("soapenv:Body");
            ar.remove("xmlns:soapenv");
            xml=ar.toString();
        }
        TextMessage message = session.createTextMessage(xml);
        producer.send(message);

    } catch (Exception e) {

        log.info("LogLocation = "+getClass().getName()+",Error in storing message in JMS stacktrace is :"+e.toString());
        ((Axis2MessageContext) msgCtx).setProperty(NhttpConstants.HTTP_SC, 500);
        handleException("Error while storing in the message store", msgCtx);

    }
    finally {
        try {
            connection.close();

        } catch (JMSException e) {
            log.info("LogLocation = "+getClass().getName()+",Error in closing JMS connection stacktrace is :"+e.toString());
        }
    }
        log.info("LogLocation = "+getClass().getName()+",ProxyName = "+msgCtx.getProperty("proxy.name")+
            ",Usercode = "+msgCtx.getProperty("usercode")+",Clientid = "+msgCtx.getProperty("clientid")+
            ",requestMsgId = "+msgCtx.getProperty("requestMsgId")+",Position = END"); 

    return true;
}