Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Invalid
-
5.15.3
-
None
-
None
-
Important
Description
activemq.xml 文件:
udp协议传输配置 <transportConnector name="udp" uri="udp://0.0.0.0:9010"/>
java 客户端连接器code:
import org.apache.activemq.ActiveMQConnectionFactory;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.Session;
public class MQConnector implements ErrorCode {
public static Destination destination;
public static Connection connection;
public static Session session;
//尝试连接队列服务若成功 生成一个MessageConsumer接口对应的类型,其中包含发送信息的方法;
public int connect(String url, String topic) throws Exception {
try
{ // Create a ConnectionFactory ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url); // Create a Connection connection = connectionFactory.createConnection(); connection.start(); // Create a Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Create the destination (Topic or Queue) destination = session.createQueue(topic); //返回错误值 return CONNECT_SUCCESS; }catch (Exception e)
{ //打印错误 System.out.println("Caught connect error:" + e); e.printStackTrace(); return CONNECT_ERROR; } }
}