7 Replies Latest reply on Sep 5, 2011 10:33 AM by pierx83

    Start a process remotely by using Java

    pierx83

      Hi to all; my goal is to find a way to start a jbpm process remotely by using a java program (I'm using jBPM 5.1).

      Actually I have no idea how to do that.

      Please, can you help me?

       

      Thanks in advance,

      Pierpaolo

        • 1. Re: Start a process remotely by using Java
          eaa

          If your processes are deployed in jbpm-gwt-console, then you can use its REST API to interacto with them.

          • 2. Re: Start a process remotely by using Java
            pierx83

            I supposed to use something like the TaskClient I use to manage the task. Is there such a thing?

             

            Thanks,

            Pierpaolo

            • 3. Re: Start a process remotely by using Java
              eaa

              Are you using jbpm-gwt-console to deploy/run your processes?

              • 4. Re: Start a process remotely by using Java
                pierx83

                Actually I'm using the jbpm-gwt-console so I have the REST interface as you suggested me before.

                 

                Therefore, my goal is to develop a different GUI for the task management (task list, start task and so on) so probably I will put the jbpm jars inside the project I'm developing but in this case:

                - I don't need the RESt interface (but of course it is not available without the jpm-gwt-console)

                - I cannot use the advantages of jbpm-gtw-console and guvnor integration

                 

                 

                What do you suggested me? To use the gwt console or not?

                 

                Thanks,

                Pierpaolo

                • 5. Re: Start a process remotely by using Java
                  pierx83

                  Anyway, I'm trying using the REST interface to start a process but I have a problem cause the answer I get is the html source of the login form

                   

                  How can I sove this?

                   

                  The code I use is:

                   

                           URL url = new URL("http://localhost:8080/gwt-console-server/rs/process/definition/HelloHT/new_instance");

                            HttpURLConnection conn =

                                (HttpURLConnection) url.openConnection();

                            conn.setRequestMethod("POST");

                            conn.setDoOutput(true);

                            conn.setDoInput(true);

                            conn.setUseCaches(false);

                            conn.setAllowUserInteraction(false);

                            conn.setRequestProperty("Content-Type",

                                "application/x-www-form-urlencoded");

                           

                            if (conn.getResponseCode() != 200) {

                              throw new IOException(conn.getResponseMessage());

                            }

                   

                            // Buffer the result into a string

                            BufferedReader rd = new BufferedReader(

                                new InputStreamReader(conn.getInputStream()));

                            StringBuilder sb = new StringBuilder();

                            String line;

                            while ((line = rd.readLine()) != null) {

                              sb.append(line);

                            }

                            rd.close();

                            System.out.println(sb.toString());

                  • 6. Re: Start a process remotely by using Java
                    npereira

                    Hi Pierpaolo,

                     

                    There was a similar discussion in the forum just this week.

                     

                    You can follow the following link, http://community.jboss.org/thread/166755

                     

                    I hope it helps.

                     

                    Regards

                    • 7. Re: Start a process remotely by using Java
                      pierx83

                      Thanks for your reply!

                      Yes, I found that link and it helped me. it works now but actually I'm facing a new problem: how to fire an event remotely? The REST interface doen't allow me do that...

                      Do you have an idea?

                       

                      Thanks,

                      Pierpaolo