0 Replies Latest reply on Oct 23, 2013 11:21 PM by xiaojie Ma

    HQ214013: Failed to decode packet: java.lang.IllegalArgumentException: HQ119032: Invalid type: -1  &&  Failed to connect to any server. Servers tried: [remote://10.19.x.x:5445]

    xiaojie Ma Newbie

      1. wildfly beta1(hornetq) ,standalone-full.xml ,myeclipse

       

      2.I want to use below JMSProducer and JMSConsumer code to test hornetq communication.

       

      3.add next to the standalone-full.xml configuration. and I also  put jboss-client.jar and jboss-cli-client.jar to the myeclipse lib.

      <jms-destinations>

        <jms-queue name="testQueue">

        <entry name="queue/test"/>

        <entry name="java:jboss/exported/jms/queue/test"/>

        </jms-queue>

        <jms-topic name="ServerNotificationTopic">

        <entry name="topic/ServerNotification"/>

        <entry name="java:jboss/exported/jms/topic/ServerNotification"/>

        </jms-topic>

        </jms-destinations>

       

      4.JMSProducer

      package org.credo.jms;

       

      import java.util.concurrent.CountDownLatch;

      import java.util.concurrent.TimeUnit;

      import java.util.logging.Logger;

      import java.util.Properties;

       

      import javax.jms.Connection;

      import javax.jms.ConnectionFactory;

      import javax.jms.Destination;

      import javax.jms.MessageProducer;

      import javax.jms.Session;

      import javax.jms.TextMessage;

      import javax.naming.Context;

      import javax.naming.InitialContext;

       

      /**

      * <p>Description:JMS </p>

      */

      public class JMSProducer {

      private static final Logger log = Logger.getLogger(JMSProducer.class.getName());

       

      private static final String DEFAULT_MESSAGE = "the 4 message!";

       

      private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";

       

      private static final String DEFAULT_DESTINATION = "jms/queue/test";

      private static final String DEFAULT_MESSAGE_COUNT = "1";

       

      private static final String DEFAULT_USERNAME = "send";

      private static final String DEFAULT_PASSWORD = "123456";

      private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";

      private static final String PROVIDER_URL = "remote://10.19.*.*:5445";

       

      public static void main(String[] args) throws Exception {

      Context context=null;

      Connection connection=null;

      try {

       

      log.info("look for jndi");

      final Properties env = new Properties();

      env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);//

      env.put(Context.PROVIDER_URL, PROVIDER_URL);//

      env.put(Context.SECURITY_PRINCIPAL, DEFAULT_USERNAME);

      env.put(Context.SECURITY_CREDENTIALS, DEFAULT_PASSWORD);//

       

      context = new InitialContext(env);

      log.info("acount,secret");

       

      log.info("CONNECTION_FACTORY!");

      ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup(DEFAULT_CONNECTION_FACTORY);

      log.info("DESTINATION!");

      Destination destination = (Destination) context.lookup(DEFAULT_DESTINATION);

       

       

      connection = connectionFactory.createConnection(DEFAULT_USERNAME, DEFAULT_PASSWORD);

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

      MessageProducer producer = session.createProducer(destination);

      connection.start();

       

      int count = Integer.parseInt(DEFAULT_MESSAGE_COUNT);

       

      TextMessage message = null;

      for (int i = 0; i < count; i++) {

      message = session.createTextMessage(DEFAULT_MESSAGE);

      producer.send(message);

      log.info("message:"+message);

      log.info("message:"+DEFAULT_MESSAGE);

      }

       

      CountDownLatch latch = new CountDownLatch(1);

      latch.await(30, TimeUnit.SECONDS);

       

      } catch (Exception e) {

      log.severe(e.getMessage());

      throw e;

      } finally {

      if (context != null) {

      context.close();

      }

       

      if (connection != null) {

      connection.close();

      }

      }

      }

      }

      but when I run this code ,I find mistake below;

      Serious: Failed to connect to any server. Servers tried: [remote://10.19.*.*:5445]

      Exception in thread "main" javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://10.19.*.*:5445]

        at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:213)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:144)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:125)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:241)

        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)

        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)

        at javax.naming.InitialContext.lookup(InitialContext.java:392)

        at org.credo.jms.JMSProducer.main(JMSProducer.java:53)

      and jboss start consloe appear :

      14:17:02,738 ERROR [org.hornetq.core.client] (Old I/O server worker (parentId: 130676233, [id: 0x07c9f609, /10.19.*.*:5445])) HQ214013: Failed to decode packet: java.lang.IllegalArgumentException: HQ119032: Invalid type: -1

        at org.hornetq.core.protocol.core.impl.PacketDecoder.decode(PacketDecoder.java:441) [hornetq-core-client-2.4.0.Beta2.jar:]

        at org.hornetq.core.protocol.ServerPacketDecoder.decode(ServerPacketDecoder.java:180) [hornetq-server-2.4.0.Beta2.jar:]

        at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.bufferReceived(RemotingConnectionImpl.java:485) [hornetq-core-client-2.4.0.Beta2.jar:]

        at org.hornetq.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:594) [hornetq-server-2.4.0.Beta2.jar:]

        at org.hornetq.core.remoting.impl.netty.HornetQChannelHandler.messageReceived(HornetQChannelHandler.java:72) [hornetq-core-client-2.4.0.Beta2.jar:]

        at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:88) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:281) [netty-3.6.6.Final.jar:]

        at org.hornetq.core.remoting.impl.netty.HornetQFrameDecoder2.decode(HornetQFrameDecoder2.java:169) [hornetq-core-client-2.4.0.Beta2.jar:]

        at org.hornetq.core.remoting.impl.netty.HornetQFrameDecoder2.messageReceived(HornetQFrameDecoder2.java:134) [hornetq-core-client-2.4.0.Beta2.jar:]

        at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.socket.oio.OioWorker.process(OioWorker.java:71) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.socket.oio.AbstractOioWorker.run(AbstractOioWorker.java:73) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.channel.socket.oio.OioWorker.run(OioWorker.java:51) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [netty-3.6.6.Final.jar:]

        at org.jboss.netty.util.VirtualExecutorService$ChildExecutorRunnable.run(VirtualExecutorService.java:175) [netty-3.6.6.Final.jar:]

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]

        at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

      message listen port is 5445 and 5545 ,network and port  is ok. I don't know why code cannot connect the jboss.

      <socket-binding name="messaging" port="5445"/>

              <socket-binding name="messaging-group" port="0" multicast-address="${jboss.messaging.group.address:231.7.7.7}" multicast-port="${jboss.messaging.group.port:9876}"/>

              <socket-binding name="messaging-throughput" port="5455"/>

      In fact,there is no remoting port 4447  socket in wildfly beta1.

           what can I do ? thanks