ActiveMQ JMS:未知数据类型-1

时间:2016-11-01 08:08:59

标签: java jms activemq

我使用下面的代码连接到JMS。我无法创建连接工厂,因为在PROD环境中,我只是一个消费者,并且不知道它安装了哪个服务器。我有经纪人URL,用户名和密码。

public class HelloWorldProducer implements Runnable {
    public void run() {
        try {
            // Create a ConnectionFactory
            ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("id972483","octitt123","tcp://ozoi6000:2506");

            // Create a Connection
         Connection connection = connectionFactory.createConnection();

            connection.start();

            // Create a Session
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

            // Create the destination (Topic or Queue)
            Destination destination = session.createQueue("gw.oct.request.letterbusinesscommunication.v1.in.q");

            // Create a MessageProducer from the Session to the Topic or Queue
            MessageProducer producer = session.createProducer(destination);
            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

            // Create a messages
            //String text = "Hello world! From: " + Thread.currentThread().getName() + " : " + this.hashCode();
            TextMessage message = session.createTextMessage(getXMLdata());
            message.setJMSCorrelationID("Sample_JMS_Test");

            // Tell the producer to send the message
            System.out.println("Sent message: "+ message.hashCode() + " : " + Thread.currentThread().getName());
            producer.send(message);

            // Clean up
            session.close();
            connection.close();
        }
        catch (Exception e) {
            System.out.println("Caught: " + e);
            e.printStackTrace();
        }
    }

我收到如下错误:

Caught: javax.jms.JMSException: Disposed due to prior exception
javax.jms.JMSException: Disposed due to prior exception
    at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:72)
    at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1413)
    at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1478)
    at org.apache.activemq.ActiveMQConnection.start(ActiveMQConnection.java:527)
    at HelloWorldProducer.run(HelloWorldProducer.java:25)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.activemq.transport.TransportDisposedIOException: Disposed due to prior exception
    at org.apache.activemq.transport.ResponseCorrelator.onException(ResponseCorrelator.java:125)
    at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:114)
    at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:114)
    at org.apache.activemq.transport.WireFormatNegotiator.onException(WireFormatNegotiator.java:173)
    at org.apache.activemq.transport.AbstractInactivityMonitor.onException(AbstractInactivityMonitor.java:344)
    at org.apache.activemq.transport.TransportSupport.onException(TransportSupport.java:96)
    at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:219)
    ... 1 more
Caused by: java.io.IOException: Unknown data type: -1
    at org.apache.activemq.openwire.OpenWireFormat.doUnmarshal(OpenWireFormat.java:359)
    at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:278)
    at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:240)
    at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:232)
    at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)
    ... 1 more

1 个答案:

答案 0 :(得分:1)

您尝试连接的端口上配置了什么?尝试将JMS客户端连接到为ActiveMQ JMS客户端所说的OpenWire协议以外的协议提供服务的端口时,您会看到这些类型的错误。

当遇到这样的错误时,通常最好询问代理实际配置的内容