1 Reply Latest reply on Apr 12, 2013 4:22 AM by puttime

    How to pump messages to ActiveMQ?

    puttime

      I have followed the instructions to include ActiveMQ in jBoss AS.

      https://community.jboss.org/wiki/IntegrationOfJBossAS7WithActiveMQ

      I'm using it as an internal messaging broker.

       

      I've created a new SwitchYard project, which uses JMS binding.

       

      Now I need to test it with a client app.

      For HornetQ, it was straight forward.

       

       

      HornetQMixIn hqMixIn = new HornetQMixIn(false)
                                          .setUser(USER)
                                          .setPassword(PASSWD);
              if (args.length == 0) {
                  return;
              }
              
              hqMixIn.initialize();
              try {
                  final Session session = hqMixIn.createJMSSession();
                  final MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(QUEUE));
               }
       
       blah blah
      

       

       

      What should I do to do the same using ActiveMQ?

       

       

      I tried the sample provided in the above URL, but it didn't work (compiler errors):

       

       

      [Error = The annotation @MessageDriven is disallowed for this location]
       @MessageDriven(activationConfig = {
                 @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
                 @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
                 @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue.queue_in") }) // Note the physical name of the queue
           @ResourceAdapter("activemq-ra.rar")
      
       
       
         [Error = The annotation @Resource is disallowed for this location]
            @Resource(mappedName = "java:/activemq/ConnectionFactory")
              ConnectionFactory connectionFactory;
              @Resource(mappedName = "java:/activemq/queue_out") // Note the mapped name of the queue
              Destination queue;
              Connection connection;
      
      

       

      Also, if I use ActiveMQ, do I still need to prepare and copy the "project_name-jms.xml" file to standalone/deployments folder?

       

      With ActiveMQ, the queue names seem to be defined in the config XML file, like for example queue.queue_in and queue.queue_out. Is that right?

       

      So for the JMS queue name, I provide queue.queue_in as the name right?

        • 1. Re: How to pump messages to ActiveMQ?
          puttime

          I was able to compile ActiveMQConnectionFactory.

          I added this dependency to pom.xml.

          <dependency>
              <groupId>org.apache.activemq</groupId>
              <artifactId>activemq-all</artifactId>
              <version>5.8.0</version>
           </dependency>
          
          

           

           

          And I was able to send the message also, but I don't get the message on the server side. I don't even see any failure message also.

          I've also attached the project contents.

           

          Here's the log from the client:

           

          SLF4J: Class path contains multiple SLF4J bindings.
          SLF4J: Found binding in [jar:file:/C:/Users/keshavc/.m2/repository/org/apache/activemq/activemq-all/5.8.0/activemq-all-5.8.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
          SLF4J: Found binding in [jar:file:/C:/Users/keshavc/.m2/repository/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
          SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
          SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
          13:43:18,665 WARN  [jmx.ManagementContext] Failed to start jmx connector: Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]. Will restart management to re-create jmx connector, trying to remedy this issue.
          13:43:18,665 INFO  [broker.BrokerService] Using Persistence Adapter: MemoryPersistenceAdapter
          13:43:18,837 INFO  [broker.BrokerService] Apache ActiveMQ 5.8.0 (localhost, ID:keshavc-win7-61835-1365754398681-0:1) is starting
          13:43:18,853 WARN  [jmx.ManagementContext] Failed to start jmx connector: Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]. Will restart management to re-create jmx connector, trying to remedy this issue.
          13:43:18,853 INFO  [broker.BrokerService] Apache ActiveMQ 5.8.0 (localhost, ID:keshavc-win7-61835-1365754398681-0:1) started
          13:43:18,853 INFO  [broker.BrokerService] For help or more information please see: http://activemq.apache.org
          13:43:18,884 INFO  [broker.TransportConnector] Connector vm://localhost Started
          <?xml version="1.0" encoding="UTF-8"?>
          <person>
              <name>dippyyy</name>
              <language>english</language>
          </person>
          Sent message [ActiveMQTextMessage {commandId = 0, responseRequired = false, messageId = ID:keshavc-win7-61835-1365754398681-3:1:1:1:1, originalDestination = null, originalTransactionId = null, producerId = null, destination = queue://MyActiveQueue1, transactionId = TX:ID:keshavc-win7-61835-1365754398681-3:1:1, expiration = 0, timestamp = 1365754398993, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody = false, droppable = false, text = <?xml version="1.0" encoding="UTF-8"?>
          <perso...>
          </person>
          }]
          13:43:18,993 INFO  [broker.BrokerService] Apache ActiveMQ 5.8.0 (localhost, ID:keshavc-win7-61835-1365754398681-0:1) is shutting down
          13:43:19,009 INFO  [broker.TransportConnector] Connector vm://localhost Stopped
          13:43:19,009 INFO  [broker.BrokerService] Apache ActiveMQ 5.8.0 (localhost, ID:keshavc-win7-61835-1365754398681-0:1) uptime 0.485 seconds
          13:43:19,009 INFO  [broker.BrokerService] Apache ActiveMQ 5.8.0 (localhost, ID:keshavc-win7-61835-1365754398681-0:1) is shutdown