8 Replies Latest reply on Feb 26, 2013 9:26 AM by Diego Santiviago

    HornetQ taskclient connection exceptions.

    Dsire krish Newbie

      1. When im connecting to the HornetQ task service with


      String name = "client 1" ;

      TaskClient client = new TaskClient(new HornetQTaskClientConnector(name, new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

       

      and operate on the tasks with client.start() and client.complete(), im getting this classcastexception.

       

      Exception in thread "Thread-2" java.lang.RuntimeException: Client Exception with class class org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1 using port 5445

                at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:134)

                at java.lang.Thread.run(Unknown Source)

      Caused by: java.lang.ClassCastException: org.jbpm.task.service.responsehandlers.BlockingQueryGenericResponseHandler cannot be cast to org.jbpm.task.service.TaskClientHandler$TaskOperationResponseHandler

                at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:64)

                at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56)

                at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:120)

       

      2. But if i connect to the service with adding a random number.

       

      String name = "client 1" ++UUID.randomUUID();

      TaskClient client = new TaskClient(new HornetQTaskClientConnector(name, new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

       

      Im getting java heap space issue with too many open client session.

       

      Is it a problem because as im not disconnecting client (client.disconnect()) .?

      Is there any simple example of using HornetQ.?

       

      Kinldy help in this issue.

        • 1. Re: HornetQ taskclient connection exceptions.
          Dsire krish Newbie

          I have also found other two types of client connections.

           

          1.     AsyncTaskService  client = new AsyncHornetQTaskClient();

                  client.connect("127.0.0.1", 5445);

           

          2.     TaskService  client = new SyncTaskServiceWrapper(new AsyncHornetQTaskClient());

                  client.connect("127.0.0.1", 5445);

           

          which one should i prefer, at which scenarios.?

          • 2. Re: HornetQ taskclient connection exceptions.
            Mauricio Salatino Master

            1.     AsyncTaskService  client = new AsyncHornetQTaskClient();

                    client.connect("127.0.0.1", 5445);

            This is an Async Client, if you are using hornetQ that's probably what you want to have. 

             

            2.     TaskService  client = new SyncTaskServiceWrapper(new AsyncHornetQTaskClient());

                    client.connect("127.0.0.1", 5445);

            THis is the same but wrapped by a layer which abstract the async behaviour of HornetQ, it's up to you. Look at the methods that are exposed.

            For the AsyncTaskService you will need to provide a handler that will be called when you receive a response. The SyncWrapper hide those handlers.

             

            About the expcetion:

            String name = "client 1" ++UUID.randomUUID();

            TaskClient client = new TaskClient(new HornetQTaskClientConnector(name, new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

             

            Are you creating too much clients? When are you creating them? you should close them, if you are not using them anymore or reuse them.


            • 3. Re: HornetQ taskclient connection exceptions.
              Dsire krish Newbie

              Thanks Mauricio.

               

              1. Actually im creating one client and reusing them. Have to probe further into that exception.

               

              2.Currently im trying the async client AsyncTaskService  client = new AsyncHornetQTaskClient(); . But im getting time out exception.

               

                   java.lang.RuntimeException: Timeout : unable to retrieve results

                   at org.jbpm.task.service.responsehandlers.BlockingTaskSummaryResponseHandler.getResults(BlockingTaskSummaryResponseHandler.java:41)

               

              why could that be.? Kindly suggest a way out.

              • 4. Re: HornetQ taskclient connection exceptions.
                Mauricio Salatino Master

                It could be a failure in the server side..

                Which version are you using? Did you check the latest snapshots to see if you have the same troubles?

                • 5. Re: HornetQ taskclient connection exceptions.
                  Dsire krish Newbie

                  I could successfully connect the CommandbasedHornetQWSHumantaskhandler to the HornetQ taskserver and even able to start new processinstances.

                  But im facing problem when connecting the taskclient to the HornetQserver to process the tasks.

                   

                  HornetQserver:

                   

                  EntityManagerFactory emfTask = Persistence.createEntityManagerFactory("org.jbpm.task");

                  TaskService taskService = new TaskService(emfTask, SystemEventListenerFactory.getSystemEventListener());

                  HornetQTaskServer server = new HornetQTaskServer(taskService,5445);

                  Thread thread = new Thread(server);

                  thread.start();

                   

                  Handler;

                   

                    taskHandler = new CommandBasedHornetQWSHumanTaskHandler(ksession);

                    ksession.getWorkItemManager().registerWorkItemHandler("Human Task",taskHandler);

                    taskHandler.setConnection("127.0.0.1 ", 5445);

                    taskHandler.connect();


                  Taskclient:

                   

                    String name = "hornetq client 1" +UUID.randomUUID();

                                                client = new TaskClient(new HornetQTaskClientConnector(name, new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

                                                boolean connected =   client.connect("127.0.0.1", 5445);

                   

                  With this client i couldnt operate on the tasks. Im getting exception on the server side.

                  java.lang.RuntimeException: Server Exception with class class org.jbpm.task.service.hornetq.HornetQTaskServer using port 5445

                  2012-07-06 01:15:58,031 ERROR [STDERR] (Thread-17)           at org.jbpm.task.service.hornetq.BaseHornetQTaskServer.run(BaseHornetQTaskServer.java:100)

                  2012-07-06 01:15:58,031 ERROR [STDERR] (Thread-17)           at java.lang.Thread.run(Thread.java:619)

                  2012-07-06 01:15:58,031 ERROR [STDERR] (Thread-17) Caused by: java.io.IOException: Error reading message

                  2012-07-06 01:15:58,031 ERROR [STDERR] (Thread-17)           at org.jbpm.task.service.hornetq.BaseHornetQTaskServer.readMessage(BaseHornetQTaskServer.java:113)

                  2012-07-06 01:15:58,031 ERROR [STDERR] (Thread-17)           at org.jbpm.task.service.hornetq.BaseHornetQTaskServer.run(BaseHornetQTaskServer.java:83)

                   

                  I have taken latest version jbpm 5.3.

                  1. Are the connectivity code snippets are correct.?

                  2. Kindly provide some example code snippet for client connectivity with HornetQ.

                  • 6. Re: HornetQ taskclient connection exceptions.
                    Joshua Godwin Newbie

                    Hi Krish ,

                    Any luck solving this problem?, i just started evaluating JBPM 5.3, so i am not too sure how to proceed with this.Could you point me to any examples that you may have found out, that show how to connect to HornetQ? Thanks.

                    • 7. Re: HornetQ taskclient connection exceptions.
                      Jose Miguel Loor Apprentice

                      hI

                       

                      I am struggling with almost the same thing. I have BRMS server on testing. I modified the web.xml in the jbpm-human-task.war/WEB-INF with this values:

                       

                      <init-param>

                              <param-name>mina.host</param-name>

                              <param-value>192.168.0.95</param-value>

                            </init-param>

                            <init-param>

                              <param-name>mina.port</param-name>

                              <param-value>9123</param-value>

                            </init-param>

                       

                      and this code:

                       

                      CommandBasedHornetQWSHumanTaskHandler hornetTaskHandler = new CommandBasedHornetQWSHumanTaskHandler(this.ksession);

                      hornetTaskHandler.setConnection("192.168.0.95", 9123);

                      hornetTaskHandler.connect();

                       

                      gives me this exception:

                       

                      java.lang.IllegalArgumentException: Could not connect task client

                                at org.jbpm.task.service.hornetq.CommandBasedHornetQWSHumanTaskHandler.connect(CommandBasedHornetQWSHumanTaskHandler.java:96)

                                at com.ndeveloper.rules.client.BRMSKnowledgeProcessRulesHandler.registerWorkItemHandlers(BRMSKnowledgeProcessRulesHandler.java:182)

                                at com.ndeveloper.rules.client.BRMSKnowledgeProcessRulesHandler.getKSession(BRMSKnowledgeProcessRulesHandler.java:119)

                                at com.ndeveloper.rules.client.BRMSKnowledgeProcessRulesHandler.startProcess(BRMSKnowledgeProcessRulesHandler.java:64)

                                at com.ndeveloper.rules.client.ProcessTest.startProcess(ProcessTest.java:32)

                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                                at java.lang.reflect.Method.invoke(Method.java:601)

                                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

                                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

                                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

                                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

                                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                                at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

                       

                      any hints about this ??

                      • 8. Re: HornetQ taskclient connection exceptions.
                        Diego Santiviago Newbie

                        This is Mina configuration:

                         

                        <init-param>

                             <param-name>mina.host</param-name>

                             <param-value>192.168.0.95</param-value>

                        </init-param>

                        <init-param>

                            <param-name>mina.port</param-name>

                            <param-value>9123</param-value>

                        </init-param>

                         

                        And you use HornetQ configuration:

                         

                        CommandBasedHornetQWSHumanTaskHandler hornetTaskHandler = new CommandBasedHornetQWSHumanTaskHandler(this.ksession);

                        hornetTaskHandler.setConnection("192.168.0.95", 9123);

                        hornetTaskHandler.connect();